Skip to content

Commit 06e2a47

Browse files
dvyukovmemfrob
authored andcommitted
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
1 parent bf7342d commit 06e2a47

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

compiler-rt/test/tsan/Linux/double_race.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
long long buf[2];
99
volatile int nreport;
1010

11-
void __sanitizer_report_error_summary(const char *summary) {
11+
__attribute__((disable_sanitizer_instrumentation)) void
12+
__sanitizer_report_error_summary(const char *summary) {
1213
nreport++;
1314
}
1415

1516
const int kEventPCBits = 61;
1617

17-
extern "C" bool __tsan_symbolize_external(unsigned long pc, char *func_buf,
18-
unsigned long func_siz,
19-
char *file_buf,
20-
unsigned long file_siz, int *line,
21-
int *col) {
18+
extern "C" __attribute__((disable_sanitizer_instrumentation)) bool
19+
__tsan_symbolize_external(unsigned long pc, char *func_buf,
20+
unsigned long func_siz, char *file_buf,
21+
unsigned long file_siz, int *line, int *col) {
2222
if (pc >> kEventPCBits) {
2323
printf("bad PC passed to __tsan_symbolize_external: %lx\n", pc);
2424
_exit(1);
@@ -47,6 +47,5 @@ int main() {
4747
// CHECK: #0 memset
4848
// CHECK: #{{[12]}} Thread
4949
// CHECK-NOT: bad PC passed to __tsan_symbolize_external
50-
// CHECK: WARNING: ThreadSanitizer: data race
51-
// CHECK: Write of size 8 at {{.*}} by thread T1:
52-
// CHECK: #0 Thread
50+
// CHECK-NOT: __sanitizer_report_error_summary
51+
// CHECK-NOT: WARNING: ThreadSanitizer: data race

compiler-rt/test/tsan/debugging.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ int main() {
4646
fprintf(stderr, "Done.\n");
4747
}
4848

49-
void __tsan_on_report(void *report) {
49+
__attribute__((disable_sanitizer_instrumentation)) void
50+
__tsan_on_report(void *report) {
5051
fprintf(stderr, "__tsan_on_report(%p)\n", report);
5152
fprintf(stderr, "__tsan_get_current_report() = %p\n",
5253
__tsan_get_current_report());

compiler-rt/test/tsan/java_symbolization.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
#include "java.h"
33
#include <memory.h>
44

5-
extern "C" void __tsan_symbolize_external_ex(
6-
jptr pc, void (*add_frame)(void *, const char *, const char *, int, int),
7-
void *ctx) {
5+
extern "C" __attribute__((disable_sanitizer_instrumentation)) void
6+
__tsan_symbolize_external_ex(jptr pc,
7+
void (*add_frame)(void *, const char *,
8+
const char *, int, int),
9+
void *ctx) {
810
if (pc == (1234 | kExternalPCBit)) {
911
add_frame(ctx, "MyInnerFunc", "MyInnerFile.java", 1234, 56);
1012
add_frame(ctx, "MyOuterFunc", "MyOuterFile.java", 4321, 65);

compiler-rt/test/tsan/java_symbolization_legacy.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
#include "java.h"
33
#include <memory.h>
44

5-
extern "C" bool __tsan_symbolize_external(jptr pc,
6-
char *func_buf, jptr func_siz,
7-
char *file_buf, jptr file_siz,
8-
int *line, int *col) {
5+
extern "C" __attribute__((disable_sanitizer_instrumentation)) bool
6+
__tsan_symbolize_external(jptr pc, char *func_buf, jptr func_siz,
7+
char *file_buf, jptr file_siz, int *line, int *col) {
98
if (pc == (1234 | kExternalPCBit)) {
109
memcpy(func_buf, "MyFunc", sizeof("MyFunc"));
1110
memcpy(file_buf, "MyFile.java", sizeof("MyFile.java"));

0 commit comments

Comments
 (0)