bug in dupChan
Meurig Sage
meurig at dcs.gla.ac.uk
Wed Jan 24 13:07:00 EST 2001
Hi
I think that there's a bug in dupChan in Chan.lhs
I tried the following program.
main = do
chan <- newChan
ch <- dupChan chan
writeChan chan "done"
x <- readChan chan
y <- readChan ch
prnt ("Got "++x ++" "++y)
Now if I remember correctly this should print "Got done done".
Instead it exits with
C:\Test\test.exe: no threads to run: infinite loop or deadlock?
I looked for the code for dupChan in hslibs and it says
dupChan :: Chan a -> IO (Chan a)
dupChan (Chan _read write) = do
new_read <- newEmptyMVar
hole <- readMVar write
putMVar new_read hole
return (Chan new_read write)
Shouldn't this instead be
dupChan :: Chan a -> IO (Chan a)
dupChan (Chan _read write) = do
new_read <- newEmptyMVar
hole <- readMVar write
putMVar new_read hole
** putMVar write hole **
return (Chan new_read write)
That's at least what the Concurrent haskell paper says.
Hugs 98 seems to have the same bug with its library.
Meurig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/glasgow-haskell-bugs/attachments/20010124/715467fe/attachment.htm
More information about the Glasgow-haskell-bugs
mailing list