summaryrefslogtreecommitdiff
path: root/rts/Capability.c
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-10-03 15:25:01 +0000
committerBen Gamari <ben@smart-cactus.org>2020-10-24 21:00:37 -0400
commit811f915db3b682f33aad2c3e6ca039a6e8451c69 (patch)
tree5ef0ba1eff5a641c108e6443fb3fa87d80f05e56 /rts/Capability.c
parent855325cdcad4c10e0f37c10934a62a07c6ec48b2 (diff)
downloadhaskell-811f915db3b682f33aad2c3e6ca039a6e8451c69.tar.gz
rts: Accept data race in work-stealing implementation
This race is okay since the task is owned by the capability pushing it. By Note [Ownership of Task] this means that the capability is free to write to `task->cap` without taking `task->lock`. Fixes #17276.
Diffstat (limited to 'rts/Capability.c')
-rw-r--r--rts/Capability.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/rts/Capability.c b/rts/Capability.c
index 2fe54f2889..0b5f009800 100644
--- a/rts/Capability.c
+++ b/rts/Capability.c
@@ -660,6 +660,9 @@ static Capability * waitForWorkerCapability (Task *task)
ACQUIRE_LOCK(&task->lock);
// task->lock held, cap->lock not held
if (!task->wakeup) waitCondition(&task->cond, &task->lock);
+ // The happens-after matches the happens-before in
+ // schedulePushWork, which does owns 'task' when it sets 'task->cap'.
+ TSAN_ANNOTATE_HAPPENS_AFTER(&task->cap);
cap = task->cap;
task->wakeup = false;
RELEASE_LOCK(&task->lock);