Skip to content

Assertion failures: stream_engine.cpp:94 and Invalid argument (ip.cpp:136) libzmq4x on OSX #1442

Closed
@ukeller

Description

@ukeller

Hey
I'm getting hit sporadically by this assertion on libzmq4x on OSX.
Looking at the code there is the following:

int set = 1;
rc = setsockopt (s, SOL_SOCKET, SO_NOSIGPIPE, &set, sizeof (int));
errno_assert (rc == 0);

It seems that this can fail on OSX if the remote end has closed/reset the socket as described here:
http://lists.apple.com/archives/macnetworkprog/2008/Jan/msg00084.html

To illustrate this for OSX I created a small test program (single thread no zmq):
https://gist.github.com/ukeller/33734f95b00e36c0e404
It creates a server socket and a connector socket. The connector socket connects to the server socket over network. The connector socket is then closed after accept returns "on the server side" and before setsockopt is called "on the server side". Effectively simulating a "client" that disconnects immediately after connecting and triggering the assertion.

To test save the GIST under socket.cc and compile with:

clang++ -std=c++1y socket.cc  -stdlib=libc++ 
 ./a.out nolinger stream_engine.cpp  #PASSES
 ./a.out linger0 stream_engine.cpp  #FAILS
 ./a.out nolinger ip.cpp  #PASSES
 ./a.out linger0 ip.cpp  #FAILS

Not sure what the fix is here. I'm tempted to say that the assertion should be disabled at least for Apple platforms. Any opinions?
Regards,
Urs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions