{"action":"created","issue":{"url":"https://api.github.com/repos/DFHack/dfhack/issues/271","labels_url":"https://api.github.com/repos/DFHack/dfhack/issues/271/labels{/name}","comments_url":"https://api.github.com/repos/DFHack/dfhack/issues/271/comments","events_url":"https://api.github.com/repos/DFHack/dfhack/issues/271/events","html_url":"https://github.com/DFHack/dfhack/issues/271","id":38630668,"number":271,"title":"Ruby 1.9 - require an \".so\" file crashes (need to init stack?)","user":{"login":"benhell","id":3821303,"avatar_url":"https://avatars.githubusercontent.com/u/3821303?v=3","gravatar_id":"","url":"https://api.github.com/users/benhell","html_url":"https://github.com/benhell","followers_url":"https://api.github.com/users/benhell/followers","following_url":"https://api.github.com/users/benhell/following{/other_user}","gists_url":"https://api.github.com/users/benhell/gists{/gist_id}","starred_url":"https://api.github.com/users/benhell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benhell/subscriptions","organizations_url":"https://api.github.com/users/benhell/orgs","repos_url":"https://api.github.com/users/benhell/repos","events_url":"https://api.github.com/users/benhell/events{/privacy}","received_events_url":"https://api.github.com/users/benhell/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/DFHack/dfhack/labels/bug","name":"bug","color":"ff4f4f"},{"url":"https://api.github.com/repos/DFHack/dfhack/labels/internal","name":"internal","color":"bfd4f2"},{"url":"https://api.github.com/repos/DFHack/dfhack/labels/ruby","name":"ruby","color":"990000"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2014-07-24T13:26:22Z","updated_at":"2015-05-28T13:15:54Z","closed_at":null,"body":"While running on Windows, I noticed that requiring any of the .so files that typically exist in a Ruby installation (e.g., 'win32ole') causes dfhack to crash, hang, or the embedded ruby interpreter to throw a variety of low-level errors.\r\n\r\nDigging into ruby.cpp in dfhack, I noticed that RUBY_INIT_STACK is not called.  See http://stackoverflow.com/questions/6585610/why-does-this-code-not-work-on-ruby-1-9-but-works-on-ruby-1-8.  Apparently RUBY_INIT_STACK is a requirement when initializing an embedded version of at least Ruby 1.9 (not sure what is required for Ruby 2.0+).  Without it, I believe that certain features of the interpreter just blow up.\r\n\r\nI tested this (without recompiling DFHack) by creating an intermediate libruby DLL that exposed all of the Ruby DLL symbols that DFHack uses, but overrode ruby_sysinit to initially call RUBY_INIT_STACK.  I did this and ran a smoke test -- no longer crashes the interpreter, and thus far it has been stable.\r\n\r\nI realize that DFHack accesses the ruby DLL directly through its exported symbols and not by actually loading the ruby.h header file, which means you can't use the RUBY_INIT_STACK directly.  It appears to be a fairly simple macro though, so you might be able to import and call the one function it calls directly.  See ruby.h in any distribution of ruby.\r\n\r\nThanks,\r\n-Ben"},"comment":{"url":"https://api.github.com/repos/DFHack/dfhack/issues/comments/106306156","html_url":"https://github.com/DFHack/dfhack/issues/271#issuecomment-106306156","issue_url":"https://api.github.com/repos/DFHack/dfhack/issues/271","id":106306156,"user":{"login":"lethosor","id":3719547,"avatar_url":"https://avatars.githubusercontent.com/u/3719547?v=3","gravatar_id":"","url":"https://api.github.com/users/lethosor","html_url":"https://github.com/lethosor","followers_url":"https://api.github.com/users/lethosor/followers","following_url":"https://api.github.com/users/lethosor/following{/other_user}","gists_url":"https://api.github.com/users/lethosor/gists{/gist_id}","starred_url":"https://api.github.com/users/lethosor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lethosor/subscriptions","organizations_url":"https://api.github.com/users/lethosor/orgs","repos_url":"https://api.github.com/users/lethosor/repos","events_url":"https://api.github.com/users/lethosor/events{/privacy}","received_events_url":"https://api.github.com/users/lethosor/received_events","type":"User","site_admin":false},"created_at":"2015-05-28T13:15:54Z","updated_at":"2015-05-28T13:15:54Z","body":"We still use ruby 1.8, so nothing about this issue should have changed. I'm not sure which ruby libraries, if any, are distributed as binaries - I haven't seen DFHack distribute any, and DFHack scripts shouldn't be using anything platform-specific like win32ole.\r\n\r\nI'm not entirely sure what you mean about python support, but that's hardly relevant to this issue - DFHack python support only existed when DFHack was out-of-process, back in 2009 or so."}}