Fix race condition in memory_decommit/memory_reset on Apple ARM64#18423
Open
Drustburn wants to merge 6 commits intoRPCS3:masterfrom
Open
Fix race condition in memory_decommit/memory_reset on Apple ARM64#18423Drustburn wants to merge 6 commits intoRPCS3:masterfrom
Drustburn wants to merge 6 commits intoRPCS3:masterfrom
Conversation
The previous approach used munmap followed by mmap without MAP_FIXED (since Apple rejects MAP_FIXED | MAP_JIT). Between the two calls, another thread could claim the unmapped address range, causing mmap to return a different address and triggering a fatal verification error. Under concurrent load (e.g. PPU LLVM compilation with many worker threads), this race manifests reliably as "Verification failed (object: 0x0)" crashes across all PPUW threads in memory_decommit. Fix: Use MAP_FIXED without MAP_JIT instead. This atomically replaces the mapping without any window for other threads to interfere. The MAP_JIT attribute is lost on the replaced pages, but the application's code signing entitlements (allow-unsigned-executable-memory, disable-executable-page-protection) permit executable mappings without it. Applied the same fix to memory_reset which had the identical pattern.
AniLeo
reviewed
Mar 22, 2026
AniLeo
reviewed
Mar 22, 2026
The Apple ARM64 code paths are now identical to the generic case, so the ifdef blocks are unnecessary.
Merged
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On Apple ARM64,
memory_decommitandmemory_resetused amunmapfollowed bymmapwithoutMAP_FIXED(since Apple rejectsMAP_FIXED | MAP_JIT). Between the two calls, another thread could claim the unmapped address range, causingmmapto return a different address and triggering a fatal verification error.Under concurrent load (e.g. PPU LLVM compilation with many worker threads), this race manifests reliably as
Verification failed (object: 0x0)crashes across all PPUW threads.Fix
Use
MAP_FIXEDwithoutMAP_JITinstead. This atomically replaces the mapping without any window for other threads to interfere. TheMAP_JITattribute is lost on the replaced pages, but the application's code signing entitlements (allow-unsigned-executable-memory,disable-executable-page-protection) permit executable mappings without it.Before (crashes under load)
After (atomic, race-free)
Test plan
memory_decommitverification failures are eliminated