[zeromq-dev] zmq::ctx_t::terminate hang

muziwind at sina.com muziwind at sina.com
Fri Aug 8 09:56:46 CEST 2014

hi all
 zmq  I used is zeromq-4.0.4.tar.gz
I met a problem.  I have a server and client.
 After close server I still use client send message, then I close client UI,  the client will hang. I call this ConditionA
gdb show the 
#0  0x0000003e9c2d7e33 in poll () from /lib64/libc.so.6
#1  0x00007ffff6720066 in zmq::signaler_t::wait (this=0x17dd928, timeout_=-1) at signaler.cpp:173
#2  0x00007ffff671117e in zmq::mailbox_t::recv (this=0x17dd8c8, cmd_=0x7fffffffb830, timeout_=-1) at mailbox.cpp:72
#3  0x00007ffff670886e in zmq::ctx_t::terminate (this=0x17dd830) at ctx.cpp:142
#4  0x00007ffff67359a0 in zmq_ctx_term (ctx_=0x17dd830) at zmq.cpp:171
#5  0x00007ffff7bb6f4d in zmq::context_t::close (this=0x1c7ab80) at /home/dev/TigerTeam/PAISetup/PAI/include/zmq/zmq.hpp:304
#6  0x00007ffff7bb6f24 in zmq::context_t::~context_t (this=0x1c7ab80, __in_chrg=<value optimized out>) at /home/dev/TigerTeam/PAISetup/PAI/include/zmq/zmq.hpp:297
#7  0x00007ffff7bb5785 in tiger::MessageCenter::~MessageCenter (this=0x7ffff7de67a0, __in_chrg=<value optimized out>) at MessageCenter.cpp:319
#8  0x0000003e9c235fd2 in exit () from /lib64/libc.so.6
#9  0x0000003e9c21ec64 in __libc_start_main () from /lib64/libc.so.6
#10 0x0000000000405f49 in _start ()
but if I not use client to send  message after close server, then i close client UI, the client can quit normally. I call this ConditionB
And on the client, I use a thread to do send, like this
while(quit ==false)
     while(quit == false)
         poll(items, 1, 1000);
         if (items[0] & ZMQ_POLLIN)

and I found something during debug
 ConditionB on exit,  these breakpoints happen in order.
#0  zmq::object_t::send_reap (this=0x2478d50, socket_=0x2478d50) at object.cpp:303
#1  0x00007ffb78eb6a46 in zmq::socket_base_t::close (this=<value optimized out>) at socket_base.cpp:837
#2  0x00007ffb78ecb7f0 in zmq_close (s_=0x2478d50) at zmq.cpp:264
#3  0x00007ffb7a34d085 in zmq::socket_t::close (this=0x24817c0) at /home/dev/TigerTeam/PAISetup/PAI/include/zmq/zmq.hpp:365
#4  0x00007ffb7a3499e3 in tiger::BroadcastThread::~BroadcastThread (this=0x23e47c0, __in_chrg=<value optimized out>) at MessageCenter.cpp:108

#0  zmq::object_t::send_stop (this=0x2478d50) at object.cpp:176
#1  0x00007ffb78e9e821 in zmq::ctx_t::terminate (this=0x23a3020) at ctx.cpp:134
#2  0x00007ffb78ecb9a0 in zmq_ctx_term (ctx_=0x23a3020) at zmq.cpp:171
#3  0x00007ffb7a34cf4d in zmq::context_t::close (this=0x211df40) at /home/dev/TigerTeam/PAISetup/PAI/include/zmq/zmq.hpp:304
#4  0x00007ffb7a34cf24 in zmq::context_t::~context_t (this=0x211df40, __in_chrg=<value optimized out>) at /home/dev/TigerTeam/PAISetup/PAI/include/zmq/zmq.hpp:297
#5  0x00007ffb7a34b785 in tiger::MessageCenter::~MessageCenter (this=0x7ffb7a57c7a0, __in_chrg=<value optimized out>) at MessageCenter.cpp:319

#0  zmq::object_t::send_stop (this=0x24817e0) at object.cpp:176
#1  0x00007ffb78e9cee1 in zmq::ctx_t::destroy_socket (this=0x23a3020, socket_=0x2478d50) at ctx.cpp:314
#2  0x00007ffb78eb67ee in zmq::socket_base_t::check_destroy (this=0x2478d50) at socket_base.cpp:1028
#3  0x00007ffb78ea3482 in zmq::epoll_t::loop (this=0x244da00) at epoll.cpp:165
#4  0x00007ffb78ec2e3b in thread_routine (arg_=0x244da70) at thread.cpp:81
#5  0x0000003e9ce077e1 in start_thread () from /lib64/libpthread.so.0
#6  0x0000003e9c2e153d in clone () from /lib64/libc.so.6
but ConditionA on exit, only 1 and 2 happen.
does anyone have clues or experiences about this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140808/59bac001/attachment.html>

More information about the zeromq-dev mailing list