Ticket #6153: writeChan_deadlock.hs

File writeChan_deadlock.hs, 589 bytes (added by klao, 23 months ago)
Line 
1import Control.Concurrent hiding (writeChan, newChan, Chan)
2import Control.Concurrent.Chan
3-- Copy Chan.hs from Control/Concurrent base locally and uncomment
4-- this instead. Compile the whole thing with -O0 to reproduce the
5-- issue realiably.
6-- import Chan
7import Control.Exception
8import Control.Monad
9import System.IO
10
11main = do
12  forever $ do
13         chan <- newChan
14         tid <- forkIO $ forever $ writeChan chan (5::Int)
15         threadDelay 3000
16         throwTo tid ThreadKilled
17         putStr "."
18         hFlush stdout
19         writeChan chan 4       -- test the deadlock