[commit: base] master: Fix System.Timeout.timeout leaking Timeout exceptions (#7719). (5dc317f)

Ian Lynagh igloo at earth.li
Sun Apr 21 15:26:18 CEST 2013


Repository : ssh://darcs.haskell.org//srv/darcs/packages/base

On branch  : master

https://github.com/ghc/packages-base/commit/5dc317f4d108be14be71b150b435cced008da564

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

commit 5dc317f4d108be14be71b150b435cced008da564
Author: Bertram Felgenhauer <int-e at gmx.de>
Date:   Thu Mar 7 02:18:17 2013 +0100

    Fix System.Timeout.timeout leaking Timeout exceptions (#7719).

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

 System/Timeout.hs |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/System/Timeout.hs b/System/Timeout.hs
index e0b20ea..be44ba3 100644
--- a/System/Timeout.hs
+++ b/System/Timeout.hs
@@ -27,6 +27,7 @@ module System.Timeout ( timeout ) where
 #ifdef __GLASGOW_HASKELL__
 import Control.Concurrent
 import Control.Exception   (Exception(..), handleJust, bracket,
+                            uninterruptibleMask_,
                             asyncExceptionToException,
                             asyncExceptionFromException)
 import Data.Typeable
@@ -90,8 +91,9 @@ timeout n f
                    (\_ -> return Nothing)
                    (bracket (forkIOWithUnmask $ \unmask ->
                                  unmask $ threadDelay n >> throwTo pid ex)
-                            (killThread)
+                            (uninterruptibleMask_ . killThread)
                             (\_ -> fmap Just f))
+        -- #7719 explains why we need uninterruptibleMask_ above.
 #else
 timeout n f = fmap Just f
 #endif /* !__GLASGOW_HASKELL__ */





More information about the ghc-commits mailing list