[zeromq-dev] [PATCH] Message atomicity problem in PUB fixed (issue 191)

Pieter Hintjens ph at imatix.com
Wed Apr 27 19:23:31 CEST 2011


On Tue, Apr 26, 2011 at 7:50 PM, Pieter Hintjens <ph at imatix.com> wrote:

So, two or three problems here.

1. the patch is not stable. I've applied it to libzmq master, and the
publisher crashes with this back trace:

Program terminated with signal 11, Segmentation fault.
#0  0x00007f262dbd2468 in zmq::writer_t::check_write (this=0x0,
msg_=0x7fff811835d0) at pipe.cpp:190
190	    if (unlikely (!active))
(gdb) bt
#0  0x00007f262dbd2468 in zmq::writer_t::check_write (this=0x0,
msg_=0x7fff811835d0) at pipe.cpp:190
#1  0x00007f262dbd24d1 in zmq::writer_t::write (this=0x0,
msg_=0x7fff811835d0) at pipe.cpp:203
#2  0x00007f262dbc3478 in zmq::dist_t::write (this=0x119ea48,
pipe_=0x0, msg_=0x7fff811835d0) at dist.cpp:160
#3  0x00007f262dbc33ac in zmq::dist_t::distribute (this=0x119ea48,
msg_=0x7fff811835d0, flags_=2) at dist.cpp:141
#4  0x00007f262dbc3250 in zmq::dist_t::send (this=0x119ea48,
msg_=0x7fff811835d0, flags_=2) at dist.cpp:113
#5  0x00007f262dbe4308 in zmq::xpub_t::xsend (this=0x119e8f0,
msg_=0x7fff811835d0, flags_=2) at xpub.cpp:57
#6  0x00007f262dbdf357 in zmq::socket_base_t::send (this=0x119e8f0,
msg_=0x7fff811835d0, flags_=2) at socket_base.cpp:490
#7  0x00007f262dbe9e43 in zmq_sendmsg (s_=0x119e8f0,
msg_=0x7fff811835d0, flags_=2) at zmq.cpp:266
#8  0x0000000000400957 in main () at pub.c:18

Note that it crashes ONLY when there is a subscriber.

2: after backporting the patch to 2.1, it crashes the publisher under
the same conditions (when there is a subscriber). The backtrace is
different but I'd guess it's the same problem:

#0  0x00007fa7eb5be0c0 in zmq::array_item_t::set_array_index
(this=0xec475abd67aa89d8, index_=0) at array.hpp:50
50	            array_index = index_;
(gdb) bt
#0  0x00007fa7eb5be0c0 in zmq::array_item_t::set_array_index
(this=0xec475abd67aa89d8, index_=0) at array.hpp:50
#1  0x00007fa7eb5c4bbf in zmq::array_t<zmq::writer_t>::swap
(this=0x1525a58, index1_=0, index2_=1) at array.hpp:122
#2  0x00007fa7eb5c4447 in zmq::dist_t::activated (this=0x1525a50,
pipe_=0x1526200) at dist.cpp:103
#3  0x00007fa7eb5d39d7 in zmq::writer_t::process_activate_writer
(this=0x1526200, msgs_read_=0) at pipe.cpp:347
#4  0x00007fa7eb5cd6a3 in zmq::object_t::process_command
(this=0x1526200, cmd_=...) at object.cpp:67
#5  0x00007fa7eb5e0d1b in zmq::socket_base_t::process_commands
(this=0x15258f0, block_=false, throttle_=true) at socket_base.cpp:691
#6  0x00007fa7eb5e03bb in zmq::socket_base_t::send (this=0x15258f0,
msg_=0x7fff638e1ad0, flags_=2) at socket_base.cpp:474
#7  0x00007fa7eb5ec110 in zmq_send (s_=0x15258f0, msg_=0x7fff638e1ad0,
flags_=2) at zmq.cpp:375
#8  0x0000000000400957 in main () at pub.c:18

3. Separately from this, I've found that calling zmq_getsockopt before
calling zmq_close results in a segment violation. I've logged this as
https://github.com/zeromq/libzmq/issues/204

Since the patch doesn't exist anywhere on github it's hard to know
where to log these results.

Anyhow, let me know how to continue debugging. (When and IF you
survive the Moscow drinkup^h^h meetup :).

-Pieter



More information about the zeromq-dev mailing list