diff options
| author | quarrel07 <quarrel-07atolls@icloud.com> | 2026-06-28 17:41:26 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-29 02:41:26 +0200 |
| commit | d1dec0f6f437cf5342a8514f23741da9ded95485 (patch) | |
| tree | f98306b154bbf2844b4ced9df31caf986c767696 /src/port/Engine.cpp | |
| parent | dfee19f91e9030ccfdb2d38a3773c7e8995c361d (diff) | |
Fix crash when bailing out of first-run setup before the game inits (#707)
InitModsSystem() runs before the game world is set up. Its bail-out paths (no
O2R + user declines generation, missing mods.toml, cyclic/outdated mod deps,
and GenAssetFile's no-ROM / unsupported-ROM cases) call exit(), which runs the
global `static World sWorldInstance` destructor -> World::CleanWorld() ->
dereferences Sky::Instance and other singletons that are still null this early,
segfaulting. The most visible case: declining the first-run "Generate one now?"
prompt pops a crash report instead of quitting cleanly.
Use _Exit() on these pre-initialization bail-outs so no static destructors run.
Co-authored-by: quarrel07 <paeans-toggle-2e@icloud.com>
Co-authored-by: coco875 <59367621+coco875@users.noreply.github.com>
Diffstat (limited to 'src/port/Engine.cpp')
| -rw-r--r-- | src/port/Engine.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index b6ba9a226..5120c82a2 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -1,5 +1,6 @@ #include "Engine.h" +#include <cstdlib> #include "ship/utils/StringHelper.h" #include "GameExtractor.h" #include "mods/ModManager.h" @@ -269,14 +270,16 @@ bool GameEngine::GenAssetFile() { if (!extractor->SelectGameFromUI()) { ShowMessage("Error", "No ROM selected.\n\nExiting..."); - exit(1); + // _Exit, not exit: this runs before the game world is initialized, so running the + // global World destructor (CleanWorld) would dereference still-null singletons and crash. + _Exit(1); } auto game = extractor->ValidateChecksum(); if (!game.has_value()) { ShowMessage("Unsupported ROM", "The provided ROM is not supported.\n\nCheck the readme for a list of supported versions."); - exit(1); + _Exit(1); } ShowMessage(("Found " + game.value()).c_str(), |
