"Thread blocked indefinitely" kills the program despite being caught
Perhaps this is just me misunderstanding the semantics of exceptions, but the following program:
import Test.HUnit.Lang
import Control.Concurrent.STM
import Control.Exception
import Control.Concurrent
import Control.Concurrent.MVar
main = do
mv <- newEmptyMVar
forkIO $ do
r <- performTestCase (atomically retry)
print "Yeaahh!"
print r
evaluate r
putMVar mv r
print "Cool, let's see what we get"
r <- takeMVar mv
print r
print "Am I printed?"
Should in my opinion, when run, print "Am I printed". This is because the "Thread blocked indefinitely" exception is caught by HUnit. However, this happens instead:
mbolingbroke@mb566 ~/Junk
$ ./Repro
"Cool, let's see what we get"
"Yeaahh!"
Just (False,"thread blocked indefinitely")
Repro: thread blocked indefinitely
NB: I get the expected behaviour if I run it within GHCi, but not if I compile the program.
This is causing problems for test-framework (see http://bsp.lighthouseapp.com/projects/15661-hs-test-framework/tickets/1-exits-immediately-on-thread-blocked-indefinitely-exception#ticket-1-2)