diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-12-01 14:11:11 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2020-10-24 21:00:36 -0400 |
commit | 6517a2ea285688907e8d71e8313f04e919a24445 (patch) | |
tree | 25f3a5bb82fbd62fe3cffba15fdd917a907b6b7a /rts/Capability.h | |
parent | 31fa87ecb4ff1abc761d776d48e87cd0fd37bedd (diff) | |
download | haskell-6517a2ea285688907e8d71e8313f04e919a24445.tar.gz |
rts: Mitigate races in capability interruption logic
Diffstat (limited to 'rts/Capability.h')
-rw-r--r-- | rts/Capability.h | 7 |
1 files changed, 4 insertions, 3 deletions
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) |