[zeromq-dev] race condition in libzmq on zmq_errno()

Martin Lucina mato at kotelna.sk
Fri Oct 14 23:39:12 CEST 2011


cremes.devlist at mac.com said:
> I think a race condition inherent to the setup of one errno per context makes sharing a single context amongst several threads, each with their own socket, very problematic.

errno uses thread-local storage on all modern systems. i.e. the variable is
"magic" in the sense that to you as a developer it looks like an ordinary
global but in fact each OS thread has its own instance.

> Am I crazy, did I find a bug, or what?

Things to check:

1) are you building your C code with -D_REENTRANT and/or -pthread? If not,
your C library may be giving you the old non-TLS global errno.

2) are you correctly including <errno.h>? this may also have an impact.

hth,

-mato



More information about the zeromq-dev mailing list