diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-10-01 22:23:03 +0000 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2020-10-24 21:02:22 -0400 |
commit | 5a98dfcae41b79bed912521d1eeb2cbc09f0742b (patch) | |
tree | e99bd78db1ae6b06359073f29073f6cb96577da6 /rts/Schedule.c | |
parent | c7c3f8aa978dd6230e3b0f2d21dec84a47bd5e7c (diff) | |
download | haskell-5a98dfcae41b79bed912521d1eeb2cbc09f0742b.tar.gz |
rts: Pause timer while changing capability count
This avoids #17289.
Diffstat (limited to 'rts/Schedule.c')
-rw-r--r-- | rts/Schedule.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/rts/Schedule.c b/rts/Schedule.c index 41d0dba953..3f04eb2af1 100644 --- a/rts/Schedule.c +++ b/rts/Schedule.c @@ -2236,6 +2236,12 @@ setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS) cap = rts_lock(); task = cap->running_task; + + // N.B. We must stop the interval timer while we are changing the + // capabilities array lest handle_tick may try to context switch + // an old capability. See #17289. + stopTimer(); + stopAllCapabilities(&cap, task); if (new_n_capabilities < enabled_capabilities) @@ -2318,6 +2324,8 @@ setNumCapabilities (uint32_t new_n_capabilities USED_IF_THREADS) // Notify IO manager that the number of capabilities has changed. rts_evalIO(&cap, ioManagerCapabilitiesChanged_closure, NULL); + startTimer(); + rts_unlock(cap); #endif // THREADED_RTS |