diff --git a/src/unwinder/frame.rs b/src/unwinder/frame.rs index 0053899..8659bfe 100644 --- a/src/unwinder/frame.rs +++ b/src/unwinder/frame.rs @@ -125,6 +125,11 @@ impl Frame { Err(gimli::Error::UnsupportedEvaluation) } + pub fn adjust_stack_for_args(&self, ctx: &mut Context) { + let size = self.row.saved_args_size(); + ctx[Arch::SP] = ctx[Arch::SP].wrapping_add(size as usize); + } + pub fn unwind(&self, ctx: &Context) -> Result { let row = &self.row; let mut new_ctx = ctx.clone(); diff --git a/src/unwinder/mod.rs b/src/unwinder/mod.rs index 3309f47..968566b 100644 --- a/src/unwinder/mod.rs +++ b/src/unwinder/mod.rs @@ -229,7 +229,10 @@ fn raise_exception_phase2( match code { UnwindReasonCode::CONTINUE_UNWIND => (), - UnwindReasonCode::INSTALL_CONTEXT => break, + UnwindReasonCode::INSTALL_CONTEXT => { + frame.adjust_stack_for_args(ctx); + return UnwindReasonCode::INSTALL_CONTEXT; + } _ => return UnwindReasonCode::FATAL_PHASE2_ERROR, } } @@ -240,8 +243,6 @@ fn raise_exception_phase2( return UnwindReasonCode::FATAL_PHASE2_ERROR; } } - - UnwindReasonCode::INSTALL_CONTEXT } #[inline(never)] @@ -312,7 +313,10 @@ fn force_unwind_phase2( match code { UnwindReasonCode::CONTINUE_UNWIND => (), - UnwindReasonCode::INSTALL_CONTEXT => break, + UnwindReasonCode::INSTALL_CONTEXT => { + frame.adjust_stack_for_args(ctx); + return UnwindReasonCode::INSTALL_CONTEXT; + } _ => return UnwindReasonCode::FATAL_PHASE2_ERROR, } } @@ -323,8 +327,6 @@ fn force_unwind_phase2( return UnwindReasonCode::END_OF_STACK; } } - - UnwindReasonCode::INSTALL_CONTEXT } #[inline(never)]