From 87c9ad32f27f2ee978ffc38a6d10e28083e4e928 Mon Sep 17 00:00:00 2001 From: Bix <114880614+Bixbr@users.noreply.github.com> Date: Fri, 4 Jul 2025 13:02:32 +0100 Subject: [PATCH] [Android/MEM] MPROTECT OOM handling. --- src/common/host_memory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index e0b5a6a67c..e001f5543c 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -387,10 +387,10 @@ static void* ChooseVirtualBase(size_t virtual_size) { uintptr_t hint_address = ((rng() % range) + lower) * HugePageSize; // Try to map. - // Note: we may be able to take advantage of MAP_FIXED_NOREPLACE here. + // Added MAP_FIXED_NOREPLACE here to stop mprotect eventually (20+ mins) failing with out of memory. void* map_pointer = mmap(reinterpret_cast(hint_address), virtual_size, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); + MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_FIXED_NOREPLACE, -1, 0); // If we successfully mapped, we're done. if (reinterpret_cast(map_pointer) == hint_address) {