Tom -- I ran into similar failure modes ( https://github.com/nanomsg/nanomsg/issues/269) and have developed a fix that has so far solved this issue in practice ( https://github.com/wirebirdlabs/ftw-nanomsg/commit/bb5d37c70800aa620391c80a30b07dcc83501e26). Perhaps, review and even try this fix, and report back findings? Best regards, Jack R. Dunaway | Wirebird Labs LLC On Mon, Oct 6, 2014 at 8:15 AM, Tom Quarendon <tom.quarendon@xxxxxxxxxxxxx> wrote: > What might the above assertion failure on attempting to close a socket > indicate? > > It doesn’t happen all of the time, so it’s clearly some issue where I’m > not closing things down properly. > > > > I’m working with inproc and an NN_PUSH NN_PULL pair of sockets. > Unfortunately I can’t reproduce this if I try and reduce my problem down to > a few lines of code, but my application logic is something like this: > > Main thread kicks off background thread. > > Background thread creates an NN_PULL socket and calls bind. It then goes > into a loop reading commands from the socket, which it then executes. On > receiving a special “shutdown” command, it exits its loop and then calls > nn_close. It is this nn_close that causes the assertion failure. If I > remove this close I get no issues. > > > > Main thread then opens a NN_PUSH socket and calls connect. It then writes > a list of commands it wants executing. It then closes the socket. > > To terminate it then creates another NN_PUSH socket, calls connect, and > then writes the special shutdown signal, and the calls nn_close(). > > > > The only timing issue I can think of is that the main thread sends the > shutdown signal, and before it then gets a change to close its socket, the > background thread processes the message and closes its end. Because it did > the bind it somehow owns some state that is released and when the main > thread then does its close, the assertion happens. However I’ve put in some > Sleeps to try and force this sequence, but it doesn’t make the failure > happen all of the time. > > > > At the time that the assertion occurs, src==0 (so this is false) and > type==33987 (so also false). > > > > I’m hoping someone might have some ideas as to what the problem is. > > Thanks. > > > > > > > > >