[compiler-rt] [rtsan] Add stats summary even when halt_on_error=true (PR #110165)
Chris Apple via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 26 13:29:51 PDT 2024
https://github.com/cjappl created https://github.com/llvm/llvm-project/pull/110165
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
>From 364637ff69b2363d9335a34bfc65a32ab65ec920 Mon Sep 17 00:00:00 2001
From: Chris Apple <cja-private at pm.me>
Date: Thu, 26 Sep 2024 13:27:51 -0700
Subject: [PATCH] [rtsan] Add stats summary even when halt_on_error=true
---
compiler-rt/lib/rtsan/rtsan.cpp | 5 ++++-
compiler-rt/test/rtsan/exit_stats.cpp | 7 ++++++-
2 files changed, 10 insertions(+), 2 deletions(-)
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
More information about the llvm-commits
mailing list