[compiler-rt] r180251 - tsan: add a test that used to crash, fixed by r180180.

Dmitry Vyukov dvyukov at google.com
Wed Apr 24 23:58:44 PDT 2013


Author: dvyukov
Date: Thu Apr 25 01:58:43 2013
New Revision: 180251

URL: http://llvm.org/viewvc/llvm-project?rev=180251&view=rev
Log:
tsan: add a test that used to crash, fixed by r180180.

Added:
    compiler-rt/trunk/lib/tsan/lit_tests/oob_race.cc

Added: compiler-rt/trunk/lib/tsan/lit_tests/oob_race.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/lit_tests/oob_race.cc?rev=180251&view=auto
==============================================================================
--- compiler-rt/trunk/lib/tsan/lit_tests/oob_race.cc (added)
+++ compiler-rt/trunk/lib/tsan/lit_tests/oob_race.cc Thu Apr 25 01:58:43 2013
@@ -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
+





More information about the llvm-commits mailing list