|
From: Konstantin S. <kon...@gm...> - 2009-11-05 15:38:45
|
On Thu, Nov 5, 2009 at 11:15 AM, Julian Seward <js...@ac...> wrote: > On Thursday 05 November 2009, Konstantin Serebryany wrote: > > > I think this section of helgrind docs is generally out of date (Julian, > > please confirm). > > Helgrind 3.5 is a pure happens-before detector and thus handles this case > > correctly. > > Same for DRD. > > Unfortunately I think the docs are correct, and neither Helgrind nor DRD > can handle this properly. Hm. Why??? cond var should only be used between mutex lock/unlock and those create h-b arcs... Here is the test: http://code.google.com/p/data-race-test/source/browse/trunk/unittest/racecheck_unittest.cc#520 Helgrind, DRD and ThreadSanitizer (in pure happens-before mode) are silent here. ThreadSanitizer in the hybrid mode barks. void Waker() { GLOB = 1; MU.Lock(); COND = 1; CV.Signal(); MU.Unlock(); } void Waiter() { usleep(100000); // Make sure the signaller gets first. MU.Lock(); while(COND != 1) CV.Wait(&MU); MU.Unlock(); GLOB = 2; } > The basic problem is that there can be a h-b > dependency which arises from the loop and values in memory, not from the > mx or cv, so the dependency is "invisible". > > I believe Laszlo's comments are valid and correct, and an interesting > solution. I'd have to stare at it more it be convinced it's correct, > but it looks plausible. > > Laszlo, can you explain the background to this a bit? How did you > come to be looking at this problem? Does your solution help? > > J > |