llvm-project
40 строк · 984.0 Байт
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
9typedef unsigned long uptr;10extern "C" void __tsan_read_range_pc(uptr addr, uptr size, uptr pc);11extern "C" void __tsan_write_range_pc(uptr addr, uptr size, uptr pc);12
13void foobar() {14}
15
16void barbaz() {17}
18
19void *Thread(void *p) {20barrier_wait(&barrier);21__tsan_read_range_pc((uptr)p, 32, (uptr)foobar + kPCInc);22return 0;23}
24
25int main() {26barrier_init(&barrier, 2);27int a[128];28pthread_t th;29pthread_create(&th, 0, Thread, (void*)a);30__tsan_write_range_pc((uptr)(a+2), 32, (uptr)barbaz + kPCInc);31barrier_wait(&barrier);32pthread_join(th, 0);33fprintf(stderr, "DONE\n");34return 0;35}
36
37// CHECK: WARNING: ThreadSanitizer: data race
38// CHECK: #0 foobar
39// CHECK: #0 barbaz
40// CHECK: DONE
41