[GHC] #7970: Thread GC frees roots before thread actually finishes

GHC ghc-devs at haskell.org
Tue Jul 2 12:45:58 CEST 2013


#7970: Thread GC frees roots before thread actually finishes
---------------------------------+------------------------------------------
    Reporter:  joeyadams         |       Owner:  simonmar        
        Type:  bug               |      Status:  new             
    Priority:  high              |   Milestone:  7.8.1           
   Component:  Runtime System    |     Version:  7.6.3           
    Keywords:                    |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  Runtime crash   
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:                  
     Related:  7170              |  
---------------------------------+------------------------------------------

Comment(by simonmar):

 So I implemented the fix, and in doing so discovered that it broke a test
 (`conc031`), which is a test for the old behaviour, see #551.

 Let me be clear about what's going on.  These two GC features:

  1. A thread can be blocked on a finalizer without being considered
 deadlocked
  2. A weak pointer will not be finalized if a deadlocked thread references
 it

 are mutually exclusive.  We currently have (1) (because the lack of it was
 reported as a bug in #551), and this ticket complains about the lack of
 (2).  But implementing (2) reverses (1).

 Here's another complaint about the lack of (2):
 http://www.haskell.org/pipermail/haskell-cafe/2010-August/081953.html (the
 whole thread is interesting)

 The evidence so far is that the lack of (2) is more surprising than the
 lack of (1), so I'm slightly tempted to go with (2).  There's also a
 workaround: `mkStablePtr` can be used to keep anything alive (and prevents
 threads from getting the deadlock exception), but you have to manually
 `freeStablePtr` later.

 Finalizers are a pain :)

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7970#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the ghc-tickets mailing list