chuckremes / ffi-rzmq

FFI bindings for ZeroMQ so the library can be used under JRuby and other FFI-compliant ruby runtimes
242 stars 62 forks source link

Track pid in Context and Socket finalizers #92

Closed thinkerbot closed 11 years ago

thinkerbot commented 11 years ago

If a socket is created prior to fork then the reference to the socket (and the context) will carry forward to the child process. When the child process exits it will try to finalize the socket from the parent and a segfault results:

Assertion failed: ok (mailbox.cpp:84)
Abort trap: 6

Looks like they ran into the same thing on the perl wrapper and they fixed the issue by tracking the pid where the socket/context is created. Only the original process will finalize the object. See: https://github.com/lestrrat/ZeroMQ-Perl/issues/42

In some experiments this works mostly but causes something to hang sporadically. Perhaps if the child exits prior to the parent the child is still waiting for the parent to finalize the socket and context... I don't know and ran out of time to investigate.

chuckremes commented 11 years ago

Can't merge due to travis-ci failures on JRuby. Looks like the version of rspec that travis is using now has some deprecation messages that need repair. See https://travis-ci.org/chuckremes/ffi-rzmq/jobs/9195559

richardkmichael commented 11 years ago

Wow, just had this problem today, just started with 0mq yesterday. Timely fix - brilliant, thanks! @chuckremes Any chance for a release soon? (Using :git for now.)