[zeromq-dev] Assertion failure in mailbox.cpp

Matt Connolly matt.connolly at me.com
Mon May 19 15:34:39 CEST 2014


On 19 May 2014, at 11:26 pm, Jon Gjengset <jon at thesquareplanet.com> wrote:

>> Nevertheless, my application will sometimes (although not always),
>> crash with an assertion failure at mailbox.cpp:82:
> 
> It might be worth noting that I have only ever observed the crash during
> the shutdown procedure after the second stage has closed its outgoing
> socket.

During my work on the ruby gem bindings for czmq, I saw that it was easy to cause assertions if one thread tried to close a socket while another thread was terminating the context.

Socket closing appears to also be somewhat asynchronous, in that the background i/o threads need to take part in the socket closing process. I can see in your code example that you are joining the threads before terminating the context, so I wonder if there is still some thread safety issue with closing different sockets simultaneously on other threads.

In the rbczmq gem, I decided to put a mutex around any calls to close a socket so only one could happen at a time. This incurs a performance hit for applications opening and closing many sockets - but I understand that is not a recommended usage pattern.

Best of luck,
Mat.







More information about the zeromq-dev mailing list