Skip to content

Commit d41bb79

Browse files
committed
at unmaskAsyncExceptions op we should setup the stack as normal, because it could be captured by an ApStack when an Update frame is present ; handle blackhole blocking at stack unwind
1 parent bc6690e commit d41bb79

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ evalPrimOp fallback op args t tc = case (op, args) of
6868
ts@ThreadState{..} <- getCurrentThreadState
6969
tid <- gets ssCurrentThreadId
7070

71-
when (tsBlockedExceptions /= []) $ do
72-
reportThreads
73-
error $ "TODO: maskAsyncExceptions# - raise async exceptions getting from threads: " ++ show tsBlockedExceptions
74-
7571
------------------------ debug
7672
promptM_ $ do
7773
liftIO $ print (tid, op, args)
@@ -130,7 +126,10 @@ evalPrimOp fallback op args t tc = case (op, args) of
130126
-- raise exception
131127
ts <- getCurrentThreadState
132128
updateThreadState tid ts {tsBlockedExceptions = waitingTids}
133-
PrimConcurrency.raiseAsyncEx (tsCurrentResult ts) tid exception
129+
-- run action
130+
stackPush $ Apply [w] -- HINT: the stack may be captured by ApStack if there is an Update frame,
131+
-- so we have to setup the continuation properly
132+
PrimConcurrency.raiseAsyncEx [f] tid exception
134133
pure []
135134
[] -> do
136135
-- set new masking state
@@ -289,10 +288,13 @@ raiseEx0 ex = unwindStack where
289288
unwindStack
290289

291290
Just (Update addr) -> do
292-
-- update the (balckholed/running) thunk with the exception value
291+
-- update the (blackholed/running) thunk with the exception value
292+
wakeupBlackHoleQueueThreads addr
293293
store addr $ RaiseException ex
294-
ctid <- gets ssCurrentThreadId
295-
--mylog $ "raiseEx - Update " ++ show addr ++ " current-tid: " ++ show ctid
294+
--ctid <- gets ssCurrentThreadId
295+
--exObj <- readHeap ex
296+
--mylog $ "raiseEx - Update " ++ show addr ++ " = " ++ show (RaiseException ex) ++ " current-tid: " ++ show ctid ++ " ex: " ++ show exObj
297+
--reportThread ctid
296298
unwindStack
297299

298300
Just (Atomically stmAction) -> do

0 commit comments

Comments
 (0)