From dffd943207dd356a113ee8ff3e51227c2655a039 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Sat, 24 Oct 2020 10:48:19 -0400 Subject: rts: Make write of to_cap->inbox atomic This is necessary since emptyInbox may read from to_cap->inbox without taking cap->lock. --- rts/Capability.h | 1 - rts/Messages.c | 2 +- 2 files changed, 1 insertion(+), 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); -- cgit v1.2.1