summaryrefslogtreecommitdiff
path: root/rts/RtsStartup.c
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2016-05-01 17:41:05 +0200
committerBen Gamari <ben@smart-cactus.org>2016-05-01 23:29:49 +0200
commit999c464da36e925bd4ffea34c94d3a7b3ab0135c (patch)
tree976d71ceaceb4a72ee40840c1ea7b170e6579a4d /rts/RtsStartup.c
parent55f4009ed610ed236f306bff0c33b0efc5a99e48 (diff)
downloadhaskell-999c464da36e925bd4ffea34c94d3a7b3ab0135c.tar.gz
rts/itimer/pthread: Stop timer when ticker is stopped
This reworks the pthread-based itimer implementation to disarm the timer when events aren't needed. Thanks to hsyl20 for the nice design. Test Plan: Validate Reviewers: hsyl20, simonmar, austin Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2131 GHC Trac Issues: #1623, #11965
Diffstat (limited to 'rts/RtsStartup.c')
-rw-r--r--rts/RtsStartup.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c
index 4b9d9471ee..6d774f4735 100644
--- a/rts/RtsStartup.c
+++ b/rts/RtsStartup.c
@@ -340,7 +340,12 @@ hs_exit_(rtsBool wait_foreign)
/* stop the ticker */
stopTimer();
- exitTimer(wait_foreign);
+ /*
+ * it is quite important that we wait here as some timer implementations
+ * (e.g. pthread) may fire even after we exit, which may segfault as we've
+ * already freed the capabilities.
+ */
+ exitTimer(rtsTrue);
// set the terminal settings back to what they were
#if !defined(mingw32_HOST_OS)