chuckremes/ffi-rzmq — pull request #92 by thinkerbot (2013-07-17 16:22:35+00:00)
Title: Track pid in Context and Socket finalizers

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.