From 6517a2ea285688907e8d71e8313f04e919a24445 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Sun, 1 Dec 2019 14:11:11 -0500 Subject: rts: Mitigate races in capability interruption logic --- rts/Capability.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'rts/Capability.h') diff --git a/rts/Capability.h b/rts/Capability.h index 6c8ac78cb6..7eaffa0225 100644 --- a/rts/Capability.h +++ b/rts/Capability.h @@ -460,21 +460,22 @@ stopCapability (Capability *cap) // It may not work - the thread might be updating HpLim itself // at the same time - so we also have the context_switch/interrupted // flags as a sticky way to tell the thread to stop. - cap->r.rHpLim = NULL; + TSAN_ANNOTATE_BENIGN_RACE(&cap->r.rHpLim, "stopCapability"); + SEQ_CST_STORE(&cap->r.rHpLim, NULL); } INLINE_HEADER void interruptCapability (Capability *cap) { stopCapability(cap); - cap->interrupt = 1; + SEQ_CST_STORE(&cap->interrupt, true); } INLINE_HEADER void contextSwitchCapability (Capability *cap) { stopCapability(cap); - cap->context_switch = 1; + SEQ_CST_STORE(&cap->context_switch, true); } #if defined(THREADED_RTS) -- cgit v1.2.1