From 7bbfb62c5bc19bbaac98d04e5e49b210e7aa997a Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Fri, 12 Mar 2021 18:54:28 +0100 Subject: [PATCH] Fix bad rebase; --- crates/runtime/src/traphandlers/macos.rs | 3 +++ crates/runtime/src/traphandlers/unix.rs | 16 +++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/crates/runtime/src/traphandlers/macos.rs b/crates/runtime/src/traphandlers/macos.rs index bb4430ebf3f1..2720b2e4f4e6 100644 --- a/crates/runtime/src/traphandlers/macos.rs +++ b/crates/runtime/src/traphandlers/macos.rs @@ -306,6 +306,9 @@ unsafe fn handle_exception(request: &mut ExceptionRequest) -> bool { if jmp_buf.is_null() { return false; } + if jmp_buf as usize == 1 { + return false; + } // We have determined that this is a wasm trap and we need to actually // force the thread itself to trap. The thread's register state is diff --git a/crates/runtime/src/traphandlers/unix.rs b/crates/runtime/src/traphandlers/unix.rs index ccd3be177040..a97976f9caa2 100644 --- a/crates/runtime/src/traphandlers/unix.rs +++ b/crates/runtime/src/traphandlers/unix.rs @@ -14,11 +14,7 @@ static mut PREV_SIGBUS: MaybeUninit = MaybeUninit::uninit(); static mut PREV_SIGILL: MaybeUninit = MaybeUninit::uninit(); static mut PREV_SIGFPE: MaybeUninit = MaybeUninit::uninit(); -/// Function which may handle custom signals while processing traps. -pub type SignalHandler<'a> = - dyn Fn(libc::c_int, *const libc::siginfo_t, *const libc::c_void) -> bool + 'a; - -unsafe fn platform_init() { +pub unsafe fn platform_init() { let register = |slot: &mut MaybeUninit, signal: i32| { let mut handler: libc::sigaction = mem::zeroed(); // The flags here are relatively careful, and they are... @@ -89,8 +85,9 @@ unsafe extern "C" fn trap_handler( // Otherwise flag ourselves as handling a trap, do the trap // handling, and reset our trap handling flag. Then we figure // out what to do based on the result of the trap handling. + let pc = get_pc(context); let jmp_buf = - info.handle_trap(get_pc(context), |handler| handler(signum, siginfo, context)); + info.jmp_buf_if_trap(pc, |handler| handler(signum, siginfo, context)); // Figure out what to do based on the result of this handling of // the trap. Note that our sentinel value of 1 means that the @@ -98,11 +95,12 @@ unsafe extern "C" fn trap_handler( // keep executing. if jmp_buf.is_null() { return false; - } else if jmp_buf as usize == 1 { + } + if jmp_buf as usize == 1 { return true; - } else { - Unwind(jmp_buf) } + info.capture_backtrace(pc); + Unwind(jmp_buf) }); if handled {