Skip to content

Commit 5063b44

Browse files
committed
when terminating during unwinding, show the reason why
1 parent 42e88a1 commit 5063b44

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/machine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,9 +975,9 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
975975
ecx.start_panic_nounwind(msg)
976976
}
977977

978-
fn unwind_terminate(ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
978+
fn unwind_terminate(ecx: &mut InterpCx<'mir, 'tcx, Self>, reason: mir::UnwindTerminateReason) -> InterpResult<'tcx> {
979979
// Call the lang item.
980-
let panic = ecx.tcx.lang_items().panic_cannot_unwind().unwrap();
980+
let panic = ecx.tcx.lang_items().get(reason.lang_item()).unwrap();
981981
let panic = ty::Instance::mono(ecx.tcx.tcx, panic);
982982
ecx.call_function(
983983
panic,

tests/fail/panic/double_panic.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ thread 'main' panicked at $DIR/double_panic.rs:LL:CC:
55
second
66
stack backtrace:
77
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
8-
panic in a function that cannot unwind
8+
panic in a destructor during cleanup
99
stack backtrace:
1010
thread caused non-unwinding panic. aborting.
1111
error: abnormal termination: the program aborted execution
@@ -20,7 +20,7 @@ LL | ABORT();
2020
= note: inside `std::sys_common::backtrace::__rust_end_short_backtrace::<[closure@std::panicking::begin_panic_handler::{closure#0}], !>` at RUSTLIB/std/src/sys_common/backtrace.rs:LL:CC
2121
= note: inside `std::panicking::begin_panic_handler` at RUSTLIB/std/src/panicking.rs:LL:CC
2222
= note: inside `core::panicking::panic_nounwind` at RUSTLIB/core/src/panicking.rs:LL:CC
23-
= note: inside `core::panicking::panic_cannot_unwind` at RUSTLIB/core/src/panicking.rs:LL:CC
23+
= note: inside `core::panicking::panic_in_cleanup` at RUSTLIB/core/src/panicking.rs:LL:CC
2424
note: inside `main`
2525
--> $DIR/double_panic.rs:LL:CC
2626
|

0 commit comments

Comments
 (0)