| 1 | // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s |
| 2 | // This test fails on powerpc64 big endian. |
| 3 | // The Tsan report is returning wrong information about |
| 4 | // the location of the race. |
| 5 | // XFAIL: target=powerpc64-unknown-linux-gnu{{.*}} |
| 6 | |
| 7 | #include "test.h" |
| 8 | |
| 9 | typedef unsigned long uptr; |
| 10 | extern "C" void __tsan_read_range_pc(uptr addr, uptr size, uptr pc); |
| 11 | extern "C" void __tsan_write_range_pc(uptr addr, uptr size, uptr pc); |
| 12 | |
| 13 | void foobar() { |
| 14 | } |
| 15 | |
| 16 | void barbaz() { |
| 17 | } |
| 18 | |
| 19 | void *Thread(void *p) { |
| 20 | barrier_wait(barrier: &barrier); |
| 21 | __tsan_read_range_pc(addr: (uptr)p, size: 32, pc: (uptr)foobar + kPCInc); |
| 22 | return 0; |
| 23 | } |
| 24 | |
| 25 | int main() { |
| 26 | barrier_init(barrier: &barrier, count: 2); |
| 27 | int a[128]; |
| 28 | pthread_t th; |
| 29 | pthread_create(newthread: &th, attr: 0, start_routine: Thread, arg: (void*)a); |
| 30 | __tsan_write_range_pc(addr: (uptr)(a+2), size: 32, pc: (uptr)barbaz + kPCInc); |
| 31 | barrier_wait(barrier: &barrier); |
| 32 | pthread_join(th: th, thread_return: 0); |
| 33 | fprintf(stderr, format: "DONE\n" ); |
| 34 | return 0; |
| 35 | } |
| 36 | |
| 37 | // CHECK: WARNING: ThreadSanitizer: data race |
| 38 | // CHECK: #0 foobar |
| 39 | // CHECK: #0 barbaz |
| 40 | // CHECK: DONE |
| 41 | |