1 // RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
4 int const kHeapSize
= 1024 * 1024;
6 void stress(jptr addr
) {
7 for (jptr sz
= 8; sz
<= 32; sz
<<= 1) {
8 for (jptr i
= 0; i
< kHeapSize
/ 4 / sz
; i
++) {
9 __tsan_java_alloc(addr
+ i
* sz
, sz
);
11 __tsan_java_move(addr
, addr
+ kHeapSize
/ 2, kHeapSize
/ 4);
12 __tsan_java_free(addr
+ kHeapSize
/ 2, kHeapSize
/ 4);
16 void *Thread(void *p
) {
22 jptr jheap
= (jptr
)malloc(kHeapSize
+ 8) + 8;
23 __tsan_java_init(jheap
, kHeapSize
);
25 pthread_create(&th
, 0, Thread
, (void*)(jheap
+ kHeapSize
/ 4));
28 if (__tsan_java_fini() != 0) {
29 fprintf(stderr
, "FAILED\n");
32 fprintf(stderr
, "DONE\n");
36 // CHECK-NOT: WARNING: ThreadSanitizer: data race