Skip to content

Commit 1ef0bed

Browse files
committed
io-sim: do not arbitrary set masking state in Throw or ThrowTo
Masking state for catch handler is set in `unwindControlStack` when we unwind the control stack to the matching `CatchFrame`. This fixes a subtle bug, where the masking state would be reset from `MaskedUninterruptible` to `MaskedInterruptible`.
1 parent 64dc2ee commit 1ef0bed

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

io-sim/src/Control/Monad/IOSim/Internal.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,8 +1064,7 @@ schedule thread@Thread{
10641064
ThrowTo e tid' _ | tid' == tid -> do
10651065
-- Throw to ourself is equivalent to a synchronous throw,
10661066
-- and works irrespective of masking state since it does not block.
1067-
let thread' = thread { threadControl = ThreadControl (Throw e) ctl
1068-
, threadMasking = MaskedInterruptible }
1067+
let thread' = thread { threadControl = ThreadControl (Throw e) ctl }
10691068
trace <- schedule thread' simstate
10701069
return (SimTrace time tid tlbl (EventThrowTo e tid) trace)
10711070

@@ -1096,7 +1095,7 @@ schedule thread@Thread{
10961095
let adjustTarget t@Thread{ threadControl = ThreadControl _ ctl' } =
10971096
t { threadControl = ThreadControl (Throw e) ctl'
10981097
, threadBlocked = False
1099-
, threadMasking = MaskedInterruptible }
1098+
}
11001099
simstate'@SimState { threads = threads' }
11011100
= snd (unblockThreads [tid'] simstate)
11021101
threads'' = Map.adjust adjustTarget tid' threads'

0 commit comments

Comments
 (0)