[commit: ghc] wip/erikd/remove-nat: rts: Fix segfault in profiling/debug/sanity checking mode (b59edda)
git at git.haskell.org
git at git.haskell.org
Thu May 5 05:19:25 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/erikd/remove-nat
Link : http://ghc.haskell.org/trac/ghc/changeset/b59edda69f5a92b54920b1a0e61065e4115d69f9/ghc
>---------------------------------------------------------------
commit b59edda69f5a92b54920b1a0e61065e4115d69f9
Author: Erik de Castro Lopo <erikd at mega-nerd.com>
Date: Thu May 5 15:10:24 2016 +1000
rts: Fix segfault in profiling/debug/sanity checking mode
The profiling code assumes that un-used memory at the start of a block
is zero filled so the profiling code can just skip over it. However, when
compiled in DEBUG mode and with the debug sanity checking RTS flag (`-DS`)
given on the command line, the memory allocator pre-fills new blocks with
`0xaa` which causes the profiling code to segfault.
The fix is just to detect debug sanity checking and ignore any `0xaa`
filled memory. It does however mean that profiling results when debug
sanity checking is enabled may produce incorrect results.
>---------------------------------------------------------------
b59edda69f5a92b54920b1a0e61065e4115d69f9
rts/LdvProfile.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/rts/LdvProfile.c b/rts/LdvProfile.c
index 1dfdc56..42081ae 100644
--- a/rts/LdvProfile.c
+++ b/rts/LdvProfile.c
@@ -184,7 +184,14 @@ processNurseryForDead( void )
for (bd = MainCapability.r.rNursery->blocks; bd != NULL; bd = bd->link) {
p = bd->start;
while (p < bd->free) {
+ // The start of the block may be zero filled which we need to skip
+ // over.
while (p < bd->free && !*p) p++; // skip slop
+
+ // In debug mode, with sanity checking enabled, the start of the
+ // block may be filled with `0xaa` so if we find it, we just break.
+ IF_DEBUG(sanity, if (*((StgWord32*)p) == 0xaaaaaaaa) break;);
+
if (p >= bd->free) break;
p += processHeapClosureForDead((StgClosure *)p);
}
More information about the ghc-commits
mailing list