Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#1344 Ruby: Director callbacks must happen on a Ruby thread

open
nobody
ruby (61)
5
2013-10-17
2013-10-17
Soren Dreijer
No

It looks like the use of directors for Ruby doesn't ensure that the calling thread is actually a native Ruby thread. That is, SWIG blindly makes the call to Ruby-land from any thread rather than marshalling the call to a Ruby thread first.

Calls to Ruby must happen on a Ruby thread (http://burgestrand.se/articles/asynchronous-callbacks-in-ruby-c-extensions.html) or otherwise the Ruby VM gets mighty upset: http://comments.gmane.org/gmane.comp.programming.swig/19854

A repro is available here: https://dl.dropboxusercontent.com/u/2406449/Swig/SwigRubyHang.7z

A fix is fairly trivial: All director calls should just be marshalled to a Ruby thread with e.g. rb_thread_create().

Discussion