LibJS: Update mmap name after recycling a HeapBlock :^)

Fixes #7507.
This commit is contained in:
Andreas Kling 2021-05-27 21:23:56 +02:00
parent 58bc10b947
commit b8fd845885

View file

@ -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);