From 13b89304b20f8ecc1ac34919cf14a79acca416d9 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 5 Nov 2026 08:24:25 +0000 Subject: [PATCH] libretro: set up the FPU before the first frame save_fpu() and restore_fpu() call the FPU emulation through function pointers that fpu_reset() only sets up when the first m68k_go() resets the CPU. A frontend may ask for the state size, or save or load a state, before the first retro_run() - Kodi does when a game starts - and the core crashed calling a null pointer. --- src/retro/main_retro.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/retro/main_retro.c b/src/retro/main_retro.c index f2be1e05f..dba1d8002 100644 --- a/src/retro/main_retro.c +++ b/src/retro/main_retro.c @@ -479,6 +479,11 @@ RETRO_API bool retro_load_game(const struct retro_game_info *game) Retro_SetInputDescriptors(); + /* The CPU, and with it the FPU emulation that save_fpu() and + * restore_fpu() call into, is only reset by the first m68k_go() in + * retro_run(), but a frontend may save or load a state before that. */ + fpu_reset(); + game_loaded = true; return true;