summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-10-01 01:31:15 +0000
committerBen Gamari <ben@well-typed.com>2020-12-01 12:48:54 -0500
commit211af4a11c325dc93821d31a0acae3d909d2a8f1 (patch)
tree0e6122c33e70c2a2214b1eb2248cc18ecdeed647
parentf9ed0fd23dca0515c4281e7a0d8c8ae1ee4af46f (diff)
downloadhaskell-211af4a11c325dc93821d31a0acae3d909d2a8f1.tar.gz
rts: Avoid lock order inversion during fork
Fixes #17275.
-rw-r--r--rts/Schedule.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/rts/Schedule.c b/rts/Schedule.c
index 206c7b4cb6..f97777927a 100644
--- a/rts/Schedule.c
+++ b/rts/Schedule.c
@@ -2018,12 +2018,14 @@ forkProcess(HsStablePtr *entry
ACQUIRE_LOCK(&sm_mutex);
ACQUIRE_LOCK(&stable_ptr_mutex);
ACQUIRE_LOCK(&stable_name_mutex);
- ACQUIRE_LOCK(&task->lock);
for (i=0; i < n_capabilities; i++) {
ACQUIRE_LOCK(&capabilities[i]->lock);
}
+ // Take task lock after capability lock to avoid order inversion (#17275).
+ ACQUIRE_LOCK(&task->lock);
+
#if defined(THREADED_RTS)
ACQUIRE_LOCK(&all_tasks_mutex);
#endif