1 // RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s 2 #include "java.h" 3 Thread(void * p)4void *Thread(void *p) { 5 *(int*)p = 42; 6 return 0; 7 } 8 main()9int main() { 10 int const kHeapSize = 1024 * 1024; 11 void *jheap = malloc(kHeapSize); 12 __tsan_java_init((jptr)jheap, kHeapSize); 13 const int kBlockSize = 16; 14 __tsan_java_alloc((jptr)jheap, kBlockSize); 15 pthread_t th; 16 pthread_create(&th, 0, Thread, jheap); 17 *(int*)jheap = 43; 18 pthread_join(th, 0); 19 __tsan_java_free((jptr)jheap, kBlockSize); 20 return __tsan_java_fini(); 21 } 22 23 // CHECK: WARNING: ThreadSanitizer: data race 24