Closed orbea closed 6 years ago
For reference here is the crash.
$ ./retroarch -L ../daphne/daphne_libretro.so
AddressSanitizer:DEADLYSIGNAL
=================================================================
==2797==ERROR: AddressSanitizer: SEGV on unknown address 0x0000001001f4 (pc 0x7fd06687a013 bp 0x7ffc4fcca530 sp 0x7ffc4fcca4e0 T0)
==2797==The signal is caused by a READ memory access.
#0 0x7fd06687a012 in game::save_sram() daphne/daphne-1.0-src/game/game.cpp:212
#1 0x7fd066879fe5 in game::pre_shutdown() daphne/daphne-1.0-src/game/game.cpp:204
#2 0x7fd06686d6fa in main_daphne_shutdown() daphne/daphne-1.0-src/daphne.cpp:295
#3 0x7fd0668b9dcc in retro_deinit daphne/libretro/libretro.cpp:250
#4 0x419997 in core_unload /home/orbea/gittings/forks/RetroArch/core_impl.c:398
#5 0x4287d5 in command_event_deinit_core /home/orbea/gittings/forks/RetroArch/command.c:1087
#6 0x42c61a in command_event /home/orbea/gittings/forks/RetroArch/command.c:2291
#7 0x41d1c5 in retroarch_main_init /home/orbea/gittings/forks/RetroArch/retroarch.c:1428
#8 0x440d5e in content_load tasks/task_content.c:279
#9 0x443b58 in task_load_content tasks/task_content.c:880
#10 0x447dfc in task_load_content_callback tasks/task_content.c:1565
#11 0x448182 in task_push_load_content_from_cli tasks/task_content.c:1633
#12 0x416cff in rarch_main frontend/frontend.c:125
#13 0x416ec3 in main frontend/frontend.c:169
#14 0x7fd06cdc9ba6 in __libc_start_main (/lib64/libc.so.6+0x21ba6)
#15 0x40c4e9 in _start (/media/gittings/forks/RetroArch/retroarch+0x40c4e9)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV daphne/daphne-1.0-src/game/game.cpp:212 in game::save_sram()
==2797==ABORTING
NOTE: Please review and test this!
This fixes a crash when loading daphne without any content.
The problem is that it will crash in
game::pre_shutdown()
fromdaphne/daphne-1.0-src/game/game.cpp
whenm_nvram_size
is never set to0
.https://github.com/libretro/daphne/blob/4dd6fc8a70adb2266432c7ebb17ecab2dec867a1/daphne/daphne-1.0-src/game/game.cpp#L212
It will do this because when daphne exits it will attempt to save sram from unexpected exits, however
m_nvram_size
is only set if running a game. I think the easiest way to solve this is to check if a game was actually ran before trying to save sram and shutdown other things that were never started.I could not figure out how to successfully load content and have not made sure this doesn't break loading content as a result. I suspect it will be fine, but if someone who can test this properly will make sure I would really appreciate it.