Skip to content

Commit 986d8ed

Browse files
committed
Move the land outside of unwind_tracer
So that we cleanup the DwarfUnwinder.
1 parent 33720f2 commit 986d8ed

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

unwind/src/libunwind_shim.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ type PersonalityRoutine = extern "C" fn(version: c_int, actions: c_int, class: u
5858
// it never needs any cleanup. Currently this is not true.
5959
#[no_mangle]
6060
pub unsafe extern "C" fn _Unwind_Resume(exception: *mut _Unwind_Exception) -> ! {
61-
::glue::registers(|registers| unwind_tracer(registers, exception));
61+
::glue::registers(|registers| {
62+
if let Some(registers) = unwind_tracer(registers, exception) {
63+
::glue::land(&registers);
64+
}
65+
});
6266
unreachable!();
6367
}
6468

@@ -120,11 +124,15 @@ pub unsafe extern "C" fn _Unwind_FindEnclosingFunction(pc: *mut c_void) -> *mut
120124
#[no_mangle]
121125
pub unsafe extern "C" fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code {
122126
(*exception).private_contptr = None;
123-
::glue::registers(|registers| unwind_tracer(registers, exception));
127+
::glue::registers(|registers| {
128+
if let Some(registers) = unwind_tracer(registers, exception) {
129+
::glue::land(&registers);
130+
}
131+
});
124132
unreachable!();
125133
}
126134

127-
unsafe fn unwind_tracer(registers: Registers, exception: *mut _Unwind_Exception) {
135+
unsafe fn unwind_tracer(registers: Registers, exception: *mut _Unwind_Exception) -> Option<Registers> {
128136
let mut unwinder = DwarfUnwinder::default();
129137
let mut frames = StackFrames::new(&mut unwinder, registers);
130138

@@ -135,7 +143,7 @@ unsafe fn unwind_tracer(registers: Registers, exception: *mut _Unwind_Exception)
135143
break;
136144
}
137145
} else {
138-
return;
146+
return None;
139147
}
140148
}
141149
}
@@ -158,11 +166,12 @@ unsafe fn unwind_tracer(registers: Registers, exception: *mut _Unwind_Exception)
158166
match personality(1, _Unwind_Action::_UA_CLEANUP_PHASE as c_int, (*exception).exception_class,
159167
exception, &mut ctx) {
160168
_Unwind_Reason_Code::_URC_CONTINUE_UNWIND => (),
161-
_Unwind_Reason_Code::_URC_INSTALL_CONTEXT => ::glue::land(frames.registers()),
169+
_Unwind_Reason_Code::_URC_INSTALL_CONTEXT => return Some(frames.registers),
162170
x => panic!("wtf reason code {:?}", x),
163171
}
164172
}
165173
}
174+
None
166175
}
167176

168177
#[no_mangle]

0 commit comments

Comments
 (0)