Repository navigation
libretro: reset machine options between content sessions - #582
Merged
sonninnos merged 1 commit intoOct 8, 2026
Merged
Conversation
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.
Loading another Neo Geo game without unloading the core library can retain the previous cartridge type. For example,
mslug3->mslug4starts the latter with:cslot1:sma_mslug3instead of:cslot1:pcm2_mslug4, producing the BIOS crosshatch screen. Loadingkof97aftermslug4can likewise retain the PCM2 cartridge and crash. A fresh process boots these games normally.Cause and change
mmain()retains a staticretro_optionsacross sessions. When the next machine has a slot with the same name,emu_options::add_and_remove_slot_options()keeps the existing slot option and its old default. Changing the system directly therefore does not necessarily replace the cartridge type.Reset the system name to an empty string before starting the next frontend session. The existing empty-system path removes obsolete slot/image options, allowing the next machine to populate its own defaults. This keeps the options object's required lifetime and does not special-case particular games or modify the general MAME options implementation.
Reproduction
mslug3with the MAME core.mslug4in the same RetroArch process.sma_mslug3cartridge in verbose output. Cold-startingmslug4selectspcm2_mslug4instead.mslug4->kof97, which can crash with the previous cartridge type still selected.This was also reproduced outside RetroArch in a small libretro host retaining the same loaded library while cycling
retro_init/retro_load_game/retro_run/retro_unload_game/retro_deinit. The reproducer used isolated save directories, no input, no savestates, and disabled threaded mode, so automatic state loading and RetroArch frontend state are not required triggers.Validation
Tested against
9069f39340f2d2b1795df8e71bb1d3d0fbc76598(MAME 0.289) on macOS ARM64:mslug3->mslug4andmslug4->kof97cases select the correct cartridge and run after the change.mslug3,mslug4,sf2ce,kof97, andkovpassed save, unload, intervening content loads, reload, unserialize, and continued execution with threaded mode enabled.mslug4, exited, and successfully loaded it on the next launch using isolated directories.Build command:
make -f Makefile.libretro platform=osx CROSS_COMPILE=1 \ LIBRETRO_APPLE_PLATFORM=arm64-apple-macos11 \ LIBRETRO_APPLE_ISYSROOT="$(xcrun --show-sdk-path)" -j10Windows, Linux, and non-arcade machine/softlist configurations have not been runtime-tested.
AI assistance
This diagnosis, patch, and description were prepared with OpenAI Codex (GPT-6). The exact serving snapshot identifier is not exposed in this session. The validation above was executed locally; its platform and coverage limits are stated explicitly.