[compiler-rt] [compiler-rt][rtsan] Improve error message wording to match ASan style (PR #107620)
Chris Apple via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 6 10:34:14 PDT 2024
https://github.com/cjappl created https://github.com/llvm/llvm-project/pull/107620
New error messages look like:
```
==4866==ERROR: RealtimeSanitizer: unsafe-library-call
Intercepted call to real-time unsafe function `malloc` in real-time context!
#0 0x000100c838c4 in malloc rtsan_interceptors.cpp:310
#1 0x000195bd7bd0 in operator new(unsigned long)+0x1c (libc++abi.dylib:arm64+0x16bd0)
#2 0x5b12800100703f30 (<unknown module>)
#3 0x000100703f70 in main main.cpp:23
#4 0x0001958960dc (<unknown module>)
#5 0x4669fffffffffffc (<unknown module>)
```
>From 5f38bff13c376b905989b2844923be62178cb96b Mon Sep 17 00:00:00 2001
From: Chris Apple <cja-private at pm.me>
Date: Tue, 3 Sep 2024 09:03:43 -0700
Subject: [PATCH] [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 a49b70360babbd..8609394fa222fc 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 6ca09cf6570940..4ba4fc5e530864 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 c7cbfcda31562e..4edf32336720f8 100644
--- a/compiler-rt/test/rtsan/basic.cpp
+++ b/compiler-rt/test/rtsan/basic.cpp
@@ -16,6 +16,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*}}
}
More information about the llvm-commits
mailing list