diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2017-08-25 08:52:28 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2017-08-25 08:52:28 +0000 |
commit | 3d2a81a38bdbbb3624da9c1fef76c9cbfd43c199 (patch) | |
tree | cf183cc6e9e5c369cb2c834c350bc0eb387e524d /test/tsan | |
parent | 3df7fc1705d67ca499eeab1585996f279aa1d125 (diff) |
tsan: don't pass bogus PCs to __tsan_symbolize_external
See the added comment for an explanation.
Reviewed in https://reviews.llvm.org/D37107
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@311768 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/tsan')
-rw-r--r-- | test/tsan/double_race.cc | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/tsan/double_race.cc b/test/tsan/double_race.cc new file mode 100644 index 000000000..76b017428 --- /dev/null +++ b/test/tsan/double_race.cc @@ -0,0 +1,52 @@ +// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t 2>&1 | FileCheck %s +#include "test.h" +#include <memory.h> + +// A reproducer for a known issue. +// See reference to double_race.cc in tsan_rtl_report.cc for an explanation. + +char buf[16]; +volatile int nreport; + +void __sanitizer_report_error_summary(const char *summary) { + nreport++; +} + +const int kEventPCBits = 61; + +extern "C" bool __tsan_symbolize_external(unsigned long pc, char *func_buf, + unsigned long func_siz, + char *file_buf, + unsigned long file_siz, int *line, + int *col) { + if (pc >> kEventPCBits) { + printf("bad PC passed to __tsan_symbolize_external: %lx\n", pc); + _exit(1); + } + return true; +} + +void *Thread(void *arg) { + barrier_wait(&barrier); + memset(buf, 2, sizeof(buf)); + return 0; +} + +int main() { + barrier_init(&barrier, 2); + pthread_t t; + pthread_create(&t, 0, Thread, 0); + memset(buf, 1, sizeof(buf)); + barrier_wait(&barrier); + pthread_join(t, 0); + return 0; +} + +// CHECK: WARNING: ThreadSanitizer: data race +// CHECK: Write of size 8 at {{.*}} by thread T1: +// CHECK: #0 memset +// CHECK: #1 Thread +// CHECK-NOT: bad PC passed to __tsan_symbolize_external +// CHECK: WARNING: ThreadSanitizer: data race +// CHECK: Write of size 8 at {{.*}} by thread T1: +// CHECK: #0 Thread |