1 // RUN: %clangxx_tsan -O1 %s -o %t -DORDER1 && %deflake %run %t | FileCheck %s
2 // RUN: %clangxx_tsan -O1 %s -o %t -DORDER2 && %deflake %run %t | FileCheck %s
16 void *Thread(void *p
) {
18 barrier_wait(&barrier
);
22 barrier_wait(&barrier
);
27 static size_t RoundUp(size_t n
, size_t to
) {
28 return ((n
+ to
- 1) / to
) * to
;
32 barrier_init(&barrier
, 2);
37 pthread_attr_init(&a
);
38 size_t stack_size
= N
* 256 + (1 << 20);
39 stack_size
= RoundUp(stack_size
, 0x10000); // round the stack size to 64k
40 int ret
= pthread_attr_setstacksize(&a
, stack_size
);
42 pthread_create(&t
, &a
, Thread
, 0);
44 barrier_wait(&barrier
);
48 barrier_wait(&barrier
);
54 // CHECK: WARNING: ThreadSanitizer: data race
56 // We must output sufficiently large stack (at least 100 frames)