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

Dimitry Golubovsky golubovsky at gmail.com
Sun Jun 20 22:51:57 EDT 2010


Hi,

I am experimenting with the new feature in GHC such as custom Handles.
I use GHC 6.12.2, base 4.2.0.1

I have pasted the code in question as
http://hpaste.org/fastcgi/hpaste.fcgi/view?id=26413#a26413

I am trying to create a Handle using a thread as data producer. In my
example is is a union of directories, and the Handle contents is
newline-separated list of full paths of all files in the union. This
list is produced by a thread which reads contents of all directories
in the union, turns them into absolute filenames, and sends to the
channel. The method of BufferedIO responsible for filling in the
Handle's buffer reads data from the channel and places it in the
buffer.

The problem is, after the contents of the Handle (via hGetContents)
has been consumed, the program crashes with the following message:

<program name>: thread blocked indefinitely in an MVar operation

that is, the BlockedIndefinitelyOnMVar exception has occurred.

What is done wrong in my code? The dirClose method seems to be called
(its output shows up), however with or without the call to killThread,
the exception occurs anyway.

Thanks for any ideas.

-- 
Dimitry Golubovsky

Anywhere on the Web


More information about the Glasgow-haskell-users mailing list