File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -537,7 +537,6 @@ void *mach_profile_listener(void *arg)
537
537
HANDLE_MACH_ERROR ("mach_msg" , ret );
538
538
// sample each thread, round-robin style in reverse order
539
539
// (so that thread zero gets notified last)
540
- jl_lock_profile ();
541
540
void * unused = NULL ;
542
541
int keymgr_locked = _keymgr_get_and_lock_processwide_ptr_2 (KEYMGR_GCC3_DW2_OBJ_LIST , & unused ) == 0 ;
543
542
jl_shuffle_int_array_inplace (profile_round_robin_thread_order , jl_n_threads , & profile_cong_rng_seed );
@@ -554,6 +553,10 @@ void *mach_profile_listener(void *arg)
554
553
jl_thread_suspend_and_get_state2 (i , & state );
555
554
unw_context_t * uc = (unw_context_t * )& state ;
556
555
556
+ // Taking profile lock after to avoid deadlock in case the i-th thread is
557
+ // trying to take the lock when signalled.
558
+ jl_lock_profile ();
559
+
557
560
if (running ) {
558
561
#ifdef LLVMLIBUNWIND
559
562
/*
@@ -606,12 +609,12 @@ void *mach_profile_listener(void *arg)
606
609
bt_data_prof [bt_size_cur ++ ].uintptr = 0 ;
607
610
bt_data_prof [bt_size_cur ++ ].uintptr = 0 ;
608
611
}
612
+ jl_unlock_profile ();
609
613
// We're done! Resume the thread.
610
614
jl_thread_resume (i , 0 );
611
615
}
612
616
if (keymgr_locked )
613
617
_keymgr_unlock_processwide_ptr (KEYMGR_GCC3_DW2_OBJ_LIST );
614
- jl_unlock_profile ();
615
618
if (running ) {
616
619
// Reset the alarm
617
620
kern_return_t ret = clock_alarm (clk , TIME_RELATIVE , timerprof , profile_port );
You can’t perform that action at this time.
0 commit comments