By erupter
I know I can’t really ask for a solution, and I normally wouldn’t but this is really escaping my abilities.
Antefacts.
I developed a program using the zeromq messaging library.
I got to a point where the program works and then started going multithreading: moving a message poller outside of the main thread.
This is supported by the library.
So I devised my thread, passed it a pointer to some parameters (including the pointer to the zmq context) and went ahead.
The Problem
The code in the child thread is the same code I had in the parent, save for the facts that functions parameters are stored in a structure that gets passed to the child.
I followed every function in the child and the parameters are correct.
The code does even work (as it should) when run normally, but hangs with an assert when run in debug.
I tried following every function I could, built the library with debug symbols, using gdb from the console…
I got nothing useful.
I still don’t understand why it fails with the debugger attached, and why it runs without.
The culprit code is the following
if ((pgm_error->domain == PGM_ERROR_DOMAIN_SOCKET ||
pgm_error->domain == PGM_ERROR_DOMAIN_IF) && (
pgm_error->code != PGM_ERROR_INVAL &&
pgm_error->code != PGM_ERROR_BADF &&
pgm_error->code != PGM_ERROR_FAULT))
from pgm_socket.cpp:301
And here are a couple gdb outputs
Breakpoint 1, zmq::pgm_socket_t::init (this=0x7ffff0000930,
udp_encapsulation_=true, network_=) at pgm_socket.cpp:301
warning: Source file is more recent than executable.
301 if ((pgm_error->domain == PGM_ERROR_DOMAIN_SOCKET ||
(gdb) stepi
0x00007ffff786488d 301 if ((pgm_error->domain == PGM_ERROR_DOMAIN_SOCKET ||
(gdb)
0x00007ffff786488f 301 if ((pgm_error->domain == PGM_ERROR_DOMAIN_SOCKET ||
(gdb)
0x00007ffff7864891 301 if ((pgm_error->domain == PGM_ERROR_DOMAIN_SOCKET ||
(gdb)
0x00007ffff7864894 301 if ((pgm_error->domain == PGM_ERROR_DOMAIN_SOCKET ||
(gdb)
0x00007ffff7864896 301 if ((pgm_error->domain == PGM_ERROR_DOMAIN_SOCKET ||
(gdb)
0x00007ffff7864899 301 if ((pgm_error->domain == PGM_ERROR_DOMAIN_SOCKET ||
(gdb)
0x00007ffff786489c 301 if ((pgm_error->domain == PGM_ERROR_DOMAIN_SOCKET ||
(gdb)
0x00007ffff786489e 301 if ((pgm_error->domain == PGM_ERROR_DOMAIN_SOCKET ||
(gdb)
0x00007ffff78648a1 301 if ((pgm_error->domain == PGM_ERROR_DOMAIN_SOCKET ||
(gdb)
0x00007ffff78648a3 301 if ((pgm_error->domain == PGM_ERROR_DOMAIN_SOCKET ||
(gdb)
0x00007ffff78648a6 301 if ((pgm_error->domain == PGM_ERROR_DOMAIN_SOCKET ||
(gdb)
376 if (sock != NULL) {
(gdb)
Breakpoint 1, zmq::pgm_socket_t::init (this=0x7ffff0000930,
udp_encapsulation_=true, network_=) at pgm_socket.cpp:301
301 if ((pgm_error->domain == PGM_ERROR_DOMAIN_SOCKET ||
(gdb) step
376 if (sock != NULL) {
(gdb)
377 pgm_close (sock, FALSE);
(gdb)
There is supposedly no way (and no reason) to jump from line 301 to 376, yet it happens.
After that there is a
return -1;
that triggers the assert that kills my code.
And I’m banging my head over this without so much as a hope of understanding what to do.
I can’t really hope for a solution with this, but at least a suggestion as to how to proceed.
My code (if anyone really wanted to check it out) on github is under the project “saettang“.

Add to favorites 