1 // RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
9 void *Thread(void *p
) {
10 barrier_wait(&barrier
);
11 __tsan_java_mutex_lock(lockaddr2
);
13 __tsan_java_mutex_unlock(lockaddr2
);
18 barrier_init(&barrier
, 2);
19 int const kHeapSize
= 1024 * 1024;
20 jptr jheap
= (jptr
)malloc(kHeapSize
+ 8) + 8;
21 __tsan_java_init(jheap
, kHeapSize
);
22 const int kBlockSize
= 64;
23 int const kMove
= 1024;
24 __tsan_java_alloc(jheap
, kBlockSize
);
26 lockaddr
= jheap
+ 46;
27 varaddr2
= varaddr
+ kMove
;
28 lockaddr2
= lockaddr
+ kMove
;
30 pthread_create(&th
, 0, Thread
, 0);
31 __tsan_java_mutex_lock(lockaddr
);
33 __tsan_java_mutex_unlock(lockaddr
);
34 __tsan_java_move(varaddr
, varaddr2
, kBlockSize
);
35 barrier_wait(&barrier
);
37 __tsan_java_free(varaddr2
, kBlockSize
);
38 fprintf(stderr
, "DONE\n");
39 return __tsan_java_fini();
42 // CHECK-NOT: WARNING: ThreadSanitizer: data race