Skip to content

Commit

Permalink
Fix data race.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed Aug 10, 2023
1 parent 288eeaf commit 37ca3f9
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/signals-mach.c
Original file line number Diff line number Diff line change
@@ -385,12 +385,11 @@ static int jl_thread_suspend_and_get_state2(int tid, host_thread_state_t *ctx)
jl_ptls_t ptls2 = jl_atomic_load_relaxed(&jl_all_tls_states)[tid];
if (ptls2 == NULL) // this thread is not alive
return 0;
mach_port_t thread = pthread_mach_thread_np(jl_atomic_load_acquire(&ptls2->system_id));
jl_task_t *ct2 = ptls2 ? jl_atomic_load_relaxed(&ptls2->current_task) : NULL;
if (ct2 == NULL) // this thread is already dead
return 0;

mach_port_t thread = pthread_mach_thread_np(jl_atomic_load_relaxed(&ptls2->system_id));

kern_return_t ret = thread_suspend(thread);
HANDLE_MACH_ERROR("thread_suspend", ret);

2 changes: 1 addition & 1 deletion src/threading.c
Original file line number Diff line number Diff line change
@@ -475,7 +475,7 @@ static void jl_delete_thread(void *value) JL_NOTSAFEPOINT_ENTER
}
// mark this thread as dead
jl_atomic_store_relaxed(&ptls->current_task, NULL);
jl_atomic_store_relaxed(&ptls->system_id, 0);
jl_atomic_store_release(&ptls->system_id, 0);
// finally, release all of the locks we had grabbed
#ifdef _OS_WINDOWS_
jl_unlock_profile_wr();

0 comments on commit 37ca3f9

Please sign in to comment.