#4514: IO manager can deadlock if a file descriptor is closed behind its back
------------------------------------------+---------------------------------
  Reporter:  adept                        |          Owner:                  
      Type:  bug                          |         Status:  new             
  Priority:  high                         |      Milestone:  7.0.2           
 Component:  Runtime System               |        Version:  7.0.1           
Resolution:                               |       Keywords:                  
  Testcase:                               |      Blockedby:                  
Difficulty:                               |             Os:  Linux           
  Blocking:                               |   Architecture:  Unknown/Multiple
   Failure:  Incorrect result at runtime  |  
------------------------------------------+---------------------------------

Comment(by bos):

 I'm pasting in some comments from Ian in email:

   Skimming through this patch I noticed some interface changes. We try not
 to change the interfaces of libraries within a GHC branch (e.g. 7.0.1 and
 7.0.2 should have the same library APIs). If it's really necessary then we
 can make changes, although we should keep them as small as possible.

   The particular changes also aren't obviously right to me. e.g. I
 wouldn't expect {{{Control.Concurrent}}} to export something called
 {{{closeFd}}}, and I wouldn't expect something called {{{closeFd}}} to
 have that type.

 I believe that it's not possible to avoid any of the submitted API changes
 here. Specifically:

 * The {{{fdWasClosed}}} function that we added during 6.13 development was
 subject to a race condition: you could mark an fd as closed after another
 thread had performed an {{{open}}} or similar that could reuse that fd.
 * The new {{{closeFd}}} function is necessary to close that race. It
 manages this by closing the fd while holding an {{{MVar}}}, so another
 thread can't race in and register the fd.
 * Why does {{{closeFd}}} accept an action as parameter? Because under
 Windows, you have to use different functions to close a file descriptor
 depending on whether it's owned by Winsock or the rest of win32.
 * If the name should be something like {{{closeFdWith}}} to be more
 descriptive, that's fine (please let me know if you have a preference), as
 my purpose is to close the race :-)
 * Why should {{{closeFdWith}}} be exported from {{{Control.Concurrent}}}?
 Because {{{threadWaitRead}}} and {{{threadWaitWrite}}} already are, and
 {{{closeFdWith}}} must be used with those functions now to guarantee race-
 free closing.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4514#comment:32>
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