1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t 2>&1 | FileCheck %s
7 void *Thread(void *p
) {
8 __tsan_java_mutex_lock(lockaddr
);
9 __tsan_java_mutex_lock(lockaddr
);
10 __tsan_java_mutex_lock(lockaddr
);
11 int rec
= __tsan_java_mutex_unlock_rec(lockaddr
);
13 fprintf(stderr
, "FAILED 0 rec=%d\n", rec
);
17 barrier_wait(&barrier
);
18 barrier_wait(&barrier
);
19 __tsan_java_mutex_lock_rec(lockaddr
, rec
);
20 __tsan_java_mutex_unlock(lockaddr
);
21 __tsan_java_mutex_unlock(lockaddr
);
22 __tsan_java_mutex_unlock(lockaddr
);
27 barrier_init(&barrier
, 2);
28 int const kHeapSize
= 1024 * 1024;
29 jptr jheap
= (jptr
)malloc(kHeapSize
+ 8) + 8;
30 __tsan_java_init(jheap
, kHeapSize
);
31 const int kBlockSize
= 16;
32 __tsan_java_alloc(jheap
, kBlockSize
);
37 pthread_create(&th
, 0, Thread
, 0);
38 barrier_wait(&barrier
);
39 __tsan_java_mutex_lock(lockaddr
);
41 __tsan_java_mutex_unlock(lockaddr
);
42 barrier_wait(&barrier
);
44 __tsan_java_free(jheap
, kBlockSize
);
45 fprintf(stderr
, "DONE\n");
46 return __tsan_java_fini();
49 // CHECK: WARNING: ThreadSanitizer: data race