1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
4 // Ensure that we can restore a stack of a finished thread.
8 void __attribute__((noinline
)) foobar(int *p
) {
12 void *Thread1(void *x
) {
14 barrier_wait(&barrier
);
18 void *Thread2(void *x
) {
19 barrier_wait(&barrier
);
20 sleep(1); // let the thread finish and exit
26 barrier_init(&barrier
, 2);
28 pthread_create(&t
[0], NULL
, Thread1
, NULL
);
29 pthread_create(&t
[1], NULL
, Thread2
, NULL
);
30 pthread_join(t
[0], NULL
);
31 pthread_join(t
[1], NULL
);
35 // CHECK: WARNING: ThreadSanitizer: data race
36 // CHECK: Write of size 4 at {{.*}} by thread T2:
37 // CHECK: Previous write of size 4 at {{.*}} by thread T1:
40 // CHECK: Thread T1 (tid={{.*}}, finished) created by main thread at:
41 // CHECK: #0 pthread_create