aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2013-04-25 06:58:43 +0000
committerDmitry Vyukov <dvyukov@google.com>2013-04-25 06:58:43 +0000
commit45269092b22468fd1f9c74de04f8560c05d5b862 (patch)
tree996841bb81144efedc91fbadf6460c40bf81ce11
parent46fea91f84311643cbe7c8daf70c7f81656cf3e1 (diff)
tsan: add a test that used to crash, fixed by r180180.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@180251 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/tsan/lit_tests/oob_race.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/tsan/lit_tests/oob_race.cc b/lib/tsan/lit_tests/oob_race.cc
new file mode 100644
index 000000000..2e7f0593f
--- /dev/null
+++ b/lib/tsan/lit_tests/oob_race.cc
@@ -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
+