[compiler-rt] 24af1ba - tsan: don't instrument runtime callbacks in tests
Dmitry Vyukov via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 5 23:44:13 PDT 2021
Author: Dmitry Vyukov
Date: 2021-10-06T08:44:04+02:00
New Revision: 24af1ba605364e3e91a05e47d41c2aec1b7b2d26
URL: https://github.com/llvm/llvm-project/commit/24af1ba605364e3e91a05e47d41c2aec1b7b2d26
DIFF: https://github.com/llvm/llvm-project/commit/24af1ba605364e3e91a05e47d41c2aec1b7b2d26.diff
LOG: tsan: don't instrument runtime callbacks in tests
These runtime callbacks are supposed to be non-instrumented,
we can't handle runtime recursion well, nor can we afford
explicit recursion checks in the hot functions (memory access,
function entry/exit).
It used to work (not crash), but it won't work with the new runtime.
Mark all runtime callbacks as non-instrumented.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D111157
Added:
Modified:
compiler-rt/test/tsan/Linux/double_race.cpp
compiler-rt/test/tsan/debugging.cpp
compiler-rt/test/tsan/java_symbolization.cpp
compiler-rt/test/tsan/java_symbolization_legacy.cpp
Removed:
################################################################################
diff --git a/compiler-rt/test/tsan/Linux/double_race.cpp b/compiler-rt/test/tsan/Linux/double_race.cpp
index c8fda7482ae68..81d4ca0ea1c72 100644
--- a/compiler-rt/test/tsan/Linux/double_race.cpp
+++ b/compiler-rt/test/tsan/Linux/double_race.cpp
@@ -8,17 +8,17 @@
long long buf[2];
volatile int nreport;
-void __sanitizer_report_error_summary(const char *summary) {
+__attribute__((disable_sanitizer_instrumentation)) void
+__sanitizer_report_error_summary(const char *summary) {
nreport++;
}
const int kEventPCBits = 61;
-extern "C" bool __tsan_symbolize_external(unsigned long pc, char *func_buf,
- unsigned long func_siz,
- char *file_buf,
- unsigned long file_siz, int *line,
- int *col) {
+extern "C" __attribute__((disable_sanitizer_instrumentation)) bool
+__tsan_symbolize_external(unsigned long pc, char *func_buf,
+ unsigned long func_siz, char *file_buf,
+ unsigned long file_siz, int *line, int *col) {
if (pc >> kEventPCBits) {
printf("bad PC passed to __tsan_symbolize_external: %lx\n", pc);
_exit(1);
@@ -47,6 +47,5 @@ int main() {
// CHECK: #0 memset
// CHECK: #{{[12]}} Thread
// CHECK-NOT: bad PC passed to __tsan_symbolize_external
-// CHECK: WARNING: ThreadSanitizer: data race
-// CHECK: Write of size 8 at {{.*}} by thread T1:
-// CHECK: #0 Thread
+// CHECK-NOT: __sanitizer_report_error_summary
+// CHECK-NOT: WARNING: ThreadSanitizer: data race
diff --git a/compiler-rt/test/tsan/debugging.cpp b/compiler-rt/test/tsan/debugging.cpp
index d9c7c65816ab2..be0a0c7b0824d 100644
--- a/compiler-rt/test/tsan/debugging.cpp
+++ b/compiler-rt/test/tsan/debugging.cpp
@@ -46,7 +46,8 @@ int main() {
fprintf(stderr, "Done.\n");
}
-void __tsan_on_report(void *report) {
+__attribute__((disable_sanitizer_instrumentation)) void
+__tsan_on_report(void *report) {
fprintf(stderr, "__tsan_on_report(%p)\n", report);
fprintf(stderr, "__tsan_get_current_report() = %p\n",
__tsan_get_current_report());
diff --git a/compiler-rt/test/tsan/java_symbolization.cpp b/compiler-rt/test/tsan/java_symbolization.cpp
index 809790a6a5131..50f7f49ab50ce 100644
--- a/compiler-rt/test/tsan/java_symbolization.cpp
+++ b/compiler-rt/test/tsan/java_symbolization.cpp
@@ -2,9 +2,11 @@
#include "java.h"
#include <memory.h>
-extern "C" void __tsan_symbolize_external_ex(
- jptr pc, void (*add_frame)(void *, const char *, const char *, int, int),
- void *ctx) {
+extern "C" __attribute__((disable_sanitizer_instrumentation)) void
+__tsan_symbolize_external_ex(jptr pc,
+ void (*add_frame)(void *, const char *,
+ const char *, int, int),
+ void *ctx) {
if (pc == (1234 | kExternalPCBit)) {
add_frame(ctx, "MyInnerFunc", "MyInnerFile.java", 1234, 56);
add_frame(ctx, "MyOuterFunc", "MyOuterFile.java", 4321, 65);
diff --git a/compiler-rt/test/tsan/java_symbolization_legacy.cpp b/compiler-rt/test/tsan/java_symbolization_legacy.cpp
index aa5ec0c37558b..ed7ffd35f8056 100644
--- a/compiler-rt/test/tsan/java_symbolization_legacy.cpp
+++ b/compiler-rt/test/tsan/java_symbolization_legacy.cpp
@@ -2,10 +2,9 @@
#include "java.h"
#include <memory.h>
-extern "C" bool __tsan_symbolize_external(jptr pc,
- char *func_buf, jptr func_siz,
- char *file_buf, jptr file_siz,
- int *line, int *col) {
+extern "C" __attribute__((disable_sanitizer_instrumentation)) bool
+__tsan_symbolize_external(jptr pc, char *func_buf, jptr func_siz,
+ char *file_buf, jptr file_siz, int *line, int *col) {
if (pc == (1234 | kExternalPCBit)) {
memcpy(func_buf, "MyFunc", sizeof("MyFunc"));
memcpy(file_buf, "MyFile.java", sizeof("MyFile.java"));
More information about the llvm-commits
mailing list