We're updating the issue view to help you get more done. 

crash closing a socket after zmq_msg_send returns EAGAIN

Description

I have a program that sends messages on a ZMQ_DEALER socket with ZMQ_DONTWAIT. If I get back EAGAIN (perhaps because the other end is responding slowly or has gone away) I call zmq_close to close the socket and then re-establish the connection (possibly to a new server) with a new socket. ZMQ_LINGER is set to 0.

I'm occasionally seeing crashes in libzmq that look like:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 #0 0x00007f8929287425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 #1 0x00007f892928ab8b in __GI_abort () at abort.c:91 #2 0x00007f892893bb05 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #3 0x00007f8928939c76 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #4 0x00007f8928939ca3 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #5 0x00007f892893a77f in __cxa_pure_virtual () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #6 0x00007f8929649db1 in zmq::v1_encoder_t::message_ready (this=0x7f8918000b90) at v1_encoder.cpp:66 #7 0x00007f892964a2a4 in zmq::encoder_base_t<zmq::v1_encoder_t>::get_data (this=0x7f8918000b90, data_=0x7f8918000928, size_=0x7f8918000930, offset_=0x0) at encoder.hpp:93 #8 0x00007f892963fb42 in zmq::stream_engine_t::out_event (this=0x7f89180008e0) at stream_engine.cpp:261 #9 0x00007f8929627d1a in zmq::epoll_t::loop (this=0x8eace0) at epoll.cpp:158 #10 0x00007f8929644996 in thread_routine (arg_=0x8ead50) at thread.cpp:83 #11 0x00007f8928be6e9a in start_thread (arg=0x7f89271b9700) at pthread_create.c:308 #12 0x00007f89293453fd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112 #13 0x0000000000000000 in ?? ()

I've attached a program, zmqtest.c, that reproduces this. Compile it with -lzmq and run it, it should crash after a minute or so (at least it does for me).

Environment

Ubuntu 12.04 LTS, Virtualbox VM (64-bit).

Status

Assignee

Unassigned

Reporter

Andy Tucker

Components

Fix versions

Affects versions

3.2.4
4.0.1
4.0.2

Priority

Major