[commit: ghc] master: Fix #9236 Error on read from closed handle (257cbec)

git at git.haskell.org git at git.haskell.org
Thu Oct 30 04:15:37 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/257cbec2f605c31d335a6709b43754a88f184d9d/ghc

>---------------------------------------------------------------

commit 257cbec2f605c31d335a6709b43754a88f184d9d
Author: David Feuer <David.Feuer at gmail.com>
Date:   Wed Oct 29 23:13:07 2014 -0500

    Fix #9236 Error on read from closed handle
    
    Summary:
    Fixes #9236. My testing indicates that this does *not* lead to problems with
    broken pipes and such, but further testing is required. It found
    a bug in haddock; I've submitted a pull request upstream.
    
    Reviewers: ekmett, austin
    
    Reviewed By: ekmett, austin
    
    Subscribers: rwbarton, thomie, carter, simonmar
    
    Differential Revision: https://phabricator.haskell.org/D327
    
    GHC Trac Issues: #9236


>---------------------------------------------------------------

257cbec2f605c31d335a6709b43754a88f184d9d
 libraries/base/GHC/IO/Handle/Text.hs | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libraries/base/GHC/IO/Handle/Text.hs b/libraries/base/GHC/IO/Handle/Text.hs
index de48bf4..88ec3c4 100644
--- a/libraries/base/GHC/IO/Handle/Text.hs
+++ b/libraries/base/GHC/IO/Handle/Text.hs
@@ -389,8 +389,11 @@ lazyRead handle =
    unsafeInterleaveIO $
         withHandle "hGetContents" handle $ \ handle_ -> do
         case haType handle_ of
-          ClosedHandle     -> return (handle_, "")
           SemiClosedHandle -> lazyReadBuffered handle handle_
+          ClosedHandle
+            -> ioException
+                  (IOError (Just handle) IllegalOperation "hGetContents"
+                        "delayed read on closed handle" Nothing Nothing)
           _ -> ioException
                   (IOError (Just handle) IllegalOperation "hGetContents"
                         "illegal handle type" Nothing Nothing)



More information about the ghc-commits mailing list