Asynchronous exceptions in threadWait

Michael Walker mike at barrucadu.co.uk
Thu Jan 17 22:23:08 UTC 2019


> Although the entire function has asynchronous exceptions masked, the call to takeMVar uses onException to deal with the possibility of an exception. According to the docs in Control.Concurrent, takeMVar can throw exceptions. But my understand (which may be wrong) is that the only exception this could throw would be something like BlockedIndefinitelyOnMVar, which I don't believe can happen here.

That's not quite right.  The mask_ function blocks asynchronous
exceptions from being delivered to the thread while it's not
"interruptible".  Most blocking functions, such as takeMVar, make the
thread interruptible while they're blocked.  So any asynchronous
exception (such as ThreadKilled) could be delivered to the thread if
it blocks in the takeMVar.

-- 
Michael Walker (http://www.barrucadu.co.uk)


More information about the Libraries mailing list