[commit: ghc] master: rts: Fix possible int overflow in resize_nursery (111b845)

git at git.haskell.org git at git.haskell.org
Sun Apr 27 11:45:32 UTC 2014


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/111b8454cc1b64da5b9816b89d79f44a8ae24355/ghc

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

commit 111b8454cc1b64da5b9816b89d79f44a8ae24355
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>


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

111b8454cc1b64da5b9816b89d79f44a8ae24355
 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