Created attachment 81219 [details] sample program In the program there are two threads synchronized by barriers. There are two buffers: one is filled by a thread, the other buffer is read by the main thread. Switching of buffers happens on the barrier. Helgrind reports errors for the reading thread, however the barrier is there to ensure that reading happens after writing. Imho these are false positives. Compile and run the attached program: g++ -lpthread barrier.cc -o barrier valgrind --tool=helgrind ./barrier Helgrind output: ==17634== Thread #1 is the program's root thread ==17634== ==17634== Possible data race during read of size 1 at 0x5c55080 by thread #1 ==17634== at 0x4009F0: read_buffer(int) (in barrier) ==17634== by 0x400B6D: main (in barrier) ==17634== Address 0x5c55080 is 0 bytes inside a block of size 1048576 alloc'd ==17634== at 0x4C28D47: operator new[](unsigned long) (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so) ==17634== by 0x400AB7: main (in barrier) ==17634== gcc version: 4.6.2 valgrind version: 3.6.1
Program flow is like: Create thread Main: nothing ... Thread: fill buffer 1 <-- barrier --> Main: read buffer 1 ... Thread: Fill buffer 0 <-- barrier --> etc
Appears to be fixed: g++ 4.8.5 valgrind 3.12.0