summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-01-09 00:20:19 -0500
committerBen Gamari <ben@well-typed.com>2019-01-14 09:30:40 -0500
commit7b12b3f0240321ac1ee43f14eb9c07e015022eeb (patch)
treec9e64a4f36784bfd0dd091471f47cf442d34fdb2 /rts
parent4ad9ffd3897924313fb509515c60b4f09429e5cf (diff)
downloadhaskell-7b12b3f0240321ac1ee43f14eb9c07e015022eeb.tar.gz
itimer: Don't free condvar until we know ticker is stopped
When we are shutting down the pthread ticker we signal the start_cond condition variable to ensure that the ticker thread wakes up and exits in a reasonable amount of time. Previously, when the ticker thread would shut down it was responsible for freeing the start_cond condition variable. However, this would lead to a race wherein the ticker would free start_cond, then the main thread would try to signal it in an effort to wake the ticker (#16150). Avoid this by moving the mutex destruction to the main thread.
Diffstat (limited to 'rts')
-rw-r--r--rts/posix/itimer/Pthread.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/rts/posix/itimer/Pthread.c b/rts/posix/itimer/Pthread.c
index d8f2497e3f..817c40f218 100644
--- a/rts/posix/itimer/Pthread.c
+++ b/rts/posix/itimer/Pthread.c
@@ -147,8 +147,6 @@ static void *itimer_thread_func(void *_handle_tick)
if (USE_TIMERFD_FOR_ITIMER)
close(timerfd);
- closeMutex(&mutex);
- closeCondition(&start_cond);
return NULL;
}
@@ -207,6 +205,8 @@ exitTicker (bool wait)
if (pthread_join(thread, NULL)) {
sysErrorBelch("Itimer: Failed to join");
}
+ closeMutex(&mutex);
+ closeCondition(&start_cond);
} else {
pthread_detach(thread);
}