From 30f7137d1acc48499840d9a106ecce6109fd8e7a Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Thu, 10 Dec 2020 09:31:00 -0500 Subject: rts: Zero shrunk array slop in vanilla RTS But only when profiling or DEBUG are enabled. Fixes #17572. --- includes/Cmm.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'includes/Cmm.h') diff --git a/includes/Cmm.h b/includes/Cmm.h index 574c60a1b3..fdb4badf9a 100644 --- a/includes/Cmm.h +++ b/includes/Cmm.h @@ -630,7 +630,11 @@ #else #define OVERWRITING_CLOSURE_SIZE(c, size) /* nothing */ #define OVERWRITING_CLOSURE(c) /* nothing */ -#define OVERWRITING_CLOSURE_MUTABLE(c, off) /* nothing */ +/* This is used to zero slop after shrunk arrays. It is important that we do + * this whenever profiling is enabled as described in Note [slop on the heap] + * in Storage.c. */ +#define OVERWRITING_CLOSURE_MUTABLE(c, off) \ + if (TO_W_(RtsFlags_ProfFlags_doHeapProfile(RtsFlags)) != 0) { foreign "C" overwritingMutableClosureOfs(c "ptr", off); } #endif // Memory barriers. -- cgit v1.2.1