Repository navigation
Conversation
The x86_64 macOS JIT was disabled in 99d2900 because of melonDS-emu#2292 (crash when booting anything with the JIT enabled on Intel Macs). Cause: since 99ce959 the JIT code memory on x86_64 is the static CodeMemory array, which ends up in __DATA. With current Apple linkers the maximum protection of __DATA is rw-, so the mprotect(PROT_EXEC) in Init() fails (its result was not checked) and the first jump into JIT code faults. Fix: allocate JIT code memory dynamically on all Apple targets, like aarch64 already does and like x86_64 did up to melonDS 0.9.5 (anonymous RWX mapping). Re-enable ENABLE_JIT on x86_64 macOS, and report a failing mprotect on the remaining static-memory targets instead of ignoring it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
Fixed by 7d8dea4 |
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.
Fixes #2292. The x86_64 macOS JIT was disabled in 99d2900 because of this crash.
Cause
Since 99ce959 the JIT code memory on x86_64 is the static
CodeMemoryarray, which ends up in__DATA. With current Apple linkers the maximum protection of__DATAisrw-(an x86_64 build of 906e9eb showsmaxprot 0x3), somprotect(PROT_EXEC)inARMJIT_Global::Init()fails. Its result was not checked, so the first jump into JIT code faults.Fix
mmappath, which is what melonDS used up to 0.9.5.ENABLE_JITfor x86_64 macOS in CMake.mprotectresult on the remaining static-memory targets and print an error instead of failing silently.Testing
On a MacBookAir7,2 (i5-5350U, macOS 12.7.6), the affected class of machine, using a headless harness on the core at 906e9eb with this change:
mprotect(PROT_EXEC) ... Permission deniedfollowed by SIGSEGV, which reproduces [JIT, macOS Sonoma (Intel)] melonDS crashes when booting anything if JIT is enabled #2292.coretarget builds for x86_64 and arm64 macOS withENABLE_JIT=ON.One observation not addressed here: on the same Air, with the JIT on, our harness hung after boot when the software 3D renderer ran threaded. The unthreaded runs above are fine. We have not investigated this, and it may be specific to our harness.
🤖 Generated with Claude Code