nng: Deadlock in nng_close(socket)
Describe the bug I’m hitting a deadlock in nng_close(socket) once every ~ 1000 runs of my unit test.
Expected behavior Calling nng_close(socket) should complete in a timely manner
Actual Behavior nng_close(socket) deadlocks
To Reproduce My unit test is very simple. I’m creating a pair0 socket and have a server and client talk through it via ipc:// aio. All works as expected only that very rarely I see a deadlock when tearing-down the unit test. Essentially, my main thread’s callstack looks like:
nni_sock_shutdown(nni_socket * sock) Line 777 C
nni_sock_close(nni_socket * s) Line 804 C
nng_close(nng_socket_s s) Line 46 C
while one of the nng worker threads is stuck doing:
nni_task_wait(nni_task * task) Line 205 C
nni_aio_wait(nng_aio *) Line 315 C
nni_aio_stop(nng_aio * aio) Line 221 C
pipe_destroy(void * arg) Line 77 C
reap_worker(void * unused) Line 58 C
nni_thr_wrap(void * arg) Line 96 C
nni_plat_thr_main(void * arg) Line 330 C
** Environment Details **
- NNG version: 1.5.2
- Operating system and version: Windows 11
- Compiler and language used: MSVC 19.29.30137.0
- Static library
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 36 (20 by maintainers)
Commits related to this issue
- fixes 1543 fixes #1543 by aborting tasks that may have been prepped, but not yet started. — committed to JoshSalitSonos/nng by JoshSalitSonos 2 years ago
- fixes 1543 (#1616) fixes #1543 by aborting tasks that may have been prepped, but not yet started. — committed to nanomsg/nng by JoshSalitSonos a year ago
- fixes #1543 Deadlock in nng_close(socket) This looks like a possible problem that may be windows specific involving the flow for IO completion ports. This simplifies the logic a little bit, and shou... — committed to nanomsg/nng by gdamore 4 months ago
So this change turned out not to work as advertised. It has other problems. I’m working on it now.
Thanks, this gives me some thing to look at. I won’t have time to investigate today, but I will try to dig into it tomorrow.