From 340b5708ce38230f1af66acf832547996aa0b2ff Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Mon, 8 Oct 2018 15:49:40 +0200 Subject: [PATCH] Fix SegmentInitialize for OS_PAGE_SIZE > 4k (#20280) The function was incorrectly rounding the dwCommit down instead of up to OS_PAGE_SIZE. It accidentally works for OSes where page size is 4096 bytes, because the dwCommit is 4096. But for ARM64 Linux distros where the page size is 64kB, this was committing zero bytes and so the runtime initialization was crashing a bit later when it tried to access the memory it was supposed to be commited. This problem was introduced in #17769. --- src/gc/handletablecore.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/gc/handletablecore.cpp b/src/gc/handletablecore.cpp index 9fadbc2..7e531f9 100644 --- a/src/gc/handletablecore.cpp +++ b/src/gc/handletablecore.cpp @@ -508,10 +508,7 @@ BOOL SegmentInitialize(TableSegment *pSegment, HandleTable *pTable) */ // we want to commit enough for the header PLUS some handles - uint32_t dwCommit = HANDLE_HEADER_SIZE; - - // Round down to the dwPageSize - dwCommit &= ~(OS_PAGE_SIZE - 1); + size_t dwCommit = ALIGN_UP(HANDLE_HEADER_SIZE, OS_PAGE_SIZE); // commit the header if (!GCToOSInterface::VirtualCommit(pSegment, dwCommit)) -- 2.7.4