Deadlock in Chan module
The following program:
module Main where
import Control.Concurrent
main :: IO ()
main = do
todo <- newChan
forkIO $ readChan todo
putStrLn "Before isEmptyChan"
b <- isEmptyChan todo
putStrLn "After isEmptyChan"
writeChan todo ()
Gives the output:
$ ghc --make Main.hs -threaded && ./Main.exe
Before isEmptyChan
Main.exe: thread blocked indefinitely in an MVar operation
I think that's a bug. Note that if the putStrLn
statements are removed then it works, but I think that's because the printing introduces a delay that lets the other thread run.
Edited by Ben Gamari