
----- Original Message ----
From: Mitar
To: Brandon Moore Cc: Gregory Collins ; Edward Z. Yang ; Haskell Cafe 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
wrote: If you plan to send an exception, you must have the ThreadId saved elsewhere, 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). http://www.haskell.org/ghc/docs/4.06/hslibs/sec-concurrency-basics.html Brandon