Skip to content

[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
merged 2 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions compiler-rt/lib/rtsan/rtsan_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
7 changes: 4 additions & 3 deletions compiler-rt/lib/rtsan/tests/rtsan_test_utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
: "";
};

Expand Down
3 changes: 2 additions & 1 deletion compiler-rt/test/rtsan/basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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*}}
}
2 changes: 1 addition & 1 deletion compiler-rt/test/rtsan/disabler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.*}}
}
Expand Down
Loading