Skip to content

Commit 4fa9363

Browse files
committed
Auto merge of #1812 - hyd-dev:85546, r=RalfJung
Fix toolstate for rust-lang/rust#85546 cc rust-lang/rust#85780
2 parents 76f5855 + 9b2d425 commit 4fa9363

File tree

7 files changed

+28
-20
lines changed

7 files changed

+28
-20
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0f8cd43ee8c3614e04b5c624dd8a45758d7023da
1+
ce0d64e03ef9875e0935bb60e989542b7ec29579

src/machine.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
356356
abi: Abi,
357357
args: &[OpTy<'tcx, Tag>],
358358
ret: Option<(&PlaceTy<'tcx, Tag>, mir::BasicBlock)>,
359-
unwind: Option<mir::BasicBlock>,
359+
unwind: StackPopUnwind,
360360
) -> InterpResult<'tcx, Option<&'mir mir::Body<'tcx>>> {
361361
ecx.find_mir_or_eval_fn(instance, abi, args, ret, unwind)
362362
}
@@ -368,7 +368,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
368368
abi: Abi,
369369
args: &[OpTy<'tcx, Tag>],
370370
ret: Option<(&PlaceTy<'tcx, Tag>, mir::BasicBlock)>,
371-
_unwind: Option<mir::BasicBlock>,
371+
_unwind: StackPopUnwind,
372372
) -> InterpResult<'tcx> {
373373
ecx.call_dlsym(fn_val, abi, args, ret)
374374
}
@@ -379,7 +379,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
379379
instance: ty::Instance<'tcx>,
380380
args: &[OpTy<'tcx, Tag>],
381381
ret: Option<(&PlaceTy<'tcx, Tag>, mir::BasicBlock)>,
382-
unwind: Option<mir::BasicBlock>,
382+
unwind: StackPopUnwind,
383383
) -> InterpResult<'tcx> {
384384
ecx.call_intrinsic(instance, args, ret, unwind)
385385
}

src/shims/foreign_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
120120
abi: Abi,
121121
args: &[OpTy<'tcx, Tag>],
122122
ret: Option<(&PlaceTy<'tcx, Tag>, mir::BasicBlock)>,
123-
unwind: Option<mir::BasicBlock>,
123+
unwind: StackPopUnwind,
124124
) -> InterpResult<'tcx, Option<&'mir mir::Body<'tcx>>> {
125125
let this = self.eval_context_mut();
126126
let attrs = this.tcx.get_attrs(def_id);

src/shims/intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
2323
instance: ty::Instance<'tcx>,
2424
args: &[OpTy<'tcx, Tag>],
2525
ret: Option<(&PlaceTy<'tcx, Tag>, mir::BasicBlock)>,
26-
_unwind: Option<mir::BasicBlock>,
26+
_unwind: StackPopUnwind,
2727
) -> InterpResult<'tcx> {
2828
let this = self.eval_context_mut();
2929

src/shims/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
2929
abi: Abi,
3030
args: &[OpTy<'tcx, Tag>],
3131
ret: Option<(&PlaceTy<'tcx, Tag>, mir::BasicBlock)>,
32-
unwind: Option<mir::BasicBlock>,
32+
unwind: StackPopUnwind,
3333
) -> InterpResult<'tcx, Option<&'mir mir::Body<'tcx>>> {
3434
let this = self.eval_context_mut();
3535
trace!("eval_fn_call: {:#?}, {:?}", instance, ret.map(|p| p.0));
@@ -64,7 +64,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
6464
ptr_op: &OpTy<'tcx, Tag>,
6565
align_op: &OpTy<'tcx, Tag>,
6666
ret: Option<(&PlaceTy<'tcx, Tag>, mir::BasicBlock)>,
67-
unwind: Option<mir::BasicBlock>,
67+
unwind: StackPopUnwind,
6868
) -> InterpResult<'tcx, bool> {
6969
let this = self.eval_context_mut();
7070
let (dest, ret) = ret.unwrap();

src/shims/panic.rs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
4141
fn handle_miri_start_panic(
4242
&mut self,
4343
args: &[OpTy<'tcx, Tag>],
44-
unwind: Option<mir::BasicBlock>,
44+
unwind: StackPopUnwind,
4545
) -> InterpResult<'tcx> {
4646
let this = self.eval_context_mut();
4747

4848
trace!("miri_start_panic: {:?}", this.frame().instance);
49-
// Make sure we only start unwinding when this matches our panic strategy.
50-
if this.tcx.sess.panic_strategy() != PanicStrategy::Unwind {
51-
throw_ub_format!("unwinding despite panic=abort");
52-
}
5349

5450
// Get the raw pointer stored in arg[0] (the panic payload).
5551
let &[ref payload] = check_arg_count(args)?;
@@ -59,7 +55,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
5955
thread.panic_payload = Some(payload);
6056

6157
// Jump to the unwind block to begin unwinding.
62-
this.unwind_to_block(unwind);
58+
this.unwind_to_block(unwind)?;
6359
return Ok(());
6460
}
6561

@@ -99,7 +95,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
9995
&[data.into()],
10096
Some(&ret_place),
10197
// Directly return to caller.
102-
StackPopCleanup::Goto { ret: Some(ret), unwind: None },
98+
StackPopCleanup::Goto { ret: Some(ret), unwind: StackPopUnwind::Skip },
10399
)?;
104100

105101
// We ourselves will return `0`, eventually (will be overwritten if we catch a panic).
@@ -155,7 +151,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
155151
&[catch_unwind.data.into(), payload.into()],
156152
Some(&ret_place),
157153
// Directly return to caller of `try`.
158-
StackPopCleanup::Goto { ret: Some(catch_unwind.ret), unwind: None },
154+
StackPopCleanup::Goto { ret: Some(catch_unwind.ret), unwind: StackPopUnwind::Skip },
159155
)?;
160156

161157
// We pushed a new stack frame, the engine should not do any jumping now!
@@ -166,7 +162,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
166162
}
167163

168164
/// Starta a panic in the interpreter with the given message as payload.
169-
fn start_panic(&mut self, msg: &str, unwind: Option<mir::BasicBlock>) -> InterpResult<'tcx> {
165+
fn start_panic(&mut self, msg: &str, unwind: StackPopUnwind) -> InterpResult<'tcx> {
170166
let this = self.eval_context_mut();
171167

172168
// First arg: message.
@@ -209,12 +205,24 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
209205
Abi::Rust,
210206
&[index.into(), len.into()],
211207
None,
212-
StackPopCleanup::Goto { ret: None, unwind },
208+
StackPopCleanup::Goto {
209+
ret: None,
210+
unwind: match unwind {
211+
Some(cleanup) => StackPopUnwind::Cleanup(cleanup),
212+
None => StackPopUnwind::Skip,
213+
},
214+
},
213215
)?;
214216
}
215217
_ => {
216218
// Forward everything else to `panic` lang item.
217-
this.start_panic(msg.description(), unwind)?;
219+
this.start_panic(
220+
msg.description(),
221+
match unwind {
222+
Some(cleanup) => StackPopUnwind::Cleanup(cleanup),
223+
None => StackPopUnwind::Skip,
224+
},
225+
)?;
218226
}
219227
}
220228
Ok(())

tests/compile-fail/panic/unwind_panic_abort.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ extern "Rust" {
77
}
88

99
fn main() {
10-
unsafe { miri_start_panic(&mut 0); } //~ ERROR unwinding despite panic=abort
10+
unsafe { miri_start_panic(&mut 0); } //~ ERROR unwinding past a stack frame that does not allow unwinding
1111
}

0 commit comments

Comments
 (0)