summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorTobias Guggenmos <tguggenm@redhat.com>2019-09-07 15:32:06 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-10-03 12:17:33 -0400
commit47386fe85a412c8aa35f6bcbce0d41f0eed03b65 (patch)
treeeb269c7dd0f13ee5803d22a6bd5009596bcda17b /rts
parentee6324adfed737fbf9ca3c36538145542b425617 (diff)
downloadhaskell-47386fe85a412c8aa35f6bcbce0d41f0eed03b65.tar.gz
Add new debug flag -DZ
Zeros heap memory after gc freed it.
Diffstat (limited to 'rts')
-rw-r--r--rts/Linker.c4
-rw-r--r--rts/RtsFlags.c11
-rw-r--r--rts/RtsUtils.c2
-rw-r--r--rts/Trace.h1
-rw-r--r--rts/sm/BlockAlloc.c6
-rw-r--r--rts/sm/Storage.c2
6 files changed, 19 insertions, 7 deletions
diff --git a/rts/Linker.c b/rts/Linker.c
index 54e5049a58..1f3d8162be 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -1185,7 +1185,7 @@ void freeObjectCode (ObjectCode *oc)
oc->sections[i].mapped_size);
break;
case SECTION_M32:
- IF_DEBUG(sanity,
+ IF_DEBUG(zero_on_gc,
memset(oc->sections[i].start,
0x00, oc->sections[i].size));
m32_free(oc->sections[i].start,
@@ -1193,7 +1193,7 @@ void freeObjectCode (ObjectCode *oc)
break;
#endif
case SECTION_MALLOC:
- IF_DEBUG(sanity,
+ IF_DEBUG(zero_on_gc,
memset(oc->sections[i].start,
0x00, oc->sections[i].size));
stgFree(oc->sections[i].start);
diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c
index cbc9a333ec..d4301c414f 100644
--- a/rts/RtsFlags.c
+++ b/rts/RtsFlags.c
@@ -181,6 +181,7 @@ void initRtsFlagsDefaults(void)
RtsFlags.DebugFlags.gc = false;
RtsFlags.DebugFlags.block_alloc = false;
RtsFlags.DebugFlags.sanity = false;
+ RtsFlags.DebugFlags.zero_on_gc = false;
RtsFlags.DebugFlags.stable = false;
RtsFlags.DebugFlags.stm = false;
RtsFlags.DebugFlags.prof = false;
@@ -405,6 +406,7 @@ usage_text[] = {
" -Dg DEBUG: gc",
" -Db DEBUG: block",
" -DS DEBUG: sanity",
+" -DZ DEBUG: zero freed memory during GC",
" -Dt DEBUG: stable",
" -Dp DEBUG: prof",
" -Da DEBUG: apply",
@@ -1861,6 +1863,9 @@ static void read_debug_flags(const char* arg)
case 'S':
RtsFlags.DebugFlags.sanity = true;
break;
+ case 'Z':
+ RtsFlags.DebugFlags.zero_on_gc = true;
+ break;
case 't':
RtsFlags.DebugFlags.stable = true;
break;
@@ -1895,6 +1900,12 @@ static void read_debug_flags(const char* arg)
// -Dx also turns on -v. Use -l to direct trace
// events to the .eventlog file instead.
RtsFlags.TraceFlags.tracing = TRACE_STDERR;
+
+ // sanity implies zero_on_gc
+ if(RtsFlags.DebugFlags.sanity){
+ RtsFlags.DebugFlags.zero_on_gc = true;
+ }
+
}
#endif
diff --git a/rts/RtsUtils.c b/rts/RtsUtils.c
index 2a53d18572..b9ddb2a345 100644
--- a/rts/RtsUtils.c
+++ b/rts/RtsUtils.c
@@ -79,7 +79,7 @@ stgMallocBytes (size_t n, char *msg)
rtsConfig.mallocFailHook((W_) n, msg);
stg_exit(EXIT_INTERNAL_ERROR);
}
- IF_DEBUG(sanity, memset(space, 0xbb, n));
+ IF_DEBUG(zero_on_gc, memset(space, 0xbb, n));
return space;
}
diff --git a/rts/Trace.h b/rts/Trace.h
index 9985adc52f..d3bb226000 100644
--- a/rts/Trace.h
+++ b/rts/Trace.h
@@ -52,6 +52,7 @@ enum CapsetType { CapsetTypeCustom = CAPSET_TYPE_CUSTOM,
#define DEBUG_gc RtsFlags.DebugFlags.gc
#define DEBUG_block_alloc RtsFlags.DebugFlags.alloc
#define DEBUG_sanity RtsFlags.DebugFlags.sanity
+#define DEBUG_zero_on_gc RtsFlags.DebugFlags.zero_on_gc
#define DEBUG_stable RtsFlags.DebugFlags.stable
#define DEBUG_stm RtsFlags.DebugFlags.stm
#define DEBUG_prof RtsFlags.DebugFlags.prof
diff --git a/rts/sm/BlockAlloc.c b/rts/sm/BlockAlloc.c
index bbb4f8a6c1..f9e3d11407 100644
--- a/rts/sm/BlockAlloc.c
+++ b/rts/sm/BlockAlloc.c
@@ -456,7 +456,7 @@ allocGroupOnNode (uint32_t node, W_ n)
}
finish:
- IF_DEBUG(sanity, memset(bd->start, 0xaa, bd->blocks * BLOCK_SIZE));
+ IF_DEBUG(zero_on_gc, memset(bd->start, 0xaa, bd->blocks * BLOCK_SIZE));
IF_DEBUG(sanity, checkFreeListSanity());
return bd;
}
@@ -531,7 +531,7 @@ bdescr* allocLargeChunkOnNode (uint32_t node, W_ min, W_ max)
recordAllocatedBlocks(node, bd->blocks);
- IF_DEBUG(sanity, memset(bd->start, 0xaa, bd->blocks * BLOCK_SIZE));
+ IF_DEBUG(zero_on_gc, memset(bd->start, 0xaa, bd->blocks * BLOCK_SIZE));
IF_DEBUG(sanity, checkFreeListSanity());
return bd;
}
@@ -656,7 +656,7 @@ freeGroup(bdescr *p)
p->gen = NULL;
p->gen_no = 0;
/* fill the block group with garbage if sanity checking is on */
- IF_DEBUG(sanity,memset(p->start, 0xaa, (W_)p->blocks * BLOCK_SIZE));
+ IF_DEBUG(zero_on_gc, memset(p->start, 0xaa, (W_)p->blocks * BLOCK_SIZE));
if (p->blocks == 0) barf("freeGroup: block size is zero");
diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c
index 3f91905f3c..d4be531c73 100644
--- a/rts/sm/Storage.c
+++ b/rts/sm/Storage.c
@@ -650,7 +650,7 @@ resetNurseries (void)
ASSERT(bd->gen_no == 0);
ASSERT(bd->gen == g0);
ASSERT(bd->node == capNoToNumaNode(n));
- IF_DEBUG(sanity, memset(bd->start, 0xaa, BLOCK_SIZE));
+ IF_DEBUG(zero_on_gc, memset(bd->start, 0xaa, BLOCK_SIZE));
}
}
#endif