diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-10-03 15:25:01 +0000 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2020-10-24 21:00:37 -0400 |
commit | 811f915db3b682f33aad2c3e6ca039a6e8451c69 (patch) | |
tree | 5ef0ba1eff5a641c108e6443fb3fa87d80f05e56 /rts/Capability.c | |
parent | 855325cdcad4c10e0f37c10934a62a07c6ec48b2 (diff) | |
download | haskell-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.c | 3 |
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); |