Skip to content

Commit bc6690e

Browse files
committed
fix: use a single retry mechanism, do not special case empty because, the prapred stack could be captured by ApStack when an sync exception is thrown
1 parent ab32571 commit bc6690e

File tree

1 file changed

+8
-16
lines changed
  • external-stg-interpreter/lib/Stg/Interpreter/PrimOp

1 file changed

+8
-16
lines changed

external-stg-interpreter/lib/Stg/Interpreter/PrimOp/STM.hs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -345,22 +345,14 @@ retrySTM = unwindStack where
345345
ts <- getThreadState tid
346346
-- subscribe to wait queues
347347
let Just tlog = tsActiveTLog ts
348-
case IntMap.null tlog of
349-
True -> do
350-
-- HINT: the transaction log is empty, so there is no TVar to subscribe, therefore the transaction is blocked indefinitely
351-
updateThreadState tid (ts {tsActiveTLog = Nothing})
352-
Rts{..} <- gets ssRtsSupport
353-
PrimConcurrency.raiseAsyncEx [] tid rtsBlockedIndefinitelyOnSTM
354-
pure []
355-
False -> do
356-
subscribeTVarWaitQueues tid tlog
357-
-- suspend thread
358-
updateThreadState tid (ts {tsStatus = ThreadBlocked (BlockedOnSTM tlog), tsActiveTLog = Just mempty})
359-
-- Q: who will update the tsTLog after the wake up?
360-
stackPush $ Atomically stmAction
361-
stackPush $ Apply [Void]
362-
stackPush $ RunScheduler SR_ThreadBlocked
363-
pure [stmAction]
348+
subscribeTVarWaitQueues tid tlog -- HINT: GC deadlock detection will cover empty tlog and dead TVar caused deadlocks
349+
-- suspend thread
350+
updateThreadState tid (ts {tsStatus = ThreadBlocked (BlockedOnSTM tlog), tsActiveTLog = Just mempty})
351+
-- Q: who will update the tsTLog after the wake up?
352+
stackPush $ Atomically stmAction
353+
stackPush $ Apply [Void]
354+
stackPush $ RunScheduler SR_ThreadBlocked
355+
pure [stmAction]
364356

365357
_ -> unwindStack -- HINT: discard stack frames
366358

0 commit comments

Comments
 (0)