@@ -41,15 +41,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
41
41
fn handle_miri_start_panic (
42
42
& mut self ,
43
43
args : & [ OpTy < ' tcx , Tag > ] ,
44
- unwind : Option < mir :: BasicBlock > ,
44
+ unwind : StackPopUnwind ,
45
45
) -> InterpResult < ' tcx > {
46
46
let this = self . eval_context_mut ( ) ;
47
47
48
48
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
- }
53
49
54
50
// Get the raw pointer stored in arg[0] (the panic payload).
55
51
let & [ ref payload] = check_arg_count ( args) ?;
@@ -59,7 +55,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
59
55
thread. panic_payload = Some ( payload) ;
60
56
61
57
// Jump to the unwind block to begin unwinding.
62
- this. unwind_to_block ( unwind) ;
58
+ this. unwind_to_block ( unwind) ? ;
63
59
return Ok ( ( ) ) ;
64
60
}
65
61
@@ -99,7 +95,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
99
95
& [ data. into ( ) ] ,
100
96
Some ( & ret_place) ,
101
97
// Directly return to caller.
102
- StackPopCleanup :: Goto { ret : Some ( ret) , unwind : None } ,
98
+ StackPopCleanup :: Goto { ret : Some ( ret) , unwind : StackPopUnwind :: Skip } ,
103
99
) ?;
104
100
105
101
// 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
155
151
& [ catch_unwind. data . into ( ) , payload. into ( ) ] ,
156
152
Some ( & ret_place) ,
157
153
// 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 } ,
159
155
) ?;
160
156
161
157
// 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
166
162
}
167
163
168
164
/// 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 > {
170
166
let this = self . eval_context_mut ( ) ;
171
167
172
168
// First arg: message.
@@ -209,12 +205,24 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
209
205
Abi :: Rust ,
210
206
& [ index. into ( ) , len. into ( ) ] ,
211
207
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
+ } ,
213
215
) ?;
214
216
}
215
217
_ => {
216
218
// 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
+ ) ?;
218
226
}
219
227
}
220
228
Ok ( ( ) )
0 commit comments