[Haskell-cafe] Printing of asynchronous exceptions to stderr

Mitar mmitar at gmail.com
Tue Nov 9 11:37:24 EST 2010


I have been spend some time to debug this in my program. ;-)

Why is ThreadKilled not displayed by RTS when send to thread (and
unhandled), but any other exception is?

For example, I am using custom exceptions to signal different kinds of
thread killing. Based on those my threads cleanup in different ways.
But after they cleanup they keep "running". Not really running as
their computations were interrupted. But simply hanging there. And if
then new custom exception arrives it is not handled anymore (as it is
after my normal exception handlers already cleaned everything) and it
is printed to stderr.

Now I added  "`finally` throwIO ThreadKilled" at the end of my cleanup
computations to really kill the thread. So that possible later
exceptions are not delivered anymore.

Why it is not so that after all computations in a thread finish,
thread is not killed/disposed of? Because it can be reused by some
other computation? But then my exceptions could be delivered to wrong
(new) thread while they were meant for old one?


More information about the Haskell-Cafe mailing list