Skip to content

Commit 8121de1

Browse files
committed
for triple-panics, do not keep printing backtraces
1 parent b60f7b5 commit 8121de1

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

library/std/src/panicking.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ fn default_hook(info: &PanicInfo<'_>) {
246246
pub fn panic_hook_with_disk_dump(info: &PanicInfo<'_>, path: Option<&crate::path::Path>) {
247247
// If this is a double panic, make sure that we print a backtrace
248248
// for this panic. Otherwise only print it if logging is enabled.
249-
let backtrace = if panic_count::get_count() >= 2 {
249+
// We do not keep printing for further panics, so that e.g. a "panic inside a drop on an unwind
250+
// path", which leads to a triple-panic (the third panic being "cannot unwind here"), doesn't
251+
// print *two* backtraces.
252+
let backtrace = if panic_count::get_count() == 2 {
250253
BacktraceStyle::full()
251254
} else {
252255
crate::panic::get_backtrace_style()

src/tools/miri/tests/fail/panic/double_panic.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ second
66
stack backtrace:
77
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
88
panic in a destructor during cleanup
9-
stack backtrace:
109
thread caused non-unwinding panic. aborting.
1110
error: abnormal termination: the program aborted execution
1211
--> RUSTLIB/std/src/sys/PLATFORM/mod.rs:LL:CC

0 commit comments

Comments
 (0)