Concurrent Haskell problem/bug

Simon Marlow
Tue, 10 Jul 2001 10:31:19 +0100

> I posted this on comp.lang.functional and someone suggested I=20
> try here.
> Apologies if it's not on-charter here - any redirections appreciated.
> I'm seeing unexpected behaviour from GHC 5. (unexpected by=20
> me, anyway :)

Hi Greg,

As it happens I saw your post on comp.lang.functional and we fixed the
bug last week :-)  (I replied to the newsgroup, but our news is a bit
flaky here so you may not have seen it).

Yes, you found a genuine bug in take/putMVar that appeared when the
semantics of putMVar changed to allow it to block when the MVar is full.
To work around the problem, don't rely on this behaviour of putMVar and
either use one of the other Concurrent Haskell datatypes (eg. Chan) or
use a second MVar to act as a "lock" on the first one.