From 3ca29d6f501ba5d2608b99e6afa471e1e91001e8 Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Mon, 9 Nov 2020 21:17:59 +0000 Subject: [PATCH] Make POSIX COMMIT CHECKS mode fill memory This simulates the pages being switched off with unexpected content, and thus, when turned on we don't assume they have been unchanged. --- src/pal/pal_posix.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pal/pal_posix.h b/src/pal/pal_posix.h index 6fbecad..ba1f489 100644 --- a/src/pal/pal_posix.h +++ b/src/pal/pal_posix.h @@ -135,6 +135,9 @@ namespace snmalloc { SNMALLOC_ASSERT(is_aligned_block(p, size)); #ifdef USE_POSIX_COMMIT_CHECKS + // Fill memory so that when we switch the pages back on we don't make + // assumptions on the content. + memset(p, 0x5a, size); mprotect(p, size, PROT_NONE); #else UNUSED(p);