#3128: hClose leaves file descriptor open if it fails
-----------------------------+----------------------------------------------
Reporter:  Baughn            |          Owner:                  
    Type:  bug               |         Status:  new             
Priority:  normal            |      Component:  libraries/base  
 Version:  6.10.1            |       Severity:  normal          
Keywords:                    |       Testcase:                  
      Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
-----------------------------+----------------------------------------------
 In libraries/base/GHC/Handle.hs, function hClose_help, we attempt to flush
 the write buffer before closing a handle's underlying FD.

 If flushing the write buffer fails, for example if this is a network
 socket that has been closed by the remote host, hClose throws an exception
 inside flushWriteBufferOnly and the socket is not closed. As a result, the
 program leaks sockets.

 The solution is to always close the FD (that is, call hClose_handle_)
 regardless of errors, but I am not confident of writing correct exception-
 handling code without the usual abstractions available.


 Also, inside hClose_handle_, an error is thrown if c_close ever returns
 -1. It may be practically impossible for this to be caused by EINTR, but
 is it theoretically impossible?

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