From b454559b3cdb682904c393ab33b25da1c0f23e0a Mon Sep 17 00:00:00 2001 From: Eduard Bagdasaryan Date: Tue, 17 Dec 2019 15:01:05 +0000 Subject: [PATCH] Fix shared memory size calculation on 64-bit systems (#520) Since commit 2253ee0, the wrong type (uint32 instead of size_t) was used to calculate the PagePool::theLevels size. theLevels memory (positioned by different and correct code) did not overlap with the raw pages buffer, but the raw pages buffer could, in some cases, be 32 bits short, placing the last 4 bytes of the last page outside of allocated memory. In practice, shared memory allocations are page-aligned, and the difference in 4 bytes was probably compensated by the extra allocated bytes in most (or perhaps even all) cases. --- src/ipc/mem/PageStack.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ipc/mem/PageStack.cc b/src/ipc/mem/PageStack.cc index ccf28d5717..0cd604403e 100644 --- a/src/ipc/mem/PageStack.cc +++ b/src/ipc/mem/PageStack.cc @@ -122,7 +122,7 @@ Ipc::Mem::PageStack::sharedMemorySize() const size_t Ipc::Mem::PageStack::SharedMemorySize(const uint32_t, const unsigned int capacity, const size_t pageSize) { - const size_t levelsSize = PageId::maxPurpose * sizeof(std::atomic); + const auto levelsSize = PageId::maxPurpose * sizeof(Levels_t); const size_t pagesDataSize = capacity * pageSize; return StackSize(capacity) + LevelsPaddingSize(capacity) + levelsSize + pagesDataSize; } -- 2.47.2