1 | // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s |
---|---|
2 | #include "test.h" |
3 | |
4 | int x; |
5 | |
6 | void *Thread(void *a) { |
7 | barrier_wait(barrier: &barrier); |
8 | x = 1; |
9 | return 0; |
10 | } |
11 | |
12 | int main() { |
13 | barrier_init(barrier: &barrier, count: 2); |
14 | print_address("addr2=", 1, &x); |
15 | pthread_t t; |
16 | pthread_create(newthread: &t, attr: 0, start_routine: Thread, arg: 0); |
17 | x = 0; |
18 | barrier_wait(barrier: &barrier); |
19 | pthread_join(th: t, thread_return: 0); |
20 | } |
21 | |
22 | // CHECK: addr2=[[ADDR2:0x[0-9,a-f]+]] |
23 | // CHECK: WARNING: ThreadSanitizer: data race |
24 | // CHECK: Location is global 'x' {{(of size 4 )?}}at [[ADDR2]] ({{.*}}+0x{{[0-9,a-f]+}}) |
25 | |
26 |