aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZnOw01 <ZnOw01@users.noreply.github.com>2026-10-30 09:35:24 -0500
committerZnOw01 <ZnOw01@users.noreply.github.com>2026-10-30 09:35:24 -0500
commit75b707a90ac8610e3a7da277e9291fd2ba4a6b52 (patch)
tree0b45f4f3d4193422aa8e4598fb9459e23bb69959 /src
parent24e3cb462e47b22edda334939123694ff6920e95 (diff)
yuzu_cmd: skip kernel teardown when nothing was booted
SDL_AppQuit runs on every exit path, including the ones where SDL_AppInit returned early: no ROM given, --help, or --version. The kernel only exists once a title is loaded, so Pause() and ShutdownMainProcess() walk into an uninitialized KernelCore and the process dies with SIGSEGV. The crash lands before spdlog flushes, which is why --version printed nothing instead of a version line. Guard the teardown on System::IsPoweredOn(), and ignore the null appstate SDL passes when SDL_AppInit never stored one. Assisted-by: Claude (Anthropic) (diagnosed the crash and wrote the guard)
Diffstat (limited to 'src')
-rw-r--r--src/yuzu_cmd/yuzu.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp
index 70fd9090e3..22abe6a759 100644
--- a/src/yuzu_cmd/yuzu.cpp
+++ b/src/yuzu_cmd/yuzu.cpp
@@ -491,9 +491,17 @@ extern "C" SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event) {
}
extern "C" void SDL_AppQuit(void *appstate, SDL_AppResult result) {
SdlState *state = (SdlState *)appstate;
+ if (!state) {
+ return;
+ }
state->system.DetachDebugger();
- void(state->system.Pause());
- state->system.ShutdownMainProcess();
+ // SDL calls this even when SDL_AppInit never powered the system on (no ROM given, --help or
+ // --version): the kernel is uninitialised then, and Pause()/ShutdownMainProcess() would
+ // dereference it.
+ if (state->system.IsPoweredOn()) {
+ void(state->system.Pause());
+ state->system.ShutdownMainProcess();
+ }
delete state;
}