Skip to content

[hwasan] Call user provided callback function for both fatal and non-… #80429

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 1 commit into from
Feb 10, 2024

Conversation

Enna1
Copy link
Contributor

@Enna1 Enna1 commented Feb 2, 2024

…fatal error report

This makes the behavior of HWASan matching with ASan: always call user provided callback function for an error report, but only call SetAbortMessage() on Android when flags()->halt_on_error is true.

@llvmbot
Copy link
Member

llvmbot commented Feb 2, 2024

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Enna1 (Enna1)

Changes

…fatal error report


Full diff: https://github.com/llvm/llvm-project/pull/80429.diff

1 Files Affected:

  • (modified) compiler-rt/lib/hwasan/hwasan_report.cpp (+1-1)
diff --git a/compiler-rt/lib/hwasan/hwasan_report.cpp b/compiler-rt/lib/hwasan/hwasan_report.cpp
index 12a4fa47f2151..54bf8247ceeb3 100644
--- a/compiler-rt/lib/hwasan/hwasan_report.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_report.cpp
@@ -40,7 +40,7 @@ class ScopedReport {
  public:
   explicit ScopedReport(bool fatal) : fatal(fatal) {
     Lock lock(&error_message_lock_);
-    error_message_ptr_ = fatal ? &error_message_ : nullptr;
+    error_message_ptr_ = &error_message_;
     ++hwasan_report_count;
   }
 

@Enna1 Enna1 requested a review from fmayer February 6, 2024 08:13
@fmayer
Copy link
Contributor

fmayer commented Feb 6, 2024

tbh I am not sure who uses this API, so I am not sure if this behavior change could cause any problems

@Enna1
Copy link
Contributor Author

Enna1 commented Feb 7, 2024

tbh I am not sure who uses this API, so I am not sure if this behavior change could cause any problems

Thanks for the review!

This change makes the behavior of hwasan matching with asan.
https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/asan/asan_report.cpp#L173-L183
Always call user provided callback function for an error report, but only call android_set_abort_message() on Android when flags()->halt_on_error is true.

In my use case, I collect every error report text and upload it to storage using __hwasan_set_error_report_callback():)

Copy link
Contributor

@fmayer fmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add "match ASan behavior" or something in the commit description.

…fatal error report

This makes the behavior of HWASan matching with ASan: always call user provided callback function for an error report, but only call `SetAbortMessage()` on Android when `flags()->halt_on_error` is true.
@Enna1 Enna1 force-pushed the users/Enna1/hwasan-error-report-callback branch from 3c457ae to 37b4c41 Compare February 8, 2024 12:06
@Enna1 Enna1 merged commit b7cc401 into main Feb 10, 2024
@Enna1 Enna1 deleted the users/Enna1/hwasan-error-report-callback branch February 10, 2024 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants