Avoid reentrancy of the same thread in AbslFailureSignalHandler() PiperOrigin-RevId: 947787991 Change-Id: Ic5f07a6f76e28545d61535c9215462bfd57c355c
diff --git a/absl/debugging/failure_signal_handler.cc b/absl/debugging/failure_signal_handler.cc index 16609f1..46cb97f 100644 --- a/absl/debugging/failure_signal_handler.cc +++ b/absl/debugging/failure_signal_handler.cc
@@ -383,10 +383,16 @@ // a bit for it to finish. If the other thread doesn't kill us, // we do so after sleeping. PortableSleepForSeconds(3); - RaiseToDefaultHandler(signo); - // The recursively raised signal may be blocked until we return. - return; + } else { + // Same thread re-entered: the handler itself faulted. Do NOT fall through + // and re-run the body (which would recurse under SA_NODEFER, resetting + // the alarm each time and consuming the unguarded altstack). Instead, + // terminate now. } + + RaiseToDefaultHandler(signo); + // The recursively raised signal may be blocked until we return. + return; } // Increase the chance that the CPU we report was the same CPU on which the