tsan: add new mutex annotations
authorDmitry Vyukov <dvyukov@google.com>
Sun, 26 Mar 2017 15:27:04 +0000 (15:27 +0000)
committerDmitry Vyukov <dvyukov@google.com>
Sun, 26 Mar 2017 15:27:04 +0000 (15:27 +0000)
commit8096a8c86ff03213f43ed3cda182ae3005c3cdf7
tree942edbedf347334ae45d10e20c66b645c2e606f4
parentde27a6dcfa565aeaceb481118fbe47bf3fb31b91
tsan: add new mutex annotations

There are several problems with the current annotations (AnnotateRWLockCreate and friends):
- they don't fully support deadlock detection (we need a hook _before_ mutex lock)
- they don't support insertion of random artificial delays to perturb execution (again we need a hook _before_ mutex lock)
- they don't support setting extended mutex attributes like read/write reentrancy (only "linker init" was bolted on)
- they don't support setting mutex attributes if a mutex don't have a "constructor" (e.g. static, Java, Go mutexes)
- they don't ignore synchronization inside of lock/unlock operations which leads to slowdown and false negatives
The new annotations solve of the above problems. See tsan_interface.h for the interface specification and comments.

Reviewed in https://reviews.llvm.org/D31093

llvm-svn: 298809
22 files changed:
compiler-rt/include/CMakeLists.txt
compiler-rt/include/sanitizer/tsan_interface.h [new file with mode: 0644]
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
compiler-rt/lib/tsan/go/tsan_go.cc
compiler-rt/lib/tsan/rtl/tsan.syms.extra
compiler-rt/lib/tsan/rtl/tsan_flags.cc
compiler-rt/lib/tsan/rtl/tsan_flags.h
compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
compiler-rt/lib/tsan/rtl/tsan_interface_ann.cc
compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc
compiler-rt/lib/tsan/rtl/tsan_interface_java.cc
compiler-rt/lib/tsan/rtl/tsan_rtl.cc
compiler-rt/lib/tsan/rtl/tsan_rtl.h
compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cc
compiler-rt/lib/tsan/rtl/tsan_stat.cc
compiler-rt/lib/tsan/rtl/tsan_stat.h
compiler-rt/lib/tsan/rtl/tsan_sync.cc
compiler-rt/lib/tsan/rtl/tsan_sync.h
compiler-rt/test/tsan/custom_mutex.h [new file with mode: 0644]
compiler-rt/test/tsan/custom_mutex0.cc [new file with mode: 0644]
compiler-rt/test/tsan/custom_mutex1.cc [new file with mode: 0644]
compiler-rt/test/tsan/custom_mutex2.cc [new file with mode: 0644]