@@ -51,7 +51,7 @@ pub enum EHAction {
51
51
52
52
pub const USING_SJLJ_EXCEPTIONS : bool = cfg ! ( all( target_os = "ios" , target_arch = "arm" ) ) ;
53
53
54
- pub unsafe fn find_eh_action ( lsda : * const u8 , context : & EHContext < ' _ > )
54
+ pub unsafe fn find_eh_action ( lsda : * const u8 , context : & EHContext < ' _ > , foreign_exception : bool )
55
55
-> Result < EHAction , ( ) >
56
56
{
57
57
if lsda. is_null ( ) {
@@ -96,7 +96,7 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext<'_>)
96
96
return Ok ( EHAction :: None )
97
97
} else {
98
98
let lpad = lpad_base + cs_lpad;
99
- return Ok ( interpret_cs_action ( cs_action, lpad) )
99
+ return Ok ( interpret_cs_action ( cs_action, lpad, foreign_exception ) )
100
100
}
101
101
}
102
102
}
@@ -121,16 +121,23 @@ pub unsafe fn find_eh_action(lsda: *const u8, context: &EHContext<'_>)
121
121
// Can never have null landing pad for sjlj -- that would have
122
122
// been indicated by a -1 call site index.
123
123
let lpad = ( cs_lpad + 1 ) as usize ;
124
- return Ok ( interpret_cs_action ( cs_action, lpad) )
124
+ return Ok ( interpret_cs_action ( cs_action, lpad, foreign_exception ) )
125
125
}
126
126
}
127
127
}
128
128
}
129
129
130
- fn interpret_cs_action ( cs_action : u64 , lpad : usize ) -> EHAction {
130
+ fn interpret_cs_action ( cs_action : u64 , lpad : usize , foreign_exception : bool ) -> EHAction {
131
131
if cs_action == 0 {
132
+ // If cs_action is 0 then this is a cleanup (Drop::drop). We run these
133
+ // for both Rust panics and foriegn exceptions.
132
134
EHAction :: Cleanup ( lpad)
135
+ } else if foreign_exception {
136
+ // catch_unwind should not catch foreign exceptions, only Rust panics.
137
+ // Instead just continue unwinding.
138
+ EHAction :: None
133
139
} else {
140
+ // Stop unwinding Rust panics at catch_unwind.
134
141
EHAction :: Catch ( lpad)
135
142
}
136
143
}
0 commit comments