From df8b691c1cc3be3dc73665e88ab97da363cbd4fa Mon Sep 17 00:00:00 2001 From: Gabriel Baraldi Date: Thu, 20 Apr 2023 13:43:37 -0300 Subject: [PATCH] Fix dyld lock not getting unlocked on invalid threads. --- src/signals-mach.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/signals-mach.c b/src/signals-mach.c index 2bb26976b0d61..13f5f6923cec3 100644 --- a/src/signals-mach.c +++ b/src/signals-mach.c @@ -614,12 +614,12 @@ void *mach_profile_listener(void *arg) if (_dyld_atfork_prepare != NULL && _dyld_atfork_parent != NULL) _dyld_atfork_prepare(); // briefly acquire the dlsym lock host_thread_state_t state; - if (!jl_thread_suspend_and_get_state2(i, &state)) - continue; + int valid_thread = jl_thread_suspend_and_get_state2(i, &state); unw_context_t *uc = (unw_context_t*)&state; if (_dyld_atfork_prepare != NULL && _dyld_atfork_parent != NULL) _dyld_atfork_parent(); // quickly release the dlsym lock - + if (!valid_thread) + continue; if (running) { #ifdef LLVMLIBUNWIND /*