Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zmq_ctx_destroy() hangs with no way to find out why #2330

Closed
mrvn opened this issue Feb 2, 2017 · 8 comments
Closed

zmq_ctx_destroy() hangs with no way to find out why #2330

mrvn opened this issue Feb 2, 2017 · 8 comments

Comments

@mrvn
Copy link
Contributor

mrvn commented Feb 2, 2017

On exit I'm unregistering all sockets from the poller, closing all sockets and finally destroying the context. The last part frequently blocks. I looked at the code over and over and everything seems to be in order and nothing forgotten. I even set LINGER to 0 for sockets.

So how can one find out why zmq_ctx_destroy() blocks? Or how can one destroy the context anyway without blocking?

@bluca
Copy link
Member

bluca commented Feb 7, 2017

What kind of sockets? What transport? Have you tried using GDB to find out where it's blocked?

@mrvn
Copy link
Contributor Author

mrvn commented Feb 13, 2017

ROUTER sockets with tcp, inproc for ZAP and monitor socket on the ROUTER. The hangs started when I added the monitor socket.

gdb isn't helpfull without debug infos and I don't have them here at the moment:

#0 0x00007ffff78e412d in poll () at ../sysdeps/unix/syscall-template.S:81
#1 0x00007ffff62d447a in ?? () from /usr/lib/x86_64-linux-gnu/libzmq.so.4
#2 0x00007ffff62bfb90 in ?? () from /usr/lib/x86_64-linux-gnu/libzmq.so.4
#3 0x00007ffff62b0c1c in ?? () from /usr/lib/x86_64-linux-gnu/libzmq.so.4
#4 0x00007ffff550ac4b in ?? ()
from /usr/lib/python3/dist-packages/zmq/backend/cython/context.cpython-34m-x86_64-linux-gnu.so
#5 0x00007ffff550b137 in ?? ()
from /usr/lib/python3/dist-packages/zmq/backend/cython/context.cpython-34m-x86_64-linux-gnu.so

My thoughts now are that closing the sockets generates some message on the monitoring socket that it waits to deliver. But nobody every fetches it.

@bluca
Copy link
Member

bluca commented Feb 13, 2017

libzmq.so.4 - that is quite old, version 4.0.x I think?

This looks like a race condition with the monitor socket that was fixed a while ago, can you try with the latest version?

@mrvn
Copy link
Contributor Author

mrvn commented Feb 21, 2017

Will do so after this release. Don't want to chance introducing new bugs by changing the lib now.

@bjovke
Copy link
Contributor

bjovke commented May 16, 2017

@mrvn Any news about this? Did you try the newer version?

@lab313ru
Copy link

This problem happens if you didn't close sockets that were opened at this context.

@stale
Copy link

stale bot commented Nov 4, 2018

This issue has been automatically marked as stale because it has not had activity for 365 days. It will be closed if no further activity occurs within 56 days. Thank you for your contributions.

@stale stale bot added the stale label Nov 4, 2018
@stale stale bot closed this as completed Dec 31, 2018
@maixuanhan
Copy link

This problem happens if you didn't close sockets that were opened at this context.

And maybe because some data lingering. Setting ZMQ_LINGER may help

Read the description of this for more detail
https://linux.die.net/man/3/zmq_ctx_destroy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants