[compiler-rt] dcc6db2 - tsan: add another deep stack test
Dmitry Vyukov via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 23 01:45:21 PDT 2021
Author: Dmitry Vyukov
Date: 2021-09-23T10:45:17+02:00
New Revision: dcc6db22d8508a85ecd2b8bdcc5ae5646968c083
URL: https://github.com/llvm/llvm-project/commit/dcc6db22d8508a85ecd2b8bdcc5ae5646968c083
DIFF: https://github.com/llvm/llvm-project/commit/dcc6db22d8508a85ecd2b8bdcc5ae5646968c083.diff
LOG: tsan: add another deep stack test
Add a test for a trace corner case that lead to a bug
in experimental runtime replacement.
Since it passes with the current runtime it makes sense
to submit it on its own.
Depends on D110264.
Reviewed By: melver
Differential Revision: https://reviews.llvm.org/D110265
Added:
compiler-rt/test/tsan/deep_stack2.cpp
Modified:
Removed:
################################################################################
diff --git a/compiler-rt/test/tsan/deep_stack2.cpp b/compiler-rt/test/tsan/deep_stack2.cpp
new file mode 100644
index 0000000000000..16756867dd6d1
--- /dev/null
+++ b/compiler-rt/test/tsan/deep_stack2.cpp
@@ -0,0 +1,42 @@
+// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
+#include "test.h"
+
+volatile long X;
+volatile long Y;
+volatile int N1 = 2 << 10;
+volatile int N2 = 32 << 10;
+void (*volatile F)();
+void (*volatile G)();
+
+static void foo() {
+ if (--N1)
+ return F();
+ while (--N2)
+ G();
+}
+
+static void bar() { Y++; }
+
+void *Thread(void *p) {
+ F();
+ X = 43;
+ barrier_wait(&barrier);
+ return 0;
+}
+
+int main() {
+ barrier_init(&barrier, 2);
+ F = foo;
+ G = bar;
+ pthread_t t;
+ pthread_create(&t, 0, Thread, 0);
+ barrier_wait(&barrier);
+ X = 43;
+ pthread_join(t, 0);
+}
+
+// CHECK: WARNING: ThreadSanitizer: data race
+// CHECK: Write
+// CHECK: #0 main
+// CHECK: Previous write
+// CHECK: #0 Thread
More information about the llvm-commits
mailing list