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

Comment(by bos):

 Johan, I think you're right about the need to invoke the callbacks. If you
 look at the {{{closeFd}}} code in
 [http://hackage.haskell.org/trac/ghc/attachment/ticket/4514/base-4514.patch
 base-4514.patch], you'll see that there are two places we could invoke the
 callbacks:

 1. While we have the {{{MVar}}} named {{{emFds}}} held.
 1. After we've released it.

 There's an unavoidable race here at present: another thread could have
 opened a file or socket, getting the same file descriptor, and we've no
 way to tell our callee that our file descriptor has been closed, so it
 could read/write the wrong file descriptor.

 To deal with this, I think we need to add the equivalents of {{{POLLHUP}}}
 and {{{POLLRDHUP}}} to the events that we can send to threads, call 'em
 {{{evtWriteHup}}} and {{{evtReadHup}}}. If you asked for {{{evtWrite}}}
 and someone closed your file descriptor, we'll give you {{{evtWriteHup}}}.
 If you asked for {{{evtRead}}}, we'll give you {{{evtReadHup}}}.

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