[commit: ghc] ghc-7.10: Fix deadlock (#10545) (a6ef59c)
git at git.haskell.org
git at git.haskell.org
Fri Jun 26 19:25:54 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-7.10
Link : http://ghc.haskell.org/trac/ghc/changeset/a6ef59cdc1c2df3c4e4ff4dcdc929c3ea14864c2/ghc
>---------------------------------------------------------------
commit a6ef59cdc1c2df3c4e4ff4dcdc929c3ea14864c2
Author: Simon Marlow <marlowsd at gmail.com>
Date: Fri Jun 19 15:12:24 2015 +0100
Fix deadlock (#10545)
yieldCapability() was not prepared to be called by a Task that is not
either a worker or a bound Task. This could happen if we ended up in
yieldCapability via this call stack:
performGC()
scheduleDoGC()
requestSync()
yieldCapability()
and there were a few other ways this could happen via requestSync.
The fix is to handle this case in yieldCapability(): when the Task is
not a worker or a bound Task, we put it on the returning_workers
queue, where it will be woken up again.
Summary of changes:
* `yieldCapability`: factored out subroutine waitForWorkerCapability`
* `waitForReturnCapability` renamed to `waitForCapability`, and
factored out subroutine `waitForReturnCapability`
* `releaseCapabilityAndQueue` worker renamed to `enqueueWorker`, does
not take a lock and no longer tests if `!isBoundTask()`
* `yieldCapability` adjusted for refactorings, only change in behavior
is when it is not a worker or bound task.
Test Plan:
* new test concurrent/should_run/performGC
* validate
Reviewers: niteria, austin, ezyang, bgamari
Subscribers: thomie, bgamari
Differential Revision: https://phabricator.haskell.org/D997
GHC Trac Issues: #10545
(cherry picked from commit 111ba4beda4ffc48381723da12e5b237d7f9ac59)
>---------------------------------------------------------------
a6ef59cdc1c2df3c4e4ff4dcdc929c3ea14864c2
rts/Capability.c | 301 +++++++----
rts/Capability.h | 8 +-
rts/RtsAPI.c | 2 +-
rts/Schedule.c | 14 +-
rts/Task.h | 11 +
testsuite/tests/concurrent/should_run/RandomPGC.hs | 597 +++++++++++++++++++++
testsuite/tests/concurrent/should_run/all.T | 4 +
testsuite/tests/concurrent/should_run/performGC.hs | 24 +
.../tests/concurrent/should_run/performGC.stdout | 400 ++++++++++++++
9 files changed, 1231 insertions(+), 130 deletions(-)
Diff suppressed because of size. To see it, use:
git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc a6ef59cdc1c2df3c4e4ff4dcdc929c3ea14864c2
More information about the ghc-commits
mailing list