{"action":"closed","issue":{"url":"https://api.github.com/repos/munificent/wren/issues/280","labels_url":"https://api.github.com/repos/munificent/wren/issues/280/labels{/name}","comments_url":"https://api.github.com/repos/munificent/wren/issues/280/comments","events_url":"https://api.github.com/repos/munificent/wren/issues/280/events","html_url":"https://github.com/munificent/wren/issues/280","id":85915631,"number":280,"title":"Deeply nested objects can result in a stack overflow in the garbage collector","user":{"login":"rxi","id":3920290,"avatar_url":"https://avatars.githubusercontent.com/u/3920290?v=3","gravatar_id":"","url":"https://api.github.com/users/rxi","html_url":"https://github.com/rxi","followers_url":"https://api.github.com/users/rxi/followers","following_url":"https://api.github.com/users/rxi/following{/other_user}","gists_url":"https://api.github.com/users/rxi/gists{/gist_id}","starred_url":"https://api.github.com/users/rxi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rxi/subscriptions","organizations_url":"https://api.github.com/users/rxi/orgs","repos_url":"https://api.github.com/users/rxi/repos","events_url":"https://api.github.com/users/rxi/events{/privacy}","received_events_url":"https://api.github.com/users/rxi/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-06-07T16:31:34Z","updated_at":"2015-11-19T15:56:23Z","closed_at":"2015-11-19T15:56:23Z","body":"Due to the garbage collector using recursion on the C stack to mark the objects, deeply nested objects can result in a stack overflow. On my system, the following example results in one:\r\n\r\n```\r\nvar head\r\n\r\nfor (i in 1..400000) {\r\n  head = { \"next\" : head }\r\n}\r\n\r\nIO.print(\"done\")\r\n```\r\n\r\ngdb backtrace:\r\n\r\n```\r\nProgram received signal SIGSEGV, Segmentation fault.\r\n0x000000000040a92c in wrenMarkObj ()\r\n(gdb) bt\r\n#0  0x000000000040a92c in wrenMarkObj ()\r\n#1  0x000000000040ab78 in wrenMarkObj ()\r\n#2  0x000000000040ab85 in wrenMarkObj ()\r\n#3  0x000000000040ab85 in wrenMarkObj ()\r\n...\r\n```\r\n\r\nMoving to a tri-color garbage collector would fix this issue; additionally it would also act as the first step towards the garbage collector being able to work incrementally. \r\n\r\n"}}