|
From: Erik S. <san...@vi...> - 2008-03-13 13:37:43
|
Hi, I'm working with a large project, where Helgrind gives a couple of false positives. I've been communicating with Julian for a while, but thought it's better to talk to this list. In my program, each thread owns some data which it manipulates. When an asynchronous event (such as user input) happens, all threads halt as soon as they can, and when all threads have halted, one of them handles the event. The event is executed by a single thread, so it may safely manipulate data owned by any thread. Helgrind complains about a data race, since it doesn't understand that some threads are sleeping. The attached file is a minimized version of my problem. Helgrind gives the following output: ==2518== Helgrind, a thread error detector. ==2518== Copyright (C) 2007-2008, and GNU GPL'd, by OpenWorks LLP et al. ==2518== Using LibVEX rev exported, a library for dynamic binary translation. ==2518== Copyright (C) 2004-2008, and GNU GPL'd, by OpenWorks LLP. ==2518== Using valgrind-3.4.0.SVN, a dynamic binary instrumentation framework. ==2518== Copyright (C) 2000-2008, and GNU GPL'd, by Julian Seward et al. ==2518== For more details, rerun with: -v ==2518== ==2518== Thread #2 was created ==2518== at 0x511C91E: clone (in /lib/libc-2.7.so) ==2518== by 0x4E2FA11: pthread_create@@GLIBC_2.2.5 (in /lib/libpthread-2.7.so) ==2518== by 0x4C26928: pthread_create@* (hg_intercepts.c:213) ==2518== by 0x4007AD: main (bug.c:52) ==2518== ==2518== Thread #3 was created ==2518== at 0x511C91E: clone (in /lib/libc-2.7.so) ==2518== by 0x4E2FA11: pthread_create@@GLIBC_2.2.5 (in /lib/libpthread-2.7.so) ==2518== by 0x4C26928: pthread_create@* (hg_intercepts.c:213) ==2518== by 0x4007C6: main (bug.c:53) ==2518== ==2518== T3: Possible data race during write of size 4 at 0x600D20 ==2518== at 0x40071E: threadB (bug.c:28) ==2518== by 0x4C26A43: mythread_wrapper (hg_intercepts.c:193) ==2518== by 0x4E2F3F6: start_thread (in /lib/libpthread-2.7.so) ==2518== by 0x511C95C: clone (in /lib/libc-2.7.so) ==2518== old state: e000002000000000 W #SS=1 #LS=0 S2/T2 ==2518== new state: c000001000000000 W #SS=2 #LS=0 S2/T2 S4/T3 ==2518== Location 0x600d20 is 0 bytes inside local var "data" ==2518== declared at bug.c:9, in frame #0 of thread 3 ==2518== ==2518== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 9 from 3) Greetings, Erik |