Skip to content

Load the game from its path when the frontend gives no data - #219

Merged
kivutar merged 1 commit into
libretro:masterfrom
sunlollyking:load-from-path
Nov 15, 2026
Merged

kivutar merged 1 commit into
libretro:masterfrom
sunlollyking:load-from-path

Conversation

@sunlollyking

Copy link
Copy Markdown

melonDS asks for the game in memory, but a frontend that can't load it there gives only the path. Kodi does this when a game won't fit in the memory it has. NDS::LoadROM() then copied from a null pointer and melonDS ran an empty cart, which crashes on some games.

With no data, the ROM is now read from info->path with the existing NDS::LoadROM(path), which reads straight into the cart, so there's no second copy. A path that can't be opened fails the load. The GBA slot does the same.

retro_reset() loads the game again the same way. It used to go through the frontend's retro_game_info pointer, but persistent_data only keeps the data, not the struct, so a frontend that builds it on the stack left it dangling.

Tested in Kodi on Linux with a DS game padded past Kodi's in-memory limit, so Kodi passed only the path. Before: an empty cart ("Game code:" blank, "ROM entry not found"). After: the game loads (YK6E), and loads again on reset. Loading from memory, and resetting, work as before.

sunlollyking added a commit to sunlollyking/game.libretro.melonds that referenced this pull request Oct 29, 2026
Carries libretro/melonDS#219 until it is merged. When game.libretro
can't give melonDS the game in memory it passes only the path, and
melonDS ran an empty cart, which crashes on some games. It now reads the
game from the path, and loads it again the same way on reset.
melonDS asks for the game in memory, but a frontend that can't load it
there, such as Kodi when a game is too big for the memory it has, gives
only the path. LoadROM() then copied from a null pointer and melonDS ran
an empty cart, which crashes on some games.

Without data the ROM is now read from the path, straight into the cart
with no second copy, and a path that can't be opened fails the load, as
does a Slot 1/2 boot whose GBA game can't be loaded. retro_reset() loads
the game again the same way: it kept the frontend's retro_game_info
pointer, which isn't guaranteed to outlive retro_load_game().

@kivutar kivutar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Red CI is unrelated

@kivutar
kivutar merged commit 4081e83 into libretro:master Nov 15, 2026
0 of 3 checks passed
kel-mo added a commit to kel-mo/tv.kodi.Kodi that referenced this pull request Nov 20, 2026
Update the add-ons to the tip of their branches, and these cores to the
commits their add-ons now pin: Beetle PCE, Beetle Saturn, FCEUmm,
Gearsystem, Hatari, LRPS2, MAME 2003-Plus, melonDS, mGBA, PPSSPP,
PrBoom, VBA-M and Virtual Jaguar.

Carries that are now upstream are dropped: game.libretro's own system
folder (kodi-game/game.libretro#222), PPSSPP's log callback
(hrydgard/ppsspp#23074), melonDS building without OpenGL
(libretro/melonDS#215) and imagedecoder.svg's size bound
(xbmc/imagedecoder.svg#7). The melonDS add-on also dropped its patch
for loading from a path, now in the core (libretro/melonDS#219).

Three cores need more than a new pin. game.libretro.mgba now builds
upstream mGBA, so it is built with CMake here. The Hatari core links
libm only into the standalone program, and the core is linked here with
--no-undefined, so libm is added to its link. game.libretro.gearsystem
dropped its core version patch, so it is dropped here too.
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