Problem
Save states crash the emulation utility process when using the Dolphin (GameCube) libretro core. The worker terminates with a segfault during retro_serialize(), killing the entire emulation session.
Root Cause (confirmed via instrumentation)
The crash is inside Dolphin's retro_serialize() implementation — not in our GL setup or buffer allocation. Diagnostic logging confirms:
[gamelord] serialize: calling retro_serialize_size...
[gamelord] serialize: size=92409028 (88.1MB)
[gamelord] serialize: allocating 92409028 bytes...
[gamelord] serialize: calling retro_serialize...
[error] [ (ipc) ] Failed to save state: Error: Worker process terminated
We verified:
- ✅ GL context is current (
CGLSetCurrentContext)
- ✅ FBOs are unbound (
glBindFramebuffer(GL_FRAMEBUFFER, 0))
- ✅ GL pipeline is flushed (
glFinish())
- ✅ Accumulated GL errors are drained
- ✅ 88MB buffer allocation succeeds
- ❌
retro_serialize() segfaults inside Dolphin's own code
The initial GL_INVALID_FRAMEBUFFER_OPERATION (0x0506) error was a red herring — draining it and unbinding FBOs didn't prevent the crash.
Current Mitigation
- Save state UI is hidden for HW-render cores (
saveStatesSupported flag piped from worker → renderer)
- Worker-side guard blocks serialize/unserialize as defense-in-depth
- No crash, no broken buttons — users simply don't see save state controls for GameCube
To Fix Properly
Investigate Dolphin's libretro retro_serialize implementation:
- The crash is likely in GPU state serialization (texture cache, shader cache, or framebuffer readback)
- May be specific to CGL offscreen contexts (no window backing)
- May be specific to Apple Silicon / macOS OpenGL 4.1
- Compare with how RetroArch sets up the GL context for Dolphin on macOS
- Contribute fix upstream to libretro/dolphin
Problem
Save states crash the emulation utility process when using the Dolphin (GameCube) libretro core. The worker terminates with a segfault during
retro_serialize(), killing the entire emulation session.Root Cause (confirmed via instrumentation)
The crash is inside Dolphin's
retro_serialize()implementation — not in our GL setup or buffer allocation. Diagnostic logging confirms:We verified:
CGLSetCurrentContext)glBindFramebuffer(GL_FRAMEBUFFER, 0))glFinish())retro_serialize()segfaults inside Dolphin's own codeThe initial
GL_INVALID_FRAMEBUFFER_OPERATION(0x0506) error was a red herring — draining it and unbinding FBOs didn't prevent the crash.Current Mitigation
saveStatesSupportedflag piped from worker → renderer)To Fix Properly
Investigate Dolphin's libretro
retro_serializeimplementation: