Changes between Initial Version and Version 2 of Ticket #3291


Ignore:
Timestamp:
Jun 11, 2009 2:39:48 PM (6 years ago)
Author:
simonmar
Comment:

The GC determines which threads are blocked indefinitely: those that are unreachable from any root can never be woken up. So what's happening here is that when the forkIO'd thread becomes unreachable, the main thread is also unreachable. Both threads therefore get BlockedIndefinitely exceptions.

If you want the main thread to stay alive, you can add a

myThreadId >>= newStablePtr

to main.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #3291

    • Property Cc echo@… added
    • Property Status changed from new to closed
    • Property Resolution changed from to invalid
    • Property Difficulty changed from to Unknown
  • Ticket #3291 – Description

    initial v2  
    11Perhaps this is just me misunderstanding the semantics of exceptions, but the following program:
    22
    3 """
     3{{{
    44import Test.HUnit.Lang
    55import Control.Concurrent.STM
     
    2222  print r
    2323  print "Am I printed?"
    24 """
     24}}}
    2525
    2626Should 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:
    2727
    28 """
     28{{{
    2929mbolingbroke@mb566 ~/Junk
    3030$ ./Repro
     
    3333Just (False,"thread blocked indefinitely")
    3434Repro: thread blocked indefinitely
    35 """
     35}}}
    3636
    3737NB: I get the expected behaviour if I run it within GHCi, but not if I compile the program.