|
From: Bart V. A. <bva...@ac...> - 2010-03-09 11:09:03
|
On Wed, Jan 27, 2010 at 1:33 PM, Konstantin Serebryany <kon...@gm...> wrote: > > On Wed, Jan 27, 2010 at 3:41 PM, Julian Seward <js...@ac...> wrote: >> >> Konstantin, >> >> I'm trying to annotate a user-implemented barrier, using >> >> http://code.google.com/p/google-perftools/source/browse/trunk/src/base/dynamic_annotations.h >> specifically ANNOTATE_HAPPENS_BEFORE and ANNOTATE_HAPPENS_AFTER >> >> like this >> >> void barrier_wait ( barrier* b ) >> { >> ANNOTATE_HAPPENS_BEFORE(b); >> // the barrier implementation >> ANNOTATE_HAPPENS_AFTER(b); >> } > > this is exactly how I handle barrier. (replying to an e-mail of about one month ago) The above algorithm for annotating barriers is wrong. This can be illustrated easily via the test program drd/tests/pth_barrier in the Valgrind tree: DRD and Helgrind always report 32 races for this program when started with the arguments "2 32 1" (two threads, 32 iterations, silent output) while TSan reports zero races with silent output and 17 races with verbose output (arguments "2 32 0"). The results reported by DRD and Helgrind are correct, the results reported by TSan not. $ ../tsan/drt/tsan.sh drd/tests/pth_barrier 2 32 1 Extracting ThreadSanitizer to /tmp/valgrind.LbA93c ==1676== ThreadSanitizer, a data race detector ==1676== Copyright (C) 2008-2009, and GNU GPL'd, by Google Inc. ==1676== Using Valgrind-3.6.0.SVN and LibVEX; rerun with -h for copyright info ==1676== Command: drd/tests/pth_barrier 2 32 1 ==1676== ==1676== ThreadSanitizerValgrind r1819: pure-happens-before=yes fast-mode=no ignore-in-dtor=no ==1676== INFO: Allocating 939,524,096 (112 * 8,388,608) bytes for Segments. ==1676== ==1676== ThreadSanitizer summary: reported 0 warning(s) (0 race(s)) Sorry that I didn't have a closer look at the above algorithm earlier. Bart. |