diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2017-08-25 15:18:48 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2017-08-25 15:18:48 +0000 |
commit | 809c05a0ca406262e02bf5ec2dd78ae1f44009da (patch) | |
tree | 593820ac07b26a91f29553abb73f2bc9984643ca /test/tsan/Linux | |
parent | 3d2a81a38bdbbb3624da9c1fef76c9cbfd43c199 (diff) |
tsan: fix darwin build
Runtime hooks do not seem to work on darwin. The test failed on builder:
http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/34882/consoleFull#7286766538254eaf0-7326-4999-85b0-388101f2d404
Move the test to Linux dir.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@311776 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/tsan/Linux')
-rw-r--r-- | test/tsan/Linux/double_race.cc | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/tsan/Linux/double_race.cc b/test/tsan/Linux/double_race.cc new file mode 100644 index 000000000..2b4af35a2 --- /dev/null +++ b/test/tsan/Linux/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 |