-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[compiler-rt][rtsan] Improve error message wording to match ASan style #107620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CC for review @davidtrevelyan |
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Chris Apple (cjappl) ChangesNew error messages look like:
Full diff: https://github.com/llvm/llvm-project/pull/107620.diff 3 Files Affected:
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*}}
}
|
5f38bff
to
b175e8a
Compare
b175e8a
to
7d45166
Compare
fmayer
approved these changes
Sep 9, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, lgtm
davidtrevelyan
approved these changes
Sep 10, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New error messages look like:
The main changes:
Report
instead of fprintf to kick off the error message. This puts the==PID==
in the front of the message.==PID==ERROR: RealtimeSanitizer: specific-reason-code
- again matching asan.Intercepted call to real-time unsafe function
fnamein real-time context!
The current version looks like this, for reference: