summaryrefslogtreecommitdiff
path: root/rts/RaiseAsync.c
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/RaiseAsync.c
parentf88710185acc0e02b334b96004f4b8fae38c5eb9 (diff)
downloadhaskell-d079b9435382882b0b069ea40bcd287db18082d3.tar.gz
rts: Avoid data races in message handling
Diffstat (limited to 'rts/RaiseAsync.c')
-rw-r--r--rts/RaiseAsync.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/rts/RaiseAsync.c b/rts/RaiseAsync.c
index 719c05435d..893d96ec60 100644
--- a/rts/RaiseAsync.c
+++ b/rts/RaiseAsync.c
@@ -232,7 +232,7 @@ uint32_t
throwToMsg (Capability *cap, MessageThrowTo *msg)
{
StgWord status;
- StgTSO *target = msg->target;
+ StgTSO *target = ACQUIRE_LOAD(&msg->target);
Capability *target_cap;
goto check_target;
@@ -245,8 +245,9 @@ check_target:
ASSERT(target != END_TSO_QUEUE);
// Thread already dead?
- if (target->what_next == ThreadComplete
- || target->what_next == ThreadKilled) {
+ StgWord16 what_next = RELAXED_LOAD(&target->what_next);
+ if (what_next == ThreadComplete
+ || what_next == ThreadKilled) {
return THROWTO_SUCCESS;
}
@@ -988,7 +989,7 @@ raiseAsync(Capability *cap, StgTSO *tso, StgClosure *exception,
sp[0] = (W_)raise;
sp[-1] = (W_)&stg_enter_info;
stack->sp = sp-1;
- tso->what_next = ThreadRunGHC;
+ RELAXED_STORE(&tso->what_next, ThreadRunGHC);
goto done;
}