|
From: Dave G. <go...@mc...> - 2010-07-08 15:56:15
|
On Jul 8, 2010, at 5:27 AM CDT, Bart Van Assche wrote: > On Thu, Jul 8, 2010 at 12:20 AM, Dave Goodell <go...@mc...> wrote: [...] >> >> Q1: I know it's potentially error prone in terms of usage and implementation, but I'm attempting something that is basically sane, right? >> >> Q2: Is there a way to correctly annotate the store/load pair, ideally across all three tools? Or for helgrind am I stuck with suppressions? > > Please check whether the issue described in the following bug report > affects your test program: > https://bugs.kde.org/show_bug.cgi?id=243935. I can reproduce #243935 on my machine (@r11206). I did not realize that the DRD and Helgrind HB/HA annotations were supposed to be binary compatible, which seems to be what this ticket is saying. I only assumed source level compatibility and rebuilt with different headers between different tool runs. At the bottom of this email is the result of a run of DRD with USE_DRD defined instead of USE_HELGRIND. It also warns about the "flag" variable, so I don't think I'm being hit by #243935. The HB/HA annotations do work for shared_data, but not for the flag variable. This makes sense to me, because I'm only indicating the HA point after the "racy" read. However I don't understand the correct way to annotate this without just telling the tool to ignore races on this memory location. I feel like what I need is an "atomic load" that will be treated the same way as a more complicated atomic operation like CAS or fetch_and_add. The various tools don't seem to have a problem with those operations (undef'ing USE_PLAIN_STORE in the test code makes DRD happy again). -Dave ------8<------ % valgrind --tool=drd --read-var-info=yes -q ./a.out ==32285== Thread 2: ==32285== Conflicting store by thread 2 at 0x00600f78 size 4 ==32285== at 0x40090E: completer /sandbox/goodell/scratch/flag-hb/foo.c:34 ==32285== by 0x4C29CFF: vgDrd_thread_wrapper /sandbox/goodell/drt/third_party/valgrind/drd/drd_pthread_intercepts.c:272 ==32285== by 0x4E3B3F6: start_thread (in /lib/libpthread-2.7.so) ==32285== by 0x5128B4C: clone (in /lib/libc-2.7.so) ==32285== Location 0x600f78 is 0 bytes inside global var "flag" ==32285== declared at foo.c:20 ==32285== Other segment start (thread 1) ==32285== at 0x4C308E4: pthread_create@* /sandbox/goodell/drt/third_party/valgrind/drd/drd_pthread_intercepts.c:431 ==32285== by 0x4009A6: main /sandbox/goodell/scratch/flag-hb/foo.c:45 ==32285== Other segment end (thread 1) ==32285== at 0x4009C9: main /sandbox/goodell/scratch/flag-hb/foo.c:49 ==32285== ==32285== Thread 1: ==32285== Conflicting load by thread 1 at 0x00600f78 size 4 ==32285== at 0x4009C9: main /sandbox/goodell/scratch/flag-hb/foo.c:49 ==32285== Location 0x600f78 is 0 bytes inside global var "flag" ==32285== declared at foo.c:20 ==32285== Other segment start (thread 2) ==32285== (thread finished, call stack no longer available) ==32285== Other segment end (thread 2) ==32285== (thread finished, call stack no longer available) ==32285== shared_data=0xdeadbeef ------8<------ |