1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
7 void *Thread1(void *p
) {
12 void *Thread2(void *p
) {
17 __attribute__((noinline
)) void *alloc() {
21 void *AllocThread(void* arg
) {
28 pthread_create(&t
[0], 0, AllocThread
, 0);
29 pthread_join(t
[0], &p
);
30 print_address("addr=", 1, p
);
31 pthread_create(&t
[0], 0, Thread1
, (char*)p
+ 16);
32 pthread_create(&t
[1], 0, Thread2
, (char*)p
+ 16);
33 pthread_join(t
[0], 0);
34 pthread_join(t
[1], 0);
38 // CHECK: addr=[[ADDR:0x[0-9,a-f]+]]
39 // CHECK: WARNING: ThreadSanitizer: data race
41 // CHECK: Location is heap block of size 99 at [[ADDR]] allocated by thread T1:
43 // CHECK: #{{1|2}} alloc
44 // CHECK: #{{2|3}} AllocThread
46 // CHECK: Thread T1 (tid={{.*}}, finished) created by main thread at:
47 // CHECK: #0 pthread_create