[Haskell-cafe] BlockedIndefinitelyOnMVar exception

Brandon Moore brandon_m_moore at yahoo.com
Thu Mar 31 21:41:59 CEST 2011

----- Original Message ----
> From: Mitar <mmitar at gmail.com>
> To: Brandon Moore <brandon_m_moore at yahoo.com>
> Cc: Gregory Collins <greg at gregorycollins.net>; Edward Z. Yang <ezyang at mit.edu>; 
>Haskell Cafe <haskell-cafe at haskell.org>
> Sent: Thu, March 31, 2011 2:06:31 PM
> Subject: Re: [Haskell-cafe] BlockedIndefinitelyOnMVar exception
> Hi!
> On Thu, Mar 31, 2011 at 4:37 PM, Brandon Moore
> <brandon_m_moore at yahoo.com>  wrote:
> > If you plan to send an exception, you must have the ThreadId  saved 
> > which should prevent the BlockedIndefinitelyOnMVar  exception.
> But this behavior is something they wish to remove in future  versions
> as not-wanted?

The BlockedIndefinitelyOnMVar exception is only supposed to be sent if
the thread is known to be deadlocked. If it is possible that another thread
might wake it by sending an asynchronous exception, it's probably not
appropriate to send it the BlockedIndefinitelyOnMVar exception.

Even if it holding a ThreadId didn't always keep the target thread around,
it would still have to preserve the thread if it was possible you might
eventually use throwTo on the threadId (even killThread technically
raises a catchable exception). I note you could at least preemptively
prune the stack down to the topmost exception handler, and collect
at least some garbage that way.

Also, that note has been in the documentation at least since GHC 4.06
so I don't expect the situation to change any time soon!
(3.02 didn't yet implement killThread, according to docs in the source package).



More information about the Haskell-Cafe mailing list