[project @ 2001-02-06 11:42:30 by simonmar]
authorsimonmar <unknown>
Tue, 6 Feb 2001 11:42:30 +0000 (11:42 +0000)
committersimonmar <unknown>
Tue, 6 Feb 2001 11:42:30 +0000 (11:42 +0000)
urk! when showing a handle, we don't replace the MVar.  For example,
the following test causes a deadlock:

main = do
  getContents
  catch getChar (\e -> print e >> return 'x')
  catch getChar (\e -> print e >> return 'x')

To be merged into 4.08.

ghc/lib/std/PrelIOBase.lhs

index 02aad74..6ef3f27 100644 (file)
@@ -1,5 +1,5 @@
 % ------------------------------------------------------------------------------
-% $Id: PrelIOBase.lhs,v 1.32 2001/01/11 17:25:57 simonmar Exp $
+% $Id: PrelIOBase.lhs,v 1.33 2001/02/06 11:42:30 simonmar Exp $
 % 
 % (c) The University of Glasgow, 1994-2000
 %
@@ -269,9 +269,10 @@ instance Show Handle where
      -- (Big) SIGH: unfolded defn of takeMVar to avoid
      -- an (oh-so) unfortunate module loop with PrelConc.
      hdl_ = unsafePerformIO (IO $ \ s# ->
-            case h               of { MVar h# ->
-            case takeMVar# h# s# of { (# s2# , r #) -> 
-                   (# s2#, r #) }})
+            case h                 of { MVar h# ->
+            case takeMVar# h# s#   of { (# s2# , r #) -> 
+            case putMVar# h# r s2# of { s3# ->
+            (# s3#, r #) }}})
 #endif
 #else
      hdl_ = unsafePerformIO (stToIO (readVar h))