From b8fd845885046d0333b6638b1b66d0eb3ad283a8 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 27 May 2021 21:23:56 +0200 Subject: [PATCH] LibJS: Update mmap name after recycling a HeapBlock :^) Fixes #7507. --- Userland/Libraries/LibJS/Heap/BlockAllocator.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibJS/Heap/BlockAllocator.cpp b/Userland/Libraries/LibJS/Heap/BlockAllocator.cpp index d622623385c..50e0f096ba0 100644 --- a/Userland/Libraries/LibJS/Heap/BlockAllocator.cpp +++ b/Userland/Libraries/LibJS/Heap/BlockAllocator.cpp @@ -33,8 +33,16 @@ BlockAllocator::~BlockAllocator() void* BlockAllocator::allocate_block([[maybe_unused]] char const* name) { - if (!m_blocks.is_empty()) - return m_blocks.take_last(); + if (!m_blocks.is_empty()) { + auto* block = m_blocks.take_last(); +#ifdef __serenity__ + if (set_mmap_name(block, HeapBlock::block_size, name) < 0) { + perror("set_mmap_name"); + VERIFY_NOT_REACHED(); + } +#endif + return block; + } #ifdef __serenity__ auto* block = (HeapBlock*)serenity_mmap(nullptr, HeapBlock::block_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_RANDOMIZED | MAP_PRIVATE, 0, 0, HeapBlock::block_size, name);