Hello,
Before I turn the following into a ticket I want to ask if I miss
something obvious:
When I run the following program:
-------------------------------------------------
import Prelude hiding (catch)
import Control.Exception
import Control.Concurrent
main :: IO ()
main = do
mv <- newEmptyMVar
_ <- forkIO $ do
catch action
(\e -> putStrLn $ "I solved the Halting Problem: " ++
show (e :: SomeException))
putStrLn "putting MVar..."
putMVar mv ()
putStrLn "putted MVar"
takeMVar mv
action :: IO ()
action = let x = x in x
-------------------------------------------------
I get the output:
$ ghc --make Loop.hs -o loop -O2 -fforce-recomp && ./loop
[1 of 1] Compiling Main ( Loop.hs, Loop.o )
Linking loop ...
loop: thread blocked indefinitely in an MVar operation
I solved the Halting Problem: <<loop>>
putting MVar...
putted MVar
As can be seen, the putMVar is executed successfully. So why do I get
the message: "thread blocked indefinitely in an MVar operation"?
Note that if I change the action to a normal error the message disappears.
I discovered this bug when hunting for another one. I have a Haskell
web-server where one of the request handlers contained a loop. All
exceptions thrown by handlers are caught and logged. When executing
the looping handler I noticed ~0% CPU usage so I assumed that the
handler wasn't actually looping because a NonTermination exception was
thrown. However for some reason the NonTermination exception was not
caught and logged. I haven't yet isolated this bug into a small
test-case but when trying that I discovered the above.
Regards,
Bas