Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support unwinding after a panic #693

Merged
merged 10 commits into from
Nov 19, 2019
3 changes: 2 additions & 1 deletion src/shims/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
// that is, calls to `extern "Rust" { fn __rust_start_panic(...) }`.
// We forward this to the underlying *implementation* in "libpanic_unwind".
Aaron1011 marked this conversation as resolved.
Show resolved Hide resolved
"__rust_start_panic" => {
RalfJung marked this conversation as resolved.
Show resolved Hide resolved
let start_panic_instance = this.resolve_path(&["panic_unwind", "__rust_start_panic"])?;
let panic_runtime = tcx.crate_name(tcx.injected_panic_runtime().expect("No panic runtime found!"));
let start_panic_instance = this.resolve_path(&[&*panic_runtime.as_str(), "__rust_start_panic"])?;
return Ok(Some(this.load_mir(start_panic_instance.def, None)?));
}
// Similarly, we forward calls to the `panic_impl` foreign item to its implementation.
Expand Down
7 changes: 0 additions & 7 deletions src/shims/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx

trace!("miri_start_panic: {:?}", this.frame().span);

if this.tcx.tcx.sess.panic_strategy() == PanicStrategy::Abort {
// FIXME: Add a better way of indicating 'abnormal' termination,
// since this is not really an 'unsupported' behavior
throw_unsup_format!("the evaluated program panicked");
}

// Get the raw pointer stored in arg[0] (the panic payload).
Aaron1011 marked this conversation as resolved.
Show resolved Hide resolved
let scalar = this.read_immediate(args[0])?;
assert!(this.machine.panic_payload.is_none(), "the panic runtime should avoid double-panics");
this.machine.panic_payload = Some(scalar);
Expand Down