Skip to content

Commit

Permalink
Check if ct is not null before doing is_addr_on_stack in the macos si…
Browse files Browse the repository at this point in the history
…gnal handler. (#55603)

Before the check we used to segfault while segfaulting and hang

---------

Co-authored-by: Jameson Nash <[email protected]>
  • Loading branch information
2 people authored and KristofferC committed Sep 12, 2024
1 parent 641748b commit bb2abb5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/signals-mach.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,9 @@ static void segv_handler(int sig, siginfo_t *info, void *context)
return;
}
jl_task_t *ct = jl_get_current_task();
if ((sig != SIGBUS || info->si_code == BUS_ADRERR) && is_addr_on_stack(ct, info->si_addr)) { // stack overflow and not a BUS_ADRALN (alignment error)
if ((sig != SIGBUS || info->si_code == BUS_ADRERR) &&
!(ct == NULL || ct->ptls == NULL || jl_atomic_load_relaxed(&ct->ptls->gc_state) == JL_GC_STATE_WAITING || ct->eh == NULL)
&& is_addr_on_stack(ct, info->si_addr)) { // stack overflow and not a BUS_ADRALN (alignment error)
stack_overflow_warning();
}
sigdie_handler(sig, info, context);
Expand Down

0 comments on commit bb2abb5

Please sign in to comment.