[commit: ghc] ghc-7.8: rts: Fix possible int overflow in resize_nursery (53c8e6e)

git at git.haskell.org git at git.haskell.org
Sun Apr 27 14:44:17 UTC 2014


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

On branch  : ghc-7.8
Link       : http://ghc.haskell.org/trac/ghc/changeset/53c8e6e3b7fc8266c8843b7fa8f1e22d4413bc81/ghc

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

commit 53c8e6e3b7fc8266c8843b7fa8f1e22d4413bc81
Author: Austin Seipp <austin at well-typed.com>
Date:   Wed Apr 23 03:41:44 2014 -0500

    rts: Fix possible int overflow in resize_nursery
    
    n_capabilities is declared as unsigned int (32bit), and so multiplication
    is 32-bit before being stored in a 64bit integer (StgWord).
    
    Instead, cast n_capabilities to StgWord before multiplying.
    
    Discovered by Coverity. CID 43164.
    
    Signed-off-by: Austin Seipp <austin at well-typed.com>
    (cherry picked from commit 111b8454cc1b64da5b9816b89d79f44a8ae24355)


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

53c8e6e3b7fc8266c8843b7fa8f1e22d4413bc81
 rts/sm/GC.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rts/sm/GC.c b/rts/sm/GC.c
index 1ecbaf5..d22a31e 100644
--- a/rts/sm/GC.c
+++ b/rts/sm/GC.c
@@ -1613,7 +1613,8 @@ resize_generations (void)
 static void
 resize_nursery (void)
 {
-    const StgWord min_nursery = RtsFlags.GcFlags.minAllocAreaSize * n_capabilities;
+    const StgWord min_nursery =
+      RtsFlags.GcFlags.minAllocAreaSize * (StgWord)n_capabilities;
 
     if (RtsFlags.GcFlags.generations == 1)
     {   // Two-space collector:



More information about the ghc-commits mailing list