2014-05-30 22:08:51 +08:00
|
|
|
// RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
|
2012-05-16 15:48:16 +08:00
|
|
|
#include <pthread.h>
|
2013-06-25 00:28:02 +08:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2012-05-16 15:48:16 +08:00
|
|
|
int Global;
|
2013-06-25 00:28:02 +08:00
|
|
|
|
2012-05-16 15:48:16 +08:00
|
|
|
void *Thread1(void *x) {
|
2013-06-25 00:28:02 +08:00
|
|
|
sleep(1);
|
2012-05-16 15:48:16 +08:00
|
|
|
Global = 42;
|
|
|
|
return x;
|
|
|
|
}
|
2013-06-25 00:28:02 +08:00
|
|
|
|
2012-05-16 15:48:16 +08:00
|
|
|
int main() {
|
|
|
|
pthread_t t;
|
2013-06-25 00:28:02 +08:00
|
|
|
pthread_create(&t, 0, Thread1, 0);
|
2012-05-16 15:48:16 +08:00
|
|
|
Global = 43;
|
2013-06-25 00:28:02 +08:00
|
|
|
pthread_join(t, 0);
|
2012-05-16 15:48:16 +08:00
|
|
|
return Global;
|
|
|
|
}
|
2013-06-25 00:28:02 +08:00
|
|
|
|
2012-05-16 15:48:16 +08:00
|
|
|
// CHECK: WARNING: ThreadSanitizer: data race
|