From bb2abb5fd06f1815281bfe4da7c9f9e16ad8a0b0 Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Tue, 3 Sep 2024 16:32:48 -0300 Subject: [PATCH] Check if ct is not null before doing is_addr_on_stack in the macos signal handler. (#55603) Before the check we used to segfault while segfaulting and hang --------- Co-authored-by: Jameson Nash --- src/signals-mach.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/signals-mach.c b/src/signals-mach.c index c31b6d506b4e67..2f3e87ece296f8 100644 --- a/src/signals-mach.c +++ b/src/signals-mach.c @@ -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);