Skip to content

Fix macOS save state crash in dual-core mode#428

Open
ryanmagoon wants to merge 1 commit intolibretro:masterfrom
ryanmagoon:fix-savestate-dualcore-crash
Open

Fix macOS save state crash in dual-core mode#428
ryanmagoon wants to merge 1 commit intolibretro:masterfrom
ryanmagoon:fix-savestate-dualcore-crash

Conversation

@ryanmagoon
Copy link
Copy Markdown

@ryanmagoon ryanmagoon commented Apr 14, 2026

In dual-core mode on macOS, retro_serialize and retro_unserialize queue DoState to the CPU thread via RunOnCPUThread. Frontends using an offscreen CGL context (no window-backed default framebuffer) set the GL context current on the calling thread, not the CPU thread. Any GL calls during DoState on the CPU thread segfault.

This temporarily declares the calling thread as the CPU thread so DoState runs inline where the GL context is valid.

Only tested on macOS arm64 with my own libretro frontend using an offscreen CGL context.

In dual-core mode, retro_serialize and retro_unserialize queue DoState
to the CPU thread via RunOnCPUThread. The CPU thread does not have the
frontend's GL context current, so any GL calls during DoState segfault.

Temporarily declare the calling thread as the CPU thread so DoState
runs inline where the GL context is valid.

Tested on macOS arm64 with a third-party libretro frontend using an
offscreen CGL context.
@ryanmagoon ryanmagoon changed the title Fix save state crash in dual-core mode Fix macOS save state crash in dual-core mode Apr 14, 2026
@cscd98
Copy link
Copy Markdown

cscd98 commented Apr 20, 2026

@warmenhoven are you able to test this please? as I don't have a mac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants