1*7c3d14c8STreehugger Robot // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s 2*7c3d14c8STreehugger Robot #include <pthread.h> 3*7c3d14c8STreehugger Robot #include <stdio.h> 4*7c3d14c8STreehugger Robot 5*7c3d14c8STreehugger Robot extern "C" void AnnotateIgnoreSyncBegin(const char*, int); 6*7c3d14c8STreehugger Robot extern "C" void AnnotateIgnoreSyncEnd(const char*, int); 7*7c3d14c8STreehugger Robot 8*7c3d14c8STreehugger Robot int Global; 9*7c3d14c8STreehugger Robot pthread_mutex_t Mutex = PTHREAD_MUTEX_INITIALIZER; 10*7c3d14c8STreehugger Robot Thread(void * x)11*7c3d14c8STreehugger Robotvoid *Thread(void *x) { 12*7c3d14c8STreehugger Robot AnnotateIgnoreSyncBegin(0, 0); 13*7c3d14c8STreehugger Robot pthread_mutex_lock(&Mutex); 14*7c3d14c8STreehugger Robot Global++; 15*7c3d14c8STreehugger Robot pthread_mutex_unlock(&Mutex); 16*7c3d14c8STreehugger Robot AnnotateIgnoreSyncEnd(0, 0); 17*7c3d14c8STreehugger Robot return 0; 18*7c3d14c8STreehugger Robot } 19*7c3d14c8STreehugger Robot main()20*7c3d14c8STreehugger Robotint main() { 21*7c3d14c8STreehugger Robot pthread_t t; 22*7c3d14c8STreehugger Robot pthread_create(&t, 0, Thread, 0); 23*7c3d14c8STreehugger Robot pthread_mutex_lock(&Mutex); 24*7c3d14c8STreehugger Robot Global++; 25*7c3d14c8STreehugger Robot pthread_mutex_unlock(&Mutex); 26*7c3d14c8STreehugger Robot pthread_join(t, 0); 27*7c3d14c8STreehugger Robot } 28*7c3d14c8STreehugger Robot 29*7c3d14c8STreehugger Robot // CHECK: WARNING: ThreadSanitizer: data race 30*7c3d14c8STreehugger Robot 31