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
This commit is contained in:
Dmitry Vyukov 2021-10-05 16:54:14 +02:00
parent 6bc64e24c3
commit 24af1ba605
4 changed files with 18 additions and 17 deletions

View File

@ -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

View File

@ -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());

View File

@ -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);

View File

@ -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"));