#4449: GHC 7 can't do IO when demonized
----------------------------+-----------------------------------------------
  Reporter:  kazu-yamamoto  |          Owner:  adept      
      Type:  bug            |         Status:  new        
  Priority:  normal         |      Milestone:  7.0.2      
 Component:  Compiler       |        Version:  7.1        
Resolution:                 |       Keywords:  forkProcess
  Testcase:                 |      Blockedby:             
Difficulty:                 |             Os:  MacOS X    
  Blocking:                 |   Architecture:  x86        
   Failure:  None/Unknown   |  
----------------------------+-----------------------------------------------

Comment(by adept):

 OK. More info. Now that I understand the `mkWeakIORef` properly (it just
 adds a finalizer to the `IORef`) I should rephrase the description of the
 root cause.

 It all happens like this. Parent process creates IO manager, and finalizer
 is added to the `state` argument inside `newWith`. Then this IORef plus
 finalized are carried on to the child process on `fork()`. Event if child
 process explicitly closes the inherited IO manager with `ioManagerDie()`,
 there is no guarantee that GC will come to collect the remains of the old
 IO manger befor the new one is created.

 Thus, finalizer for the inherited IO manger could be run _after_ new one
 is created, and there is no easy way to force it run sooner. Since
 `Controls` of the both managers refer to the same file descriptors, we
 have errors (double close) when they are finally run, plus finalizers of
 the inherited manager close control pipes of the new manager.

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

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to