[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
Mon Sep 9 14:10:01 PDT 2024


https://github.com/cjappl updated https://github.com/llvm/llvm-project/pull/107620

>From 7d451660d31b0876eca1c1ad20c07cb23e35aa27 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 f4075bb27e4f91..607db90213a30d 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*}}
 }



More information about the llvm-commits mailing list