#1313: #to_json will cause a stack overflow if generating a collection with objective-c objects ------------------------------------+--------------------------------------- Reporter: mrada@… | Owner: lsansonetti@… Type: defect | Status: new Priority: critical | Milestone: Component: MacRuby | Keywords: reduction 0.11-blocker ------------------------------------+--------------------------------------- Comment(by mrada@…): The problem with that solution is that it would only stop the crash. We would still be generating incorrect JSON for NSDictionary since NSDictionary#to_s will be called and it does not generate a valid JSON hash. Then, there is the additional problem that the Object#to_json method is not defined when loading the ext version of json, which means that code that depends on #to_json to be defined on all objects will break. I think the best solution to the problem is https://github.com/ferrous26/MacRuby/commit/bd65650315b, this is because of the way that the generator methods are mixed in the proper classes. However, the same fix cannot be applied to C version of json because of #1326. The other possible fix is to make a change to the method that mixes the generators in so that it mixes them in to the proper Foundation classes. Then there is still https://github.com/ferrous26/MacRuby/commit/8a0f79a5122c8, which adds proper detection, otherwise we are depending on the #to_json or the #to_json.to_s catch-all at the bottom which just adds needless overhead to the generation. Though I think this is something I can push upstream. -- Ticket URL: <http://www.macruby.org/trac/ticket/1313#comment:5> MacRuby <http://macruby.org/>