[compiler-rt] [rtsan] Add stats summary even when halt_on_error=true (PR #110165)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 26 13:30:25 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Chris Apple (cjappl)
<details>
<summary>Changes</summary>
I discovered this on another branch. We only output the summary when halt_on_exit=false.
Questions:
1. Should this configuration be valid? It will always definitionally output "total = 1, unique =1". We could just abort early as an invalid combo
---
Full diff: https://github.com/llvm/llvm-project/pull/110165.diff
2 Files Affected:
- (modified) compiler-rt/lib/rtsan/rtsan.cpp (+4-1)
- (modified) compiler-rt/test/rtsan/exit_stats.cpp (+6-1)
``````````diff
diff --git a/compiler-rt/lib/rtsan/rtsan.cpp b/compiler-rt/lib/rtsan/rtsan.cpp
index 6fcff5e326a52f..f4f242c0f34638 100644
--- a/compiler-rt/lib/rtsan/rtsan.cpp
+++ b/compiler-rt/lib/rtsan/rtsan.cpp
@@ -75,8 +75,11 @@ static auto OnViolationAction(DiagnosticsInfo info) {
handle.inc_use_count_unsafe();
}
- if (flags().halt_on_error)
+ if (flags().halt_on_error) {
+ if (flags().print_stats_on_exit)
+ PrintStatisticsSummary();
Die();
+ }
};
}
diff --git a/compiler-rt/test/rtsan/exit_stats.cpp b/compiler-rt/test/rtsan/exit_stats.cpp
index 4341fbb0f9cf21..d4d19ace778ba5 100644
--- a/compiler-rt/test/rtsan/exit_stats.cpp
+++ b/compiler-rt/test/rtsan/exit_stats.cpp
@@ -1,5 +1,6 @@
// RUN: %clangxx -fsanitize=realtime %s -o %t
-// RUN: env RTSAN_OPTIONS="halt_on_error=false,print_stats_on_exit=true" %run %t 2>&1 | FileCheck %s
+// RUN: %env_rtsan_opts="halt_on_error=false,print_stats_on_exit=true" %run %t 2>&1 | FileCheck %s
+// RUN: %env_rtsan_opts="halt_on_error=true,print_stats_on_exit=true" not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-HALT
// UNSUPPORTED: ios
@@ -22,3 +23,7 @@ int main() {
// CHECK: RealtimeSanitizer exit stats:
// CHECK-NEXT: Total error count: 10
// CHECK-NEXT: Unique error count: 1
+
+// CHECK-HALT: RealtimeSanitizer exit stats:
+// CHECK-HALT-NEXT: Total error count: 1
+// CHECK-HALT-NEXT: Unique error count: 1
``````````
</details>
https://github.com/llvm/llvm-project/pull/110165
More information about the llvm-commits
mailing list