Skip to content

Commit

Permalink
Darwin/ARM64: Fix jl_throw_in_ctx (#39894)
Browse files Browse the repository at this point in the history
Fixes incorrect SIGFPE handling causing crashes during the numbers
test.
  • Loading branch information
Keno authored Mar 3, 2021
1 parent c0f9666 commit 79d7683
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/signals-mach.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ static void jl_call_in_state(jl_ptls_t ptls2, host_thread_state_t *state,
#else
state->__sp = rsp;
state->__pc = (uint64_t)fptr;
state->__lr = 0;
#endif
}

Expand Down
3 changes: 2 additions & 1 deletion src/signals-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,15 @@ static void jl_call_in_ctx(jl_ptls_t ptls, void (*fptr)(void), int sig, void *_c
// `catch_exception_raise`. It works fine when a signal is received
// due to `kill`/`raise` though.
ucontext64_t *ctx = (ucontext64_t*)_ctx;
#if defined(_CPU_X86_64_)
rsp -= sizeof(void*);
*(void**)rsp = NULL;
#if defined(_CPU_X86_64_)
ctx->uc_mcontext64->__ss.__rsp = rsp;
ctx->uc_mcontext64->__ss.__rip = (uintptr_t)fptr;
#else
ctx->uc_mcontext64->__ss.__sp = rsp;
ctx->uc_mcontext64->__ss.__pc = (uintptr_t)fptr;
ctx->uc_mcontext64->__ss.__lr = 0;
#endif
#else
#warning "julia: throw-in-context not supported on this platform"
Expand Down

0 comments on commit 79d7683

Please sign in to comment.