From 75c10e435b2b9c947422ad38fa0b020595d3f747 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Fri, 21 Jun 2019 13:18:20 -0400 Subject: [PATCH] fix bug in thread self-wakeup (#32382) --- src/partr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/partr.c b/src/partr.c index 734607bc38ae1..3ec703e845d55 100644 --- a/src/partr.c +++ b/src/partr.c @@ -343,10 +343,12 @@ static int sleep_check_after_threshold(uint64_t *start_cycles) /* ensure thread tid is awake if necessary */ JL_DLLEXPORT void jl_wakeup_thread(int16_t tid) { - int16_t self = jl_get_ptls_states()->tid; + jl_ptls_t ptls = jl_get_ptls_states(); + int16_t self = ptls->tid; int16_t uvlock = jl_atomic_load_acquire(&jl_uv_mutex.owner); if (tid == self) { // we're already awake, but make sure we'll exit uv_run + jl_atomic_store(&ptls->sleep_check_state, not_sleeping); if (uvlock == self) uv_stop(jl_global_event_loop()); }