From 364637ff69b2363d9335a34bfc65a32ab65ec920 Mon Sep 17 00:00:00 2001 From: Chris Apple 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 6fcff5e326a52..f4f242c0f3463 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 4341fbb0f9cf2..d4d19ace778ba 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