LoneGazebo / Community-Patch-DLL

Community Patch for Civilization V - Brave New World
Other
282 stars 157 forks source link

Freeze on barbarian turn. #3901

Closed tu-79 closed 6 years ago

tu-79 commented 6 years ago

1. Mod version (i.e Date - 4/23):

2018-01-21

2. Mod list (if using Vox Populi only, leave blank): FlagPromotions InfoAddict Improved City View

3. Error description:

Freeze on barbarian turn.

4. Steps to reproduce (optional):

Logs.zip AutoSave_0216 AD-1530.zip This time I have a recent savegame. I just spread religion in one aztec city and killed a hunnic dromon.

Supporting information: Please note that you can attach .zip files by dragging-and-dropping them. If possible, zip up all supporting data and post that way.

  1. Log files (always attach your Logs folder, located at My Documents/My Games/Sid Meier's Civilization 5. Make sure you have enabled logging before experiencing an error! Go here to find out how: http://forums.civfanatics.com/showthread.php?t=487482):

  2. Save game (always attach a save that was made a turn before the error; located at My Documents/My Games/Sid Meier's Civilization 5/ModdedSaves):

  3. CvMiniDump.dmp file (attach if experiencing a game crash. Located at Program Files/Steam/steamapps/common/Sid Meier's Civilization V):

  4. Screenshots (optional):

Jotaro31400 commented 6 years ago

yes i've got the same issue i will join my log soon.

Infixo commented 6 years ago

Is FlagPromotions affecting save files? If not, can you load the save without it and see if the problem exists?

Padre19 commented 6 years ago

Same issue for me without FlagPromo.

ilteroi commented 6 years ago

we're not making progress. i can't reproduce it.

once more: i need a save where all i need to do is to press "end turn". otherwise any unit i move in a different way than you influences the game state and we'll never catch this.

tu-79 commented 6 years ago

But then I need to manually save just before hitting NEXT button. Because I don't know if I'm going to be able to reproduce exactly all my steps in the last turn.

EDIT. Anyway, if reloading solves the problem, I wish to continue this game, it's the first time in a while that I'm ahead. And I want to see if I can stop than hunnic invasion with such a small army.

LoneGazebo commented 6 years ago

@ilteroi I think I caught the freeze:

DangerPlots.cpp Line 972

m_lastResults.push_back(std::make_pair(unitStats, iPlotDamage));

It crashed here with access invalid due to location choice during a barb turn - stack was a simple path lookup for a unit.

LoneGazebo commented 6 years ago

If I can get more info I will.

ilteroi commented 6 years ago

crash or freeze?

anyway, i think your callstack is shot or you simply ran out of memory.

more info definitely appreciated.

tu-79 commented 6 years ago

I have 8GB RAM. Map is small. I almost never had freezes before. And that other time was a bug that only affected Windows 7 machines. I'll try to provide more info, but I'm a bit busy now looking for a school for my son. My wife won't appreciate that I spend so much time 'playing'.

ilteroi commented 6 years ago

no worries, i was talking to G :)

LoneGazebo commented 6 years ago

Freeze. I can’t get it to replicate and I didn’t realize what I’d caught until I’d already de-linked the debugger. :( Bugger all!

Eriktheread commented 6 years ago

Byzantines, huge map, 14 civs. Getting this every 1-4 turns. Unplayable right now. Other mods: Wonder race, unit path, city limit viewer. Save:

AutoSave_0112 BC-0075.zip

Logs: Logs.zip

XplosiveLun commented 6 years ago

Here's another case. Freeze twice in recent turns. Unusual because it used NOT to happen in a chain. One coincident I discovered is it may be related to Barbarian capturing a city state.

Mods:

Saves & logs: Mongo AutoSave 100-102.zip Logs.zip

ilteroi commented 6 years ago

the freeze probably occured to me as well, but when i stepped into it none of the threads were in the game core DLL. that's bad. means it's either a latent vanilla bug we managed to trigger somehow, or possibly a lua issue.

LoneGazebo commented 6 years ago

@Infixo is it possible that this is related to some new lua you've written? I've now had the freeze happen to me twice while in the civilopedia...it feels like an infinite loop is happening in lua, that's my guess.

ilteroi commented 6 years ago

can you maybe build a version without the recent UI changes so that we can verify the lua theory?

Infixo commented 6 years ago

UI Lua is not executed during AI turns, is it? At least I have not seen any PlayerDoTurn events or similar, in EUI. Do we have a save file with just VP that causes problems? I’m running test games all the time and have not encountered this issue. Occasional CTD if there is a bug, but not the freeze. The only weird case I had recently was with 3/4UC project when FireTuner started to loose InGame context and crashed. I’m asking about clean save file because e.g. UnitPathViewer is not fully compatible with VP - Akamal privately fixed it. Civilopedia - do you refer to the situation that the cursor changed into „processing” and stayed? if so, this is not freeze, the cursor normally works (there was a normal bug with one of fields, that I have fixed); if something else - let me know on which article, and I’ll check

Infixo commented 6 years ago

Ok, I'm at the computer so I can check. I am basically changing:

Plus one-timers:

Any version from releases before Dec, 15th should do.

Infixo commented 6 years ago

I ran the file from @Eriktheread. 20 turns manually, no problems. But I cannot run in auto-play. I get CTD in DangerPlots::ResetDangerCache(const CvPlot* pCenterPlot, int iRange), stack is like SetAIAutoPlay->SetAllPlotsVisible->AddKnownAttacker. I don't know if this is related at all, maybe some other bug, but definetely a bad sign.

Edit. Interesting comment in the code: "//open up a slot if required - it seems Really Advanced Setup does not leave observer slots but sets them all to closed". And then it goes into the CTD section (he uses RASv15).

ilteroi commented 6 years ago

interesting.

i did recently make a change to AddKnownAttacker, so there might be a bug there. will check but that's not the problem we're looking for.

the freeze doesn't seem to happen during autoplay and it doesn't seem to be reproducable so that points to a UI issue. don't know why it would only occur during the barbarian turn though.

deadstarre commented 6 years ago

I autosave every turn. First time I froze was on turn 35, appearing during barbarian turn but when i rebooted and got back into the game, turn 36s auto save was there - as if turn 35 had fully completed, even though itd appeared to freeze. I loaded up the turn 36 save expecting to continue on, and it froze again before I could click start from the the portrait loading screen. so in that way, i did confirm a freeze occurring not during barbs turn, hopefully that means something to anybody. unfortunately I no longer have either save

Infixo commented 6 years ago

Re:CTD Internal table m_DangerPlots is not initialized (NULL). I've made a temp fix, and it's working.

Freeze could be due to Lua script, but I can hardly imagine an UI because nothing is executed without the player action. Also - entire UI is available during auto-play - you can go into every city, open city view, etc. And as you say - somehow auto-play is immune to the problem? On the other hand - FlagPromos and UnitPathViewer are constantly monitoring all units and have a ton of code that is executed automatically. Plus they use persistent storage which is well... not the most reliable thing in Civ5. I would really like to see a report from a clean VP install, without these mods.

Eriktheread commented 6 years ago

If we havnt found this by the time I start a new game Ill load one up without the path viewer.

I also autosave every turn. Dunno if its related.

LoneGazebo commented 6 years ago

The two times it froze for me I was doing auto play and had the civilopedis open.

LoneGazebo commented 6 years ago

*Civilopedia (my phone hates this word)

Infixo commented 6 years ago

But what article did you open? Civilopedia doesn't do anything by itself. Until you click something, nothing happens, it just displays static text.

Infixo commented 6 years ago

Anyway, I tried also tu_79's file. Played 20 turns manually, then auto-played, nothing happens.

LoneGazebo commented 6 years ago

@Infixo I think I was browsing wonders?

ilteroi commented 6 years ago

path viewer is probably not to blame, tu79's save doesn't use it.

regarding autoplay i really meant unattended autoplay.

Infixo commented 6 years ago

Maybe we should announce a bug hunt. Looking for a save file from clean VP game, no mods, that has that issue and it is repeatable.

If this UI related then basically everyone should get that problem. But it is still rather very rare. I’m leaning towards memory problems and they can be accelerated by mods. We should also ask people how many turns they played until freeze happened.

Legoras commented 6 years ago

Sorry for interrupting, but I reading EUI thread and there sometimes people have identical freeze, with no other mods, even without Vox. So maybe it is Only because EUI ?

Infixo commented 6 years ago

@Legoras Can you give a link?

Eriktheread commented 6 years ago

It might just be anecdotal, but Ive noticed it happening more frequently when I have another section of the UI open, like a city screen or the tech tree. Current game was smooth up to turn ~100, now its freezing every 4 or 5 turns.

Legoras commented 6 years ago

@Infixo I only read last 6 pages EUI thread, I think will be more there. 1.29 freeze, sometimes people back to 1.28 and it fixed, but sometimes 1.28 also crash. I dont know which version Vox use [as base]

https://forums.civfanatics.com/threads/enhanced-user-interface.512263/page-137#post-14797954 [freeze] https://forums.civfanatics.com/threads/enhanced-user-interface.512263/page-139#post-14837841 [hang] https://forums.civfanatics.com/threads/enhanced-user-interface.512263/page-140#post-14865657 [crash] https://forums.civfanatics.com/threads/enhanced-user-interface.512263/page-141#post-14885503 [crash] https://forums.civfanatics.com/threads/enhanced-user-interface.512263/page-142#post-14923931 [freeze]

Update: https://forums.civfanatics.com/threads/enhanced-user-interface.512263/page-136#post-14757103 [ freeze] https://forums.civfanatics.com/threads/enhanced-user-interface.512263/page-136#post-14796185 [freeze]

LoneGazebo commented 6 years ago

IIRC there is a limited amount of memory that the UI can access at any one time - if that amount is exceeded, it can cause issues. At one point bc1 had to remove some value caching methods to overcome this issue. I believe that there is chance that some recent additions to the code are causing this. @Infixo I'm not saying it is bad code, it's not, but rather that the UI can only handle so much without freezing.

Infixo commented 6 years ago

32-bit Lua on 64-bit machines can access up to 1GB of memory (due to some weird technicalities it is less than on 32-bit machines). I suppose it shares memory with Civ5.exe which is also 32-bit. Maybe if people are using many mods or running games on big maps then it really hits some memory issues. Let's see if anybody with clean VP will have problems.

LoneGazebo commented 6 years ago

I'm getting pretty consistent crashes that happen in the lua exe now. Something's up.

Infixo commented 6 years ago

In what configuration? Auto-play or manual? Post a save file, pls.

LoneGazebo commented 6 years ago

Auto-play. Right now it's inconsistent, and the minidumps are varying between lua and civ5 exe. Hmm...

Infixo commented 6 years ago

Don't know what to say. I am auto-playing 300+ turns game on 1-26 code + my usual UI mods. Not a single problem.

ryanmusante commented 6 years ago

I had a freeze on turn 366 on marathon speed during barbarian turn. I didn't have logging enabled this time. Before the freeze, task manager had executable using 1.9 GB. I am using additional UI mods as seen.

barb_frereze_turn366

bigcat88 commented 6 years ago

Maybe this will help, this minidump from yesterday. I have disabled autosaves. Almost clear VP, only Enchanced Naval , really advanced setup, ige and wonder race.

CvMiniDump.zip

LoneGazebo commented 6 years ago

I've been going through the code from 1-14, and - in the DLL - the only questionable spots I've seen are in CvPlot:

getNumUnitsOfAIType getFirstUnitOfAITypeSameTeam getFirstUnitOfAITypeOtherTeam

I think they're probably fine, but 'while' statements are the biggest culprits for hangs in the DLL.

LoneGazebo commented 6 years ago

also GetNumSpecificFriendlyUnitCombatsAdjacent is new and has a while statement in it.

LoneGazebo commented 6 years ago

Other than that, the only major new code changes are @Infixo's lua and @ilteroi's rewrite of the dominance zones logic. Neither of which update during the barbarian turn. I'm stumped.

ilteroi commented 6 years ago

let's do this systematically. create a version with only the c++ changes and a version with only the lua changes and see which one causes the freezes.

Infixo commented 6 years ago

Some other functions use while(pUnitNode != NULL) but these use only while (pUnitNode). Theoretically it should be the same, but it's always safer to check directly for NULL?

LoneGazebo commented 6 years ago

@ilteroi you can do that pretty easily- grab the current 'official' version and replace (6) EUI compatibility with it: https://mega.nz/#!zV9SkJqB!r-ZfpBs_Oyq4Is2-trvDSUqC9ZsOTn3GMHCyDfjBC78

Infixo commented 6 years ago

To test anything you need a file that causes problems every time not sometimes. Otherwise you won’t know if lack of problems is a result of ’sometimes’ or the fix. Do we have such file?

LoneGazebo commented 6 years ago

@Infixo not a reliable one, no.