summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-10-24 10:48:19 -0400
committerBen Gamari <ben@smart-cactus.org>2020-11-08 09:40:53 -0500
commit6c3c646c8ae08c70f25f6c0bc658cda28800fffa (patch)
tree268c8d0c3df43c2aa9a954b6da3a5a69dfdceb7b
parente1ae10d4e4eb5ac780d3cf3ea7e212286bf1567a (diff)
downloadhaskell-6c3c646c8ae08c70f25f6c0bc658cda28800fffa.tar.gz
rts: Make write of to_cap->inbox atomic
This is necessary since emptyInbox may read from to_cap->inbox without taking cap->lock.
-rw-r--r--rts/Capability.h1
-rw-r--r--rts/Messages.c2
2 files changed, 1 insertions, 2 deletions
diff --git a/rts/Capability.h b/rts/Capability.h
index aab2d84ae7..bc2e48412a 100644
--- a/rts/Capability.h
+++ b/rts/Capability.h
@@ -485,7 +485,6 @@ INLINE_HEADER bool emptyInbox(Capability *cap)
// 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);
}
diff --git a/rts/Messages.c b/rts/Messages.c
index 6418a65117..285ca5be63 100644
--- a/rts/Messages.c
+++ b/rts/Messages.c
@@ -39,7 +39,7 @@ void sendMessage(Capability *from_cap, Capability *to_cap, Message *msg)
#endif
msg->link = to_cap->inbox;
- to_cap->inbox = msg;
+ RELAXED_STORE(&to_cap->inbox, msg);
recordClosureMutated(from_cap,(StgClosure*)msg);