[llvm-commits] patch: add tsan annotations to ManagedStatic

Nick Lewycky nlewycky at google.com
Thu Nov 10 16:59:44 PST 2011


The attached patch silences false-positives found by tsan, a valgrind-based
thread sanitizer. It's correct that there are races, but they're benign,
hence the need to add annotations to suppress the reports. Here's what one
report looks like on a trivial testcase:

  WARNING: Possible data race during read of size 8 at 0x404130: {{{
      T2 (L{}):
       #0  llvm::ManagedStatic::operator*
/home/nlewycky/llvm/include/llvm/Support/ManagedStatic.h:65
       #1  test1::helper /home/nlewycky/llvm-thread-test.cc:8
     Concurrent write(s) happened at (OR AFTER) these points:
      T1 (L{}):
       #0  llvm::ManagedStaticBase::RegisterManagedStatic
/home/nlewycky/llvm/lib/Support/ManagedStatic.cpp:43
       #1  llvm::ManagedStatic::operator*
home/nlewycky/llvm/include/llvm/Support/ManagedStatic.h:67
       #2  test1::helper /home/nlewycky/llvm-thread-test.cc:8
     Address 0x404130 is 0 bytes inside data symbol "_ZN5test12msE"
      Race verifier data: 0x400C28,0x400ECB
   }}}

The annotations are calls to no-op functions, and compiled out entirely
when either debug mode is off or ENABLE_THREADS is zero.

Please review!

Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111110/268eb593/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tsan-managedstatic.patch
Type: text/x-patch
Size: 6703 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111110/268eb593/attachment.bin>


More information about the llvm-commits mailing list