Skip to content

Commit da7eec0

Browse files
Kenoantoine-levitt
authored andcommitted
Darwin/ARM64: Fix jl_throw_in_ctx (JuliaLang#39894)
Fixes incorrect SIGFPE handling causing crashes during the numbers test.
1 parent 7f216f6 commit da7eec0

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/signals-mach.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ static void jl_call_in_state(jl_ptls_t ptls2, host_thread_state_t *state,
171171
#else
172172
state->__sp = rsp;
173173
state->__pc = (uint64_t)fptr;
174+
state->__lr = 0;
174175
#endif
175176
}
176177

src/signals-unix.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,15 @@ static void jl_call_in_ctx(jl_ptls_t ptls, void (*fptr)(void), int sig, void *_c
163163
// `catch_exception_raise`. It works fine when a signal is received
164164
// due to `kill`/`raise` though.
165165
ucontext64_t *ctx = (ucontext64_t*)_ctx;
166+
#if defined(_CPU_X86_64_)
166167
rsp -= sizeof(void*);
167168
*(void**)rsp = NULL;
168-
#if defined(_CPU_X86_64_)
169169
ctx->uc_mcontext64->__ss.__rsp = rsp;
170170
ctx->uc_mcontext64->__ss.__rip = (uintptr_t)fptr;
171171
#else
172172
ctx->uc_mcontext64->__ss.__sp = rsp;
173173
ctx->uc_mcontext64->__ss.__pc = (uintptr_t)fptr;
174+
ctx->uc_mcontext64->__ss.__lr = 0;
174175
#endif
175176
#else
176177
#warning "julia: throw-in-context not supported on this platform"

0 commit comments

Comments
 (0)