From 01b282a5f37ebf3a3e9ee12026445f26f7256d28 Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Mon, 9 Nov 2020 21:16:35 +0000 Subject: [PATCH] Bug fix for using failing to initialise meta-data If the Superslab meta-data is larger than an OS page, then the subsequent pages could be decommited. This removes the skipped initialisation in that case. --- src/mem/superslab.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mem/superslab.h b/src/mem/superslab.h index 50e6e1630..93aabb908 100644 --- a/src/mem/superslab.h +++ b/src/mem/superslab.h @@ -81,7 +81,10 @@ namespace snmalloc { allocator = alloc; - if (kind != Super) + // If Superslab is larger than a page, then we cannot guarantee it still + // has a valid layout as the subsequent pages could have been freed and + // zeroed, hence only skip initialisation if smaller. + if (kind != Super || (sizeof(Superslab) >= OS_PAGE_SIZE)) { if (kind != Fresh) {