Thread-backed handles: thread blocked indefinitely in an MVar operation

Dimitry Golubovsky golubovsky at
Tue Jun 22 07:43:12 EDT 2010


On Tue, Jun 22, 2010 at 4:31 AM, Simon Marlow <marlowsd at> wrote:

> So the problem is that fillReadBuffer has to return 0 to indicate EOF, but
> you are killing the slave thread as soon as it has reached the end of the
> stream.  So you get one call to fillReadBuffer that returns the data up to
> the end of the stream, and the next call that should return 0 blocks on the
> Chan indefinitely because the slave thread has already been killed.

Thanks for your reply.

Updated paste:

I enclosed readChan in a catchException call which seems to have cured
the problem: it just simulates EOF on the handle if the thread is
blocked (channel vanished). Interestingly that in the failing version,
handle closing was done in a separate thread (thread 3), but in the
updated version it was the same thread 1.

Dimitry Golubovsky

Anywhere on the Web

Dimitry Golubovsky

Anywhere on the Web

More information about the Glasgow-haskell-users mailing list