Files
clang-p2996/compiler-rt/test/tsan/malloc_stack.cc
Dmitry Vyukov 233f401c2b tsan: make positive tests more robust
Add a script that is used to deflake inherently flaky tsan tests.
It is invoked from lit tests as:
%deflake %run %t
The script runs the target program up to 10 times,
until it produces a tsan warning.

llvm-svn: 209898
2014-05-30 14:08:51 +00:00

26 lines
525 B
C++

// RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
#include <pthread.h>
#include <unistd.h>
_Atomic(int*) p;
void *thr(void *a) {
sleep(1);
int *pp = __c11_atomic_load(&p, __ATOMIC_RELAXED);
*pp = 42;
return 0;
}
int main() {
pthread_t th;
pthread_create(&th, 0, thr, p);
__c11_atomic_store(&p, new int, __ATOMIC_RELAXED);
pthread_join(th, 0);
}
// CHECK: data race
// CHECK: Previous write
// CHECK: #0 operator new
// CHECK: Location is heap block
// CHECK: #0 operator new