bmaupin / civ-be-linux-fixes

Fixes for various bugs in Beyond Earth on Linux
2 stars 0 forks source link

Crash when loading save game with different DLC #1

Closed bmaupin closed 1 month ago

bmaupin commented 1 month ago

To reproduce:

  1. Start Beyond Earth with Rising Tide installed
  2. Disable Rising Tide
  3. Start a new game with a mod that affects save games
  4. Save the game
  5. Exit the game
  6. Enable Rising Tide
  7. Try to load the save game

To test:

An arithmetic exception can be triggered either by dividing by zero, or overflow of a signed integer

bmaupin commented 1 month ago

Backtrace:

Thread 13 "CivBE" received signal SIGFPE, Arithmetic exception.
0x08c97e41 in ?? ()
(gdb) bt
#0  0x08c97e41 in ?? ()
#1  0x08c97d72 in cvRiverSimSystem::IsRiver(Hex::Edge const&) const ()
#2  0x08c06ef8 in cvFloodplainsSystem::BuildTileLists(FFastVector<cvFloodplainsSim, false, 1010u, 0u, FTempHeapFastVectorAllocator>&, FFastVector<Hex::Edge, true, 1009u, 0u, FTempHeapFastVectorAllocator>&, cvFloodplainsSystem::RIVERBANK_FLAG) ()
#3  0x08c06cc1 in cvFloodplainsSystem::BuildFloodplains(FFastVector<FFastVector<Hex::Edge, true, 1009u, 0u, FTempHeapFastVectorAllocator>, false, 1009u, 0u, FTempHeapFastVectorAllocator> const&) ()
#4  0x08b3028c in TerrainSystem::Init(DynamicHexGrid<HexPatternCell, SquareGridPolicy, 0u, 0u>&, bool, unsigned int) ()
#5  0x08acdf53 in LoadGameState::InitTerrainFromGameplay() ()
#6  0x08acbee4 in LoadGameState::LaunchNextStage() ()
#7  0x08acf580 in LoadGameState::Update(float) ()
#8  0x089f7b05 in CivBEApp::OnIdle() ()
#9  0x089f6859 in CivBEApp::Tick(AppHost::TickInfo const*) ()
#10 0x0903b6e8 in AppHost::RunApp(int, char**, AppHost::Application*) ()
#11 0x0903a8d0 in AppHost::RunApp(char*, AppHost::Application*) ()
#12 0x089f0ff8 in WinMain ()
#13 0x08987301 in ?? ()
#14 0x089bfcb5 in ThreadHANDLE::ThreadProc(void*) ()
#15 0xf7486c01 in ?? () from /lib/i386-linux-gnu/libc.so.6
#16 0xf752372c in ?? () from /lib/i386-linux-gnu/libc.so.6
bmaupin commented 1 month ago

Troubleshooting:

First, Rising Tide is unloaded and mod is loaded

Thread 13 "CivBE" hit Breakpoint 3, 0x08a5f4c2 in CvModdingFrameworkAppSide::SetActiveDLCandMods(cvContentPackageIDList const&, std::__1::list<ModAssociations::ModInfo, std::__1::allocator<ModAssociations::ModInfo> > const&, bool, bool) ()
(gdb) print_dlc *(void**)($sp+0x4)+0x5d4
GUID: 0xd188c918:   0x54d2b257  0x4045c591  0x9fa6178f  0xc7663103
GUID: 0xb49b3a38:   0x3f49df54  0x44d168b6  0x68a130a9  0x59aa8f62
(gdb) print_dlc *(void**)($sp+0x8)
GUID: 0x8e8a09c8:   0x3f49df54  0x44d168b6  0x68a130a9  0x59aa8f62
(gdb) print_mods *(void**)($sp+0x4)+0x5e0
(gdb) print_mods *(void**)($sp+0xc)
GUID: 0xa86fc748:   "9412c9bf-a7b2-481e-b42e-431f06aac221"

Next, they're both loaded

Thread 13 "CivBE" hit Breakpoint 3, 0x08a5f4c2 in CvModdingFrameworkAppSide::SetActiveDLCandMods(cvContentPackageIDList const&, std::__1::list<ModAssociations::ModInfo, std::__1::allocator<ModAssociations::ModInfo> > const&, bool, bool) ()
(gdb) print_dlc *(void**)($sp+0x4)+0x5d4
GUID: 0xd188c918:   0x3f49df54  0x44d168b6  0x68a130a9  0x59aa8f62
(gdb) print_dlc *(void**)($sp+0x8)
GUID: 0xaf4cd5f8:   0x3f49df54  0x44d168b6  0x68a130a9  0x59aa8f62
(gdb) print_mods *(void**)($sp+0x4)+0x5e0
GUID: 0xb1588618:   "9412c9bf-a7b2-481e-b42e-431f06aac221"
(gdb) print_mods *(void**)($sp+0xc)
GUID: 0x6c18f228:   "9412c9bf-a7b2-481e-b42e-431f06aac221"

Finally, the mod is unloaded??

Thread 13 "CivBE" hit Breakpoint 3, 0x08a5f4c2 in CvModdingFrameworkAppSide::SetActiveDLCandMods(cvContentPackageIDList const&, std::__1::list<ModAssociations::ModInfo, std::__1::allocator<ModAssociations::ModInfo> > const&, bool, bool) ()
(gdb) print_dlc *(void**)($sp+0x4)+0x5d4
GUID: 0xd188c918:   0x3f49df54  0x44d168b6  0x68a130a9  0x59aa8f62
(gdb) print_dlc *(void**)($sp+0x8)
GUID: 0xa386c8d8:   0x3f49df54  0x44d168b6  0x68a130a9  0x59aa8f62
(gdb) print_mods *(void**)($sp+0x4)+0x5e0
GUID: 0xb1588618:   "9412c9bf-a7b2-481e-b42e-431f06aac221"
(gdb) print_mods *(void**)($sp+0xc)
bmaupin commented 1 month ago

0x08c97e41 ... this is in the binary, right?

Rising Tide initial memory address:

0xb50b0b60  0xb55d2da0  Yes         /home/bmaupin/.local/share/Steam/steamapps/common/Sid Meier's Civilization Beyond Earth/steamassets/../libCvGameCoreDLL_Expansion1.so

Base game CvGameCore address at time of crash:

0x636631b0  0x63b05408  Yes         /home/bmaupin/.local/share/Steam/steamapps/common/Sid Meier's Civilization Beyond Earth/steamassets/../libCvGameCoreDLL_BeyondEarth.so

... so maybe this is unrelated to CvGameCore?

bmaupin commented 1 month ago

Given that this seems to be unrelated to the patch for fixing the crash when using mods and there's a relatively easy workaround for it, I'm not going to bother worrying about it.