[zeromq-dev] inproc: passing an object pointer between threads causing datarace?? (3.2.2 stable release)

Pieter Hintjens ph at imatix.com
Thu Nov 29 15:50:52 CET 2012


On Thu, Nov 29, 2012 at 3:25 PM, Kah-Chan Low <kahchanlow at yahoo.com> wrote:

> Doesn't zmq_send(), which is called by socket_t::send(), make a copy of
> whatever message that is passed in before returning?

It takes the buffer you provide and queues that address for sending.
It's confusing you because you think the pointer is passed by value
whereas you are passing its address, precisely as if it was a buffer.
This is a fairly common error for beginners, to pass a buffer that is
deallocated before the send completes.

(I've not tried to reproduce it but this is what I believe is happening.)

Try just sending one pointer (not in a loop).

-Piieter



More information about the zeromq-dev mailing list