[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 05:22:23 CET 2012


On Tue, Nov 27, 2012 at 10:23 PM, Kah-Chan Low <kahchanlow at yahoo.com> wrote:

> 1. I don't understand the error message above: how does accessing the value
> of variable n have anything to do with the internals of ZMQ?

It doesn't, as far as I can see.

> 2. Is it possible for the compiler to rearrange the machine instructions
> such that the assignment of value of n (i.e. *n=4; *n += 2;) occurs after
> the message has been sent and received on the other thread?  In this case,
> is it possible for the program to output any value other than '6' for 'n'?

That's very doubtful. However are you not declaring n on the stack?
Meaning, it will not be valid when the send actually happens.

-Pieter



More information about the zeromq-dev mailing list