[Sanitizer] Add rudimentary support for wide-character strings to scanf/printf interc...
[blocksruntime.git] / test / tsan / deep_stack1.cc
blob3048aa8745bb4a165a8ab2d51f0d11f03753bff7
1 // RUN: %clangxx_tsan -O1 %s -o %t -DORDER1 && not %t 2>&1 | FileCheck %s
2 // RUN: %clangxx_tsan -O1 %s -o %t -DORDER2 && not %t 2>&1 | FileCheck %s
3 #include <pthread.h>
4 #include <stdio.h>
5 #include <unistd.h>
7 volatile int X;
8 volatile int N;
9 void (*volatile F)();
11 static void foo() {
12 if (--N == 0)
13 X = 42;
14 else
15 F();
18 void *Thread(void *p) {
19 #ifdef ORDER1
20 sleep(1);
21 #endif
22 F();
23 return 0;
26 int main() {
27 N = 50000;
28 F = foo;
29 pthread_t t;
30 pthread_attr_t a;
31 pthread_attr_init(&a);
32 pthread_attr_setstacksize(&a, N * 256 + (1 << 20));
33 pthread_create(&t, &a, Thread, 0);
34 #ifdef ORDER2
35 sleep(1);
36 #endif
37 X = 43;
38 pthread_join(t, 0);
41 // CHECK: WARNING: ThreadSanitizer: data race
42 // CHECK: #100 foo
43 // We must output suffucuently large stack (at least 100 frames)