File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -750,7 +750,6 @@ static void *signal_listener(void *arg)
750
750
// sample each thread, round-robin style in reverse order
751
751
// (so that thread zero gets notified last)
752
752
if (critical || profile ) {
753
- jl_lock_profile ();
754
753
if (!critical )
755
754
jl_shuffle_int_array_inplace (profile_round_robin_thread_order , jl_n_threads , & profile_cong_rng_seed );
756
755
for (int idx = jl_n_threads ; idx -- > 0 ; ) {
@@ -759,6 +758,10 @@ static void *signal_listener(void *arg)
759
758
// notify thread to stop
760
759
jl_thread_suspend_and_get_state (i , & signal_context );
761
760
761
+ // Taking profile lock after to avoid deadlock in case the i-th thread is
762
+ // trying to take the lock when signalled.
763
+ jl_lock_profile ();
764
+
762
765
// do backtrace on thread contexts for critical signals
763
766
// this part must be signal-handler safe
764
767
if (critical ) {
@@ -810,10 +813,11 @@ static void *signal_listener(void *arg)
810
813
}
811
814
}
812
815
816
+ jl_unlock_profile ();
817
+
813
818
// notify thread to resume
814
819
jl_thread_resume (i , sig );
815
820
}
816
- jl_unlock_profile ();
817
821
}
818
822
#ifndef HAVE_MACH
819
823
if (profile && running ) {
You can’t perform that action at this time.
0 commit comments