summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-10-01 01:31:15 +0000
committerBen Gamari <ben@smart-cactus.org>2020-10-24 21:01:33 -0400
commit8f802f386ad5774a863f756f2d8d397903074700 (patch)
treef36d8d1b9d61059672aaa89b7fffa790389862a8 /rts
parentd39bbd3dbd569d60c7f27f68a1f30885a30c3fa3 (diff)
downloadhaskell-8f802f386ad5774a863f756f2d8d397903074700.tar.gz
rts: Avoid lock order inversion during fork
Fixes #17275.
Diffstat (limited to 'rts')
-rw-r--r--rts/Schedule.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/rts/Schedule.c b/rts/Schedule.c
index 41d0dba953..88a0278191 100644
--- a/rts/Schedule.c
+++ b/rts/Schedule.c
@@ -2027,12 +2027,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