summaryrefslogtreecommitdiff
path: root/rts/Capability.h
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-09-27 20:37:41 +0000
committerBen Gamari <ben@smart-cactus.org>2020-10-24 21:00:37 -0400
commitd079b9435382882b0b069ea40bcd287db18082d3 (patch)
tree5d956d0041fea0e1f058e00be6a8ca84b7d38adb /rts/Capability.h
parentf88710185acc0e02b334b96004f4b8fae38c5eb9 (diff)
downloadhaskell-d079b9435382882b0b069ea40bcd287db18082d3.tar.gz
rts: Avoid data races in message handling
Diffstat (limited to 'rts/Capability.h')
-rw-r--r--rts/Capability.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/rts/Capability.h b/rts/Capability.h
index 7eaffa0225..aab2d84ae7 100644
--- a/rts/Capability.h
+++ b/rts/Capability.h
@@ -482,8 +482,12 @@ contextSwitchCapability (Capability *cap)
INLINE_HEADER bool emptyInbox(Capability *cap)
{
- return (cap->inbox == (Message*)END_TSO_QUEUE &&
- cap->putMVars == NULL);
+ // This may race with writes to putMVars and inbox but this harmless for the
+ // intended uses of this function.
+ TSAN_ANNOTATE_BENIGN_RACE(&cap->putMVars, "emptyInbox(cap->putMVars)");
+ TSAN_ANNOTATE_BENIGN_RACE(&cap->inbox, "emptyInbox(cap->inbox)");
+ return (RELAXED_LOAD(&cap->inbox) == (Message*)END_TSO_QUEUE &&
+ RELAXED_LOAD(&cap->putMVars) == NULL);
}
#endif