summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@cs.stanford.edu>2016-08-15 02:22:28 -0700
committerEdward Z. Yang <ezyang@cs.stanford.edu>2016-08-15 18:05:46 -0700
commitf9a11a241b8056ac2b9c771172a48919fb3d0ed1 (patch)
tree5808c66fee37b4c39935b00a0e53201bafa72c8c
parentda99a7f515cddb7e9eebd81283375c245e1625d4 (diff)
downloadhaskell-f9a11a241b8056ac2b9c771172a48919fb3d0ed1.tar.gz
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@cs.stanford.edu> Test Plan: validate Reviewers: simonmar, austin, Phyx, bgamari, erikd Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2455
-rw-r--r--rts/RtsUtils.c1
-rw-r--r--rts/sm/Storage.c2
2 files changed, 3 insertions, 0 deletions
diff --git a/rts/RtsUtils.c b/rts/RtsUtils.c
index 716d203462..3a9742744f 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 3f8889658f..4d0c8d5260 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;