From 27804b4e67a430133c0227265c0d9c0473efa783 Mon Sep 17 00:00:00 2001 From: OatmealDome Date: Tue, 1 Sep 2026 21:50:27 -0400 Subject: [PATCH] MemArenaDarwin: Pass the MAP_MEM_VM_SHARE flag to mach_make_memory_entry_64 Large anonymous mappings are split into 128 MB chunks. Without MAP_MEM_VM_SHARE, mach_make_memory_entry_64 will only return an entry spanning the first chunk. Attempting to map through that entry will fail if it extends beyond the 128 MB boundary, which can happen when the sizes of MEM1/MEM2 are overridden. --- Source/Core/Common/MemArenaDarwin.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Core/Common/MemArenaDarwin.cpp b/Source/Core/Common/MemArenaDarwin.cpp index 9414535be5..0f6db28339 100644 --- a/Source/Core/Common/MemArenaDarwin.cpp +++ b/Source/Core/Common/MemArenaDarwin.cpp @@ -26,7 +26,11 @@ void MemArena::GrabSHMSegment(size_t size, std::string_view base_name) } memory_object_size_t entry_size = size; - constexpr vm_prot_t prot = VM_PROT_READ | VM_PROT_WRITE; + // Large anonymous mappings are split into 128 MB chunks. Without MAP_MEM_VM_SHARE, + // mach_make_memory_entry_64 will only return an entry spanning the first chunk. + // Attempting to map through that entry will fail if it extends beyond the 128 MB + // boundary, which can happen when the sizes of MEM1/MEM2 are overridden. + constexpr vm_prot_t prot = VM_PROT_READ | VM_PROT_WRITE | MAP_MEM_VM_SHARE; retval = mach_make_memory_entry_64(mach_task_self(), &entry_size, m_shm_address, prot, &m_shm_entry, MACH_PORT_NULL);