[commit: ghc] wip/merge-queue: itimer: Don't free condvar until we know ticker is stopped (688956a)
git at git.haskell.org
git at git.haskell.org
Sun Jan 13 00:06:24 UTC 2019
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/merge-queue
Link : http://ghc.haskell.org/trac/ghc/changeset/688956a33fafa00cae869fa6f8df6c98448598e0/ghc
>---------------------------------------------------------------
commit 688956a33fafa00cae869fa6f8df6c98448598e0
Author: Ben Gamari <ben at smart-cactus.org>
Date: Wed Jan 9 00:20:19 2019 -0500
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.
>---------------------------------------------------------------
688956a33fafa00cae869fa6f8df6c98448598e0
rts/posix/itimer/Pthread.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/rts/posix/itimer/Pthread.c b/rts/posix/itimer/Pthread.c
index d8f2497..817c40f 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);
}
More information about the ghc-commits
mailing list