Skip to content

Commit 595e484

Browse files
authored
[rtsan] Add option to allow printing of duplicate stacks (suppress_equal_stacks) (#117069)
Following the example of tsan, where we took the name This would allow users to determine if they want to see ALL output from rtsan. Additionally, remove the UNLIKELY hint, as it is now up to the flag whether or not it is likely that we go through this conditional.
1 parent 963b8e3 commit 595e484

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

compiler-rt/lib/rtsan/rtsan.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,7 @@ static void OnViolation(const BufferedStackTrace &stack,
5555
StackDepotHandle handle = StackDepotPut_WithHandle(stack);
5656

5757
const bool is_stack_novel = handle.use_count() == 0;
58-
59-
// Marked UNLIKELY as if user is runing with halt_on_error=false
60-
// we expect a high number of duplicate stacks. We are willing
61-
// To pay for the first insertion.
62-
if (UNLIKELY(is_stack_novel)) {
58+
if (is_stack_novel || !flags().suppress_equal_stacks) {
6359
IncrementUniqueErrorCount();
6460

6561
{

compiler-rt/lib/rtsan/rtsan_flags.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@
1919
RTSAN_FLAG(bool, halt_on_error, true, "Exit after first reported error.")
2020
RTSAN_FLAG(bool, print_stats_on_exit, false, "Print stats on exit.")
2121
RTSAN_FLAG(const char *, suppressions, "", "Suppressions file name.")
22+
RTSAN_FLAG(bool, suppress_equal_stacks, true,
23+
"Suppress a report if we've already output another report "
24+
"with the same stack.")

compiler-rt/test/rtsan/deduplicate_errors.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %clangxx -fsanitize=realtime %s -o %t
22
// RUN: env RTSAN_OPTIONS="halt_on_error=false,print_stats_on_exit=true" %run %t 2>&1 | FileCheck %s
3+
// RUN: env RTSAN_OPTIONS="halt_on_error=false,suppress_equal_stacks=false" %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-DUPLICATES
34

45
// UNSUPPORTED: ios
56

@@ -37,3 +38,6 @@ int main() {
3738
// CHECK: RealtimeSanitizer exit stats:
3839
// CHECK-NEXT: Total error count: 220
3940
// CHECK-NEXT: Unique error count: 4
41+
42+
// CHECK-DUPLICATES-COUNT-220: ==ERROR:
43+
// CHECK-DUPLICATES-NOT: ==ERROR:

0 commit comments

Comments
 (0)