From 7133a49e8153e3b405335c8aed1b76c482ebe430 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 28 May 2024 19:17:18 -0400 Subject: [PATCH] kernel/slab: Allocate one area upfront when the debug heaps are in use. See inline comment: if we don't, we'll try to allocate pages during the post-page-init but pre-area-init period, which isn't possible (and after the previous commit will properly fail.) Change-Id: If8392417e05912c8cfc417222abab3b39cb15bf1 Reviewed-on: https://review.haiku-os.org/c/haiku/+/7700 Haiku-Format: Haiku-format Bot Reviewed-by: waddlesplash --- src/system/kernel/slab/MemoryManager.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/system/kernel/slab/MemoryManager.cpp b/src/system/kernel/slab/MemoryManager.cpp index da4efab2e0..b729235d00 100644 --- a/src/system/kernel/slab/MemoryManager.cpp +++ b/src/system/kernel/slab/MemoryManager.cpp @@ -445,6 +445,16 @@ MemoryManager::Init(kernel_args* args) sFreeAreas = NULL; sFreeAreaCount = 0; sMaintenanceNeeded = false; + +#if USE_DEBUG_HEAP_FOR_MALLOC || USE_GUARDED_HEAP_FOR_MALLOC + // Allocate one area immediately. Otherwise, we might try to allocate before + // post-area initialization but after page initialization, during which time + // we can't actually reserve pages. + MutexLocker locker(sLock); + Area* area = NULL; + _AllocateArea(0, area); + _AddArea(area); +#endif }