tsan: add a test that used to crash, fixed by r180180.

llvm-svn: 180251
This commit is contained in:
Dmitry Vyukov 2013-04-25 06:58:43 +00:00
parent 2816c023ea
commit a05bbe1c9a
1 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,24 @@
// RUN: %clangxx_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdio.h>
const long kOffset = 64*1024;
void *Thread(void *p) {
((char*)p)[-kOffset] = 43;
return 0;
}
int main() {
char *volatile p0 = new char[16];
delete[] p0;
char *p = new char[32];
pthread_t th;
pthread_create(&th, 0, Thread, p);
p[-kOffset] = 42;
pthread_join(th, 0);
}
// Used to crash with CHECK failed.
// CHECK: WARNING: ThreadSanitizer: data race