-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hang with STM & two scopes #33
Comments
We also tried just using {-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DeriveAnyClass #-}
module Main where
import Control.Monad
import Control.Exception
import Control.Concurrent
import Control.Concurrent.STM
import Ki
data Bang = Bang
deriving (Exception, Show)
main :: IO ()
main =
scoped \scope1 -> do
explodingThread <- fork scope1 do
threadDelay 1_000_000
throwIO Bang
scoped \ki -> do
c <- newTChanIO
threadId <- fork ki do
threadDelay 5_000_000
putStrLn "Waiting"
threadDelay 10_000_000 |
One more finding: If I do threadId <- fork ki do
print =<< try @SomeException do
forever do
atomically do
readTChan c
pure () I get
So I think it does get the exception and something else is borked |
Oh dear, thanks for the bug report. |
I think the bug is here: ki/ki/src/Ki/Internal/Scope.hs Lines 169 to 173 in 48f351f
The intention is to avoid bothering to throw But the child thread identifier here isn't globally unique: for each scope, it starts at 0 and counts up. So, we can easily get our wires crossed and avoid propagating an exception down to a child that should receive it. I can see a few options:
|
This is fixed in Kind of an embarrassing bug! 😓 But thank you again for reporting! |
Amazing, thank you so much! And don't feel bad - most bugs are like this! We'll give this a bash soon. Fortunately we only hit this bug when a bunch of other stuff has crashed, so it's quite - if you'll forgive the pun - exceptional 😉 |
The following program hangs indefinitely:
I would expect this to be fine, and die with the
Bang
exception. If we use a single scope, that's exactly what happens, so it seems to be some kind of interation between two scopes.The text was updated successfully, but these errors were encountered: