macOS Metal crash on clean exit in RT64 worker teardown
Summary
On macOS with the Metal backend, Zelda64Recompiled can crash during clean exit after starting the game. The crash occurs while RT64 worker threads are being joined or torn down.
Observed crash signature
The local crash reports showed:
- Exception Type: EXC_BAD_ACCESS (SIGSEGV)
- Triggered by Thread: RT64 Workload or RT64 Idle
- top frames in libobjc around objc_release / AutoreleasePoolPage::releaseUntil
- RT64 teardown frames including WorkloadQueue::~WorkloadQueue and Application::end
Representative failing path:
Thread crashed: RT64 Idle / RT64 Workload
libobjc.A.dylib objc_release
libobjc.A.dylib AutoreleasePoolPage::releaseUntil
Zelda64Recompiled RT64::WorkloadQueue::~WorkloadQueue
Zelda64Recompiled RT64::Application::endDiagnosis
This appears to be an RT64 Metal object lifetime issue rather than a Zelda64Recomp game-state bug. RT64 worker threads create autoreleased Metal/Foundation objects without stable autorelease pools, and a few Metal objects returned by autoreleasing APIs are stored/released with incorrect ownership.
Upstream tracking
Draft RT64 fix PR: https://github.com/rt64/rt64/pull/256
The local fix branch was validated by rebuilding Zelda64Recompiled, verifying the app signature, starting the game repeatedly, and exiting cleanly without reproducing the crash.
Notes
The RT64 PR targets the RT64 branch currently pinned by Zelda64Recomp, because RT64 main does not contain the same Metal backend file layout.
Source: Zelda64Recomp/Zelda64Recomp