From 7d451660d31b0876eca1c1ad20c07cb23e35aa27 Mon Sep 17 00:00:00 2001 From: Chris Apple Date: Tue, 3 Sep 2024 09:03:43 -0700 Subject: [PATCH 1/2] [compiler-rt][rtsan] Improve error message wording to match ASan style --- compiler-rt/lib/rtsan/rtsan_context.cpp | 9 +++++---- compiler-rt/lib/rtsan/tests/rtsan_test_utilities.h | 7 ++++--- compiler-rt/test/rtsan/basic.cpp | 3 ++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/compiler-rt/lib/rtsan/rtsan_context.cpp b/compiler-rt/lib/rtsan/rtsan_context.cpp index a49b70360babb..8609394fa222f 100644 --- a/compiler-rt/lib/rtsan/rtsan_context.cpp +++ b/compiler-rt/lib/rtsan/rtsan_context.cpp @@ -95,10 +95,11 @@ void __rtsan::PrintDiagnostics(const char *intercepted_function_name, uptr pc, uptr bp) { ScopedErrorReportLock l; - fprintf(stderr, - "Real-time violation: intercepted call to real-time unsafe function " - "`%s` in real-time context! Stack trace:\n", - intercepted_function_name); + Report("ERROR: RealtimeSanitizer: unsafe-library-call\n"); + Printf("Intercepted call to real-time unsafe function " + "`%s` in real-time context!\n", + intercepted_function_name); + __rtsan::PrintStackTrace(pc, bp); } diff --git a/compiler-rt/lib/rtsan/tests/rtsan_test_utilities.h b/compiler-rt/lib/rtsan/tests/rtsan_test_utilities.h index 6ca09cf657094..4ba4fc5e53086 100644 --- a/compiler-rt/lib/rtsan/tests/rtsan_test_utilities.h +++ b/compiler-rt/lib/rtsan/tests/rtsan_test_utilities.h @@ -30,9 +30,10 @@ void ExpectRealtimeDeath(Function &&Func, auto GetExpectedErrorSubstring = [&]() -> std::string { return intercepted_method_name != nullptr - ? "Real-time violation: intercepted call to real-time unsafe " - "function `" + - std::string(intercepted_method_name) + "`" + ? ".*==ERROR: RealtimeSanitizer: unsafe-library-call.*" + "Intercepted call to real-time unsafe function `" + + std::string(intercepted_method_name) + + "` in real-time context!" : ""; }; diff --git a/compiler-rt/test/rtsan/basic.cpp b/compiler-rt/test/rtsan/basic.cpp index f4075bb27e4f9..607db90213a30 100644 --- a/compiler-rt/test/rtsan/basic.cpp +++ b/compiler-rt/test/rtsan/basic.cpp @@ -17,6 +17,7 @@ void violation() [[clang::nonblocking]] { int main() { violation(); return 0; - // CHECK: Real-time violation: intercepted call to real-time unsafe function `malloc` in real-time context! Stack trace: + // CHECK: ==ERROR: RealtimeSanitizer: unsafe-library-call + // CHECK-NEXT: Intercepted call to real-time unsafe function `malloc` in real-time context! // CHECK-NEXT: {{.*malloc*}} } From d865e5d14bc6afb3c2ce330fd0516076c9b19982 Mon Sep 17 00:00:00 2001 From: Chris Apple Date: Tue, 10 Sep 2024 13:31:01 -0700 Subject: [PATCH 2/2] Fix disabler test --- compiler-rt/test/rtsan/disabler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler-rt/test/rtsan/disabler.cpp b/compiler-rt/test/rtsan/disabler.cpp index 0a6411a2be694..dd1d4439beae4 100644 --- a/compiler-rt/test/rtsan/disabler.cpp +++ b/compiler-rt/test/rtsan/disabler.cpp @@ -41,7 +41,7 @@ int main() { // CHECK: Allocated pointer {{.*}} in disabled context // CHECK: Allocated second pointer {{.*}} in disabled context // CHECK: Free'd second pointer in disabled context - // CHECK: {{.*Real-time violation.*}} + // CHECK: ==ERROR: RealtimeSanitizer: unsafe-library-call // CHECK-NOT: {{.*malloc*}} // CHECK-NEXT: {{.*free.*}} }