diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-09-27 20:37:41 +0000 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2020-10-24 21:00:37 -0400 |
commit | d079b9435382882b0b069ea40bcd287db18082d3 (patch) | |
tree | 5d956d0041fea0e1f058e00be6a8ca84b7d38adb /rts/Capability.h | |
parent | f88710185acc0e02b334b96004f4b8fae38c5eb9 (diff) | |
download | haskell-d079b9435382882b0b069ea40bcd287db18082d3.tar.gz |
rts: Avoid data races in message handling
Diffstat (limited to 'rts/Capability.h')
-rw-r--r-- | rts/Capability.h | 8 |
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 |