[commit: ghc] master: When in sanity mode, un-zero malloc'd memory; fix uninitialized memory bugs. (f9a11a2)

git at git.haskell.org git at git.haskell.org
Tue Aug 16 01:06:03 UTC 2016


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

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

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

commit f9a11a241b8056ac2b9c771172a48919fb3d0ed1
Author: Edward Z. Yang <ezyang at cs.stanford.edu>
Date:   Mon Aug 15 02:22:28 2016 -0700

    When in sanity mode, un-zero malloc'd memory; fix uninitialized memory bugs.
    
    malloc'd memory is not guaranteed to be zeroed.  On Linux, however,
    it is often zeroed, leading to latent bugs.  In fact, with this
    patch I fix two uninitialized memory bugs stemming from this.
    
    Signed-off-by: Edward Z. Yang <ezyang at cs.stanford.edu>
    
    Test Plan: validate
    
    Reviewers: simonmar, austin, Phyx, bgamari, erikd
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2455


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

f9a11a241b8056ac2b9c771172a48919fb3d0ed1
 rts/RtsUtils.c   | 1 +
 rts/sm/Storage.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/rts/RtsUtils.c b/rts/RtsUtils.c
index 716d203..3a97427 100644
--- a/rts/RtsUtils.c
+++ b/rts/RtsUtils.c
@@ -79,6 +79,7 @@ stgMallocBytes (size_t n, char *msg)
       rtsConfig.mallocFailHook((W_) n, msg); /*msg*/
       stg_exit(EXIT_INTERNAL_ERROR);
     }
+    IF_DEBUG(sanity, memset(space, 0xbb, n));
     return space;
 }
 
diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c
index 3f88896..4d0c8d5 100644
--- a/rts/sm/Storage.c
+++ b/rts/sm/Storage.c
@@ -106,6 +106,8 @@ initGeneration (generation *gen, int g)
     gen->n_scavenged_large_blocks = 0;
     gen->live_compact_objects = NULL;
     gen->n_live_compact_blocks = 0;
+    gen->compact_blocks_in_import = NULL;
+    gen->n_compact_blocks_in_import = 0;
     gen->mark = 0;
     gen->compact = 0;
     gen->bitmap = NULL;



More information about the ghc-commits mailing list