LoneGazebo / Community-Patch-DLL

Community Patch for Civilization V - Brave New World
Other
286 stars 158 forks source link

Game constantly crashes on the same late game turn #4901

Closed SauliHa closed 5 years ago

SauliHa commented 5 years ago
  1. Mod version :11/9

  2. Mod list (if using Vox Populi only, leave blank):Vox Populi + InfoAddict

  3. Error description: Game cannot progress past turn 372, since i get CTD during AI turn. Have tried reloading an autosave few turns earlier but to no avail.

  4. Steps to reproduce (optional): Proceed past turn 372 and you should get CTD.


Save file and CvMiniDump:

save&dump.zip

GitHubRub commented 5 years ago

I can confirm that your save file results in a crash for me too, during the America AI's turn. Furthermore, the circumstances of your crash mirror the ones I experience in my own game (playing as Ottomans). Attaching Visual Studio reveals that the following exception:

Exception thrown: read access violation. FAutoVariable<std::vector<int,std::allocator >,CvUnit>::operator returned nullptr.

is raised in CvUnit.cpp line 26386: return m_yieldFromScouting[eIndex];

used in the function: int CvUnit::getYieldFromScouting(YieldTypes eIndex) const

In both your game and mine this happens when an AI captures a city state that had been conquered by another AI. In your game that city is Ur, which is controlled by the Huns and conquered by America during its turn, crashing the game. In my game the city is Tyre, which had been conquered by Mongolia and again by Arabia during their turn, crashing the game.

Looking at the stack seems to confirm the problem: the game goes through AttackCity() and then UnitMove(), implying the attack was successful. This eventually leads to a null pointer.

I used IGE https://steamcommunity.com/sharedfiles/filedetails/?id=77002777&searchtext=ige

to give Ur to America, so they wouldn't need to conquer it. This allowed the turn to complete without crashing.

Lastly, I noticed that in both cases the city states were puppets of the first AI before being conquered by the second AI. I don't think the fact they are puppets is the issue, however, as I used IGE to set the city state as a normal city owned by the AI and the crash still occurred.

ilteroi commented 5 years ago

now this is a very good bug report!

do you also have the exact line in UnitMove() where the null ptr is dereferenced?

GitHubRub commented 5 years ago

Here's a screenshot of the whole stack, so you can see the lines for all the functions:

voxpopuli_citystatecrash_stack

Let me know when a hotfix is applied. I'll recompile and test it on my PC.

ilteroi commented 5 years ago

hmm. unfortunately the root cause isn't quite obvious ... what nullptr are you referring to exactly?

because your watch window in the screenshot says that this is 0x5ea41748.

GitHubRub commented 5 years ago

This one:

exception 2

ilteroi commented 5 years ago

aha. looks more like the index is out of bounds ... since eYield is 0, it means m_yieldFromScouting is not initialized, which should be impossible unless the unit has been killed. maybe it's a use-after-free?

ilteroi commented 5 years ago

seems i can reproduce it in my testgame. it's a bit tricky but a fix should be forthcoming.

GitHubRub commented 5 years ago

My most recent Civ V binge has come to an end (due to excessive micromanagement in the mid/late game, as always), but I'm glad I was able to help.

ryanmusante commented 5 years ago

@GitHubRub well than just move it from a binge to casual play. Contribute to some of the modmods. I take months of time away from playing to troubleshoot and test code. It's just as much fun seeing the game evolve as it is to immerse yourself.