[commit: ghc] master: Fix thunk leak in CoreM's CoreWriter (d43d63f)

Ian Lynagh igloo at earth.li
Tue Jun 4 22:12:22 CEST 2013


Repository : http://darcs.haskell.org/ghc.git/

On branch  : master

https://github.com/ghc/ghc/commit/d43d63f50f7359f30bc65af3d286042dd4dd1c1d

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

commit d43d63f50f7359f30bc65af3d286042dd4dd1c1d
Author: Andrew Farmer <anfarmer at ku.edu>
Date:   Thu Mar 7 18:13:03 2013 -0600

    Fix thunk leak in CoreM's CoreWriter

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

 compiler/simplCore/CoreMonad.lhs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/compiler/simplCore/CoreMonad.lhs b/compiler/simplCore/CoreMonad.lhs
index 3afb8cd..e11c139 100644
--- a/compiler/simplCore/CoreMonad.lhs
+++ b/compiler/simplCore/CoreMonad.lhs
@@ -762,7 +762,8 @@ instance Monad CoreM where
     mx >>= f = CoreM $ \s -> do
             (x, s', w1) <- unCoreM mx s
             (y, s'', w2) <- unCoreM (f x) s'
-            return (y, s'', w1 `plusWriter` w2)
+            let w = w1 `plusWriter` w2 -- forcing w before returning avoids a space leak (Trac #7702)
+            return $ seq w (y, s'', w)
 
 instance Applicative CoreM where
     pure = return





More information about the ghc-commits mailing list