diff --git a/src/signals-mach.c b/src/signals-mach.c index 2b1da43b71f63..8ac7e5301d7ad 100644 --- a/src/signals-mach.c +++ b/src/signals-mach.c @@ -276,12 +276,16 @@ kern_return_t catch_mach_exception_raise( int nthreads = jl_atomic_load_acquire(&jl_n_threads); for (tid = 0; tid < nthreads; tid++) { jl_ptls_t _ptls2 = jl_atomic_load_relaxed(&jl_all_tls_states)[tid]; + if (jl_atomic_load_relaxed(&_ptls2->current_task) == NULL) { + // this thread is dead + continue; + } if (pthread_mach_thread_np(_ptls2->system_id) == thread) { ptls2 = _ptls2; break; } } - if (!ptls2 || ptls2->current_task == NULL) { + if (!ptls2) { // We don't know about this thread, let the kernel try another handler // instead. This shouldn't actually happen since we only register the // handler for the threads we know about.