exceptions and forking
Alastair Reid
reid@cs.utah.edu
Fri, 4 May 2001 05:22:13 -0600 (MDT)
[Copied to hugs-bugs. Simon is replying to a query by me about a
recent change in the Exception library (that the CVS repository
version of Hugs now supports). The BlockedOnDeadMVar exception is an
exception sent to all threads which are blocked on an unreachable MVar
which is unreachable and, therefore, can never, ever be awakened by a
live thread writing to the MVar.]
"Simon Marlow" <simonmar@microsoft.com> writes:
> Well, strictly speaking you should implement BlockedOnDeadMVar because
> otherwise a thread can be silently GC'd without getting a chance to
> clean up and release any locks it may be holding. I'm not sure how
> difficult it would be to implement in Hugs, though.
I'm absolutely convinced. Not dealing properly with issues like this
is what makes killThread such a broken idea in Java (though not in
Haskell thanks to ideas in your PLDI paper).
Unfortunately, it's going to be somewhat unpleasant to implement in
Hugs. It's obvious enough how to use ForeignObjs to detect when the
GC is done with an MVar but will require yet another change to the
list of runnable threads to be able to bring a dying thread back to
life while we send it an exception. Hack upon hack upon hack....
Sigh!
[Ummm, consider this as a bug report from me (Hugs doesn't implement
BlockedOnDeadMVar) combined with me accepting responsibility for
fixing it if no-one beats me to it.]
--
Alastair Reid reid@cs.utah.edu http://www.cs.utah.edu/~reid/