@@ -46,41 +46,33 @@ static InitializationState GetInitializationState() {
4646 atomic_load (&rtsan_initialized, memory_order_acquire));
4747}
4848
49- static auto OnViolationAction (DiagnosticsInfo info) {
50- return [ info]( ) {
51- IncrementTotalErrorCount ();
49+ static auto OnViolationAction (const BufferedStackTrace &stack,
50+ const DiagnosticsInfo & info) {
51+ IncrementTotalErrorCount ();
5252
53- BufferedStackTrace stack;
53+ // If in the future we interop with other sanitizers, we will
54+ // need to make our own stackdepot
55+ StackDepotHandle handle = StackDepotPut_WithHandle (stack);
5456
55- // We use the unwind_on_fatal flag here because of precedent with other
56- // sanitizers, this action is not necessarily fatal if halt_on_error=false
57- stack.Unwind (info.pc , info.bp , nullptr ,
58- common_flags ()->fast_unwind_on_fatal );
57+ const bool is_stack_novel = handle.use_count () == 0 ;
5958
60- // If in the future we interop with other sanitizers, we will
61- // need to make our own stackdepot
62- StackDepotHandle handle = StackDepotPut_WithHandle (stack);
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)) {
63+ IncrementUniqueErrorCount ();
6364
64- const bool is_stack_novel = handle.use_count () == 0 ;
65+ PrintDiagnostics (info);
66+ stack.Print ();
6567
66- // Marked UNLIKELY as if user is runing with halt_on_error=false
67- // we expect a high number of duplicate stacks. We are willing
68- // To pay for the first insertion.
69- if (UNLIKELY (is_stack_novel)) {
70- IncrementUniqueErrorCount ();
68+ handle.inc_use_count_unsafe ();
69+ }
7170
72- PrintDiagnostics (info);
73- stack.Print ();
74-
75- handle.inc_use_count_unsafe ();
76- }
77-
78- if (flags ().halt_on_error ) {
79- if (flags ().print_stats_on_exit )
80- PrintStatisticsSummary ();
81- Die ();
82- }
83- };
71+ if (flags ().halt_on_error ) {
72+ if (flags ().print_stats_on_exit )
73+ PrintStatisticsSummary ();
74+ Die ();
75+ }
8476}
8577
8678extern " C" {
@@ -141,17 +133,17 @@ __rtsan_notify_intercepted_call(const char *func_name) {
141133 __rtsan_ensure_initialized ();
142134 GET_CALLER_PC_BP;
143135 ExpectNotRealtime (GetContextForThisThread (),
144- OnViolationAction ( {DiagnosticsInfoType::InterceptedCall,
145- func_name, pc, bp}) );
136+ {DiagnosticsInfoType::InterceptedCall, func_name, pc, bp} ,
137+ OnViolationAction );
146138}
147139
148140SANITIZER_INTERFACE_ATTRIBUTE void
149141__rtsan_notify_blocking_call (const char *func_name) {
150142 __rtsan_ensure_initialized ();
151143 GET_CALLER_PC_BP;
152144 ExpectNotRealtime (GetContextForThisThread (),
153- OnViolationAction ( {DiagnosticsInfoType::BlockingCall,
154- func_name, pc, bp}) );
145+ {DiagnosticsInfoType::BlockingCall, func_name, pc, bp} ,
146+ OnViolationAction );
155147}
156148
157149} // extern "C"
0 commit comments