Skip to content

Commit

Permalink
Fix bad rebase;
Browse files Browse the repository at this point in the history
  • Loading branch information
bnjbvr committed Mar 12, 2021
1 parent cf0e500 commit 7bbfb62
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 3 additions & 0 deletions crates/runtime/src/traphandlers/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 7 additions & 9 deletions crates/runtime/src/traphandlers/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ static mut PREV_SIGBUS: MaybeUninit<libc::sigaction> = MaybeUninit::uninit();
static mut PREV_SIGILL: MaybeUninit<libc::sigaction> = MaybeUninit::uninit();
static mut PREV_SIGFPE: MaybeUninit<libc::sigaction> = 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<libc::sigaction>, signal: i32| {
let mut handler: libc::sigaction = mem::zeroed();
// The flags here are relatively careful, and they are...
Expand Down Expand Up @@ -89,20 +85,22 @@ 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
// exception was handled by a custom exception handler, so we
// 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 {
Expand Down

0 comments on commit 7bbfb62

Please sign in to comment.