summaryrefslogtreecommitdiff
path: root/rts/sm
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-12-10 09:31:00 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-01-07 00:10:15 -0500
commit30f7137d1acc48499840d9a106ecce6109fd8e7a (patch)
treea7a792bf6f014b574fde8032a6f0488567dd01dc /rts/sm
parentfb81f2edccaa8a02b0b3f68e82f0c795346e3b54 (diff)
downloadhaskell-30f7137d1acc48499840d9a106ecce6109fd8e7a.tar.gz
rts: Zero shrunk array slop in vanilla RTS
But only when profiling or DEBUG are enabled. Fixes #17572.
Diffstat (limited to 'rts/sm')
-rw-r--r--rts/sm/Storage.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c
index a43719fc9b..41abbfc81c 100644
--- a/rts/sm/Storage.c
+++ b/rts/sm/Storage.c
@@ -953,14 +953,19 @@ accountAllocation(Capability *cap, W_ n)
* profiler, see Note [skipping slop in the heap profiler].
*
* In general we zero:
+ *
* - Pinned object alignment slop, see MEMSET_SLOP_W in allocatePinned.
* - Large object alignment slop, see MEMSET_SLOP_W in allocatePinned.
- * This is necessary even in the vanilla RTS since the user may trigger a heap
- * census via +RTS -hT even when not linking against the profiled RTS.
- *
- * Only when profiling we zero:
* - Shrunk array slop, see OVERWRITING_CLOSURE_MUTABLE.
*
+ * Note that this is necessary even in the vanilla (e.g. non-profiling) RTS
+ * since the user may trigger a heap census via +RTS -hT, which can be used
+ * even when not linking against the profiled RTS. Failing to zero slop
+ * due to array shrinking has resulted in a few nasty bugs (#17572, #9666).
+ * However, since array shrink may result in large amounts of slop (unlike
+ * alignment), we take care to only zero such slop when heap profiling or DEBUG
+ * are enabled.
+ *
* When performing LDV profiling or using a (single threaded) debug RTS we zero
* slop even when overwriting immutable closures, see Note [zeroing slop when
* overwriting closures].