@@ -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 ( ( ) )
0 commit comments