Bug Reports

Well, I was wrong here. I converted the save over to RevDCM, and still got this CvUnitSelectionGroupAI assert failure, but it didn't have a fatal hang. So went pack and reanalyzed the save and the fatal hang. This time I isolated it to a single unit. It's a modded unit of mine, the Pathfinder. But here is the thing, there is no art bug, and the XML is fine with this unit. I've seen hundreds of them around in test games, and no problem (they are a strength 6 upgrade for explorers). Never had this hang reported in 1.02. So on a hunch I thought it might be AI related, and changed the unit's AI type to UNITAI_EXPLORE from UNITAI_ATTACK, changing it to explore fixes this fatal hang.

I then tried replicating this with explorerers and other pathfinders, to no avail. It seems to be some issue intrinsic to this particular stack. The AI is at war with all his neighbors in this case, and it looks like this is a City Attack stack that is being built, if that helps. Also all recon units have been modded so that they can attack but not capture. I'll try to see if I can get this hang to reproduce somehow, but so far it seems to be something that happens when the AI looks at this particular stack...

Edit:
Well no luck. I swapped the pathfinder for an explorer, but the AI just upgraded to a pathfinder. No further hangs, whatever issue it had on the previous turn seemed to be fixed. The I tried remove the tech to upgrade, but it just sends the attack stack out with an explorer fine...

Edit2:
Well I still can't figure out how to reproduce this. The only way I can get the crash to happen is if a pathfinder unit is in the city with the samuri and has it's AI set to UNITAI_ATTACK on that specific turn. Changing anything, AI type, the tile the pathfinder is in doesn't replicate it. And replacing the pathfinder with an explorer doesn't cause a fatal hang either. I'm totally stumped. I'll show a picture of the unit and what's going on (switched to this player to show the situation, this is also how I isolated the cause of this hang):
Spoiler :
Crash.jpg


Oh and unit stats, Explorer is the same as default BtS explorer except it may attack (but not capture), and doesn't have the free promos, instead gets +20% defense on hills and forest/jungles. Pathfinder is the same as an explorer except it is strength 6, has a 20% withdraw chance, and has a base 30% strength on hills and forest/jungle. Anyway totally stumped here. Any ideas? I could look through the Unit AI code if I had some idea of what to look for.
 
Oh man ... that is a weird one.

I was trying to come up with things which could cause a problem, and had a couple ideas which didn't turn out to be problems ... in BBAI 0.7, AI pathfinding routines for Great Generals were changed, and these are sometimes spawned in enemy territory in Revolution. But the game handles that okay (could be better, but doesn't crash).

But now that you've isolated it to that "pathfinder" unit, I'm a bit stumped as well. Since you've narrowed it down to that unit running UNITAI_ATTACK and nothing else, the possibilities are that either:

- During that unit's turn in CvUnitAI::AI_attackMove(), it somehow enters an infinite loop and crashes.
- That unit first joins a group (the samurais I'm guessing), and then during the group's move turn in CvUnitAI::AI_xxxMove(), the code enters an infinite loop and crashes ... where xxx could be attack or attackCity or something else.

My hunch would be the latter and that the samurais are going off to capture a worker or some such action but that the newly added pathfinder can't do that, resulting in some kind of problem. I would suggest that your custom unit should either be able to capture or should only be given UNITAI_EXPLORE ... weird things will happen when you add a unit with some limitations to a stack which otherwise doesn't have that limitation. The AI may not check that all units in the stack can execute what the head unit can.

It's a guess, but that's the best I've got.
 
Thanks for the response jdog.

I've narrowed it down further. The only differences in a pathfinder and explorers are:
1)prereque techs
2)Strength
3)Withdrawl
4)terrain bonuses

Now the only one that made sense here that would flub the AI routines would be withdrawl (since the terrain bonuses are only a difference in degree and not type). So my first thing to try was to eliminate the 20% withdrawl chance for pathfinders.
Result: No hang

So we now know this fatal hang is related to giving a unit with NoCapture a withdrawl chance if it is in a stack and has the UnitAI UNITAI_ATTACK. Now like I've said I've tried to recreate the conditions, and can't reproduce this, so we know it's rare bug. But this was never reported in RevDCM 1.02, so I believe it is something that's changed in BetterAI 0.7 and must be in a UNITAI_ATTACK routine that is effected by withdrawl chances. Also of note, these same unit atributes also apply to gunships.

Any chance this further insight could lead to fixing this?

Edit: Actually on second thought I have seen reports of unexplained hangs from previous BetterAI builds, so this may go back a long ways...

Edit2: Further testing. Replacing the pathfinder with a default horseman did not elicit the fatal hang, so it is not entirely based on withdrawl. However editing horseman in the XML so that they could not capture did cause the same hang. So this is almost definatly a bug that will cause a fatal hang with default BtS gunships.
 
Great detective work, phungus! ;)
 
Thanks, just hope it's enough for jdog or glider to track the cause in the code so it can be fixed. I have a theory here. In the save where this crash occurs there is a city that's 3 tiles away that Hirohito is at war with. If I remove the withdraw so the hang doesn't occur the AI sends it's attack stack with the pathfinder next to the city. So I'm thinking the way to reproduce this fatal bug would be to set up a situation where the AI has an attack stack it sends at an enemy city and the attack stack ends up next to the city with all the units having 0 movement points left except for a unit that has a withdraw chance and can't capture. At least I think that might work as a way to set up a reproduceable test. This seems to be the recepie that's causing this at least.
 
Well, I am going to add to phungus' findings, even though this might not be the proper forum for it. I have found a very similar bug to the one phungus has located. In my case, I am using a merge of Better AI 0.70, DCM, IDW and some other stuff, but NOT Revolutions (which is why I think phungus' bug also originates in Better AI 0.70). The scenario is a duel map (an oasis map, so almost no water), only two civs, and no war. The game crashes at a certain point. I was able to isolate it to a single catapult - if this cat was removed, the crash no longer occurred. Using phungus' finding, I just tried to change the UNITAI in the worldbuilder - and the crash also no longer occurs.

The turn before the crash, a Keshik (Mongol UU) with UNITAI_ATTACK moves into a plot. A Catapult with UNITAI_ATTACK_CITY comes from another direction and moves to the same plot. On the next turn, their UNITAI's are unchanged, but the game crashes. Again, if I change the UNITAI of the catapult, the game does NOT crash. If I remove the Keshik from the game, it also crashes.

Using a debug version of the dll gives me nothing, the debugger stops at a non sensical plase in CvCity.h.

1) I think it safe to at least rule out the Revolutions component, since I'm not using it at all.
2) DCM should also be ruled out, since there was no wars going on in my game. Same for IDW.
3) Somewhere in the life of Better AI, I think this glitch must have occurred. It's pretty elusive, so it might not be new to Better AI 0.70.

I have savegames and dll's available if anyone is interested. :)
 
Testing further. Starting a game in the future era using default RevDCM, creating a stack with Mechanized infantry and a gunship and setting all units to UNITAI_ATTACK in the stack leads to a crash when at war with a neighbor. Easy to reproduce so no need to upload a save.
 
Easy to reproduce so no need to upload a save.

Damn, after all that hard work you have done to find a bug (thanks), and then to miss the big one, to save the file, zip it and upload it (5 minutes). A save makes it much easier to debug I cannot stress it enough!

Cheers.
 
Well, I dont' think it's the same bug.

The critical bug I've been tracking is caused by:
An attack stack with 1 move units and one 2 move unit moving onto a tile next to an enemy city. The 1 move units have no movement points left, and the 2 move unit has retreat odds can still move and is set as UNITAI_ATTACK and cannot capture. This causes a fatal hang.

This is a very hard scenario to replicate as you basically have to luck out with the AI making such a stack, and moving it the way it needs to reproduce it. But if you can get the AI to do this, it'll cause a fatal hang.


The bug here: http://forums.civfanatics.com/showpost.php?p=8096881&postcount=467 I said was easy to replicate, is easy to replicate, but it's different (also it causes an assert, which the fatal hang does not). But I'm not even sure it's truly a bug, it may only be possible to create this situation through AI autoplay. Basically make a stack with multiple 1 or 2 move units, set all their AIs to UNITAI_ATTACK, group said units with a gunship. Prex ctrl+alt+x and let the AI take a turn, this will crash. That's really easy to replicate, but like I said, maybe not necessary to fix, at is may only be causable by the human setting up the conditions and going into autoplay.

Now the first bug, this one is fatal, and is causing problems in game. That's the one I'm really interested in seeing a fix for, as it's the main thing holding up development of Legends of Revolution right now :please:
And just so it doesn't get lost, full details on this fatal bug can be found in this post:
http://forums.civfanatics.com/showpost.php?p=8094439&postcount=463
 
Well, I dont' think it's the same bug.

The critical bug I've been tracking is caused by:
An attack stack with 1 move units and one 2 move unit moving onto a tile next to an enemy city. The 1 move units have no movement points left, and the 2 move unit has retreat odds can still move and is set as UNITAI_ATTACK and cannot capture. This causes a fatal hang.

This is a very hard scenario to replicate as you basically have to luck out with the AI making such a stack, and moving it the way it needs to reproduce it. But if you can get the AI to do this, it'll cause a fatal hang.


The bug here: http://forums.civfanatics.com/showpost.php?p=8096881&postcount=467 I said was easy to replicate, is easy to replicate, but it's different (also it causes an assert, which the fatal hang does not). But I'm not even sure it's truly a bug, it may only be possible to create this situation through AI autoplay. Basically make a stack with multiple 1 or 2 move units, set all their AIs to UNITAI_ATTACK, group said units with a gunship. Prex ctrl+alt+x and let the AI take a turn, this will crash. That's really easy to replicate, but like I said, maybe not necessary to fix, at is may only be causable by the human setting up the conditions and going into autoplay.

Now the first bug, this one is fatal, and is causing problems in game. That's the one I'm really interested in seeing a fix for, as it's the main thing holding up development of Legends of Revolution right now :please:
And just so it doesn't get lost, full details on this fatal bug can be found in this post:
http://forums.civfanatics.com/showpost.php?p=8094439&postcount=463

Right now I'm trying to recreate the second bug you're reporting ... no luck so far. Here's what I'm doing (I control the French):

1. I control the French, who are at war with several neighbors.
2. Place two French marines and two French tanks in French territory using Worldbuilder.
3. Check that those units have UNITAI_ATTACK.
4. Place a French helicopter nearby (tried both same tile and neighboring tile). Check helicopter has UNITAI_ATTACK.
5. Group the marines and tanks.
6. (Move them along roads to tile with helicopter)
7. Add helicopter to the group.

I've also tried starting them in enemy territory, no asserts and no crashes so far.

Is there some other formula to follow which triggers the asserts? What exactly are you doing which makes it happen reliably?
 
Right now I'm trying to recreate the second bug you're reporting ... no luck so far. Here's what I'm doing (I control the French):

1. I control the French, who are at war with several neighbors.
2. Place two French marines and two French tanks in French territory using Worldbuilder.
3. Check that those units have UNITAI_ATTACK.
4. Place a French helicopter nearby (tried both same tile and neighboring tile). Check helicopter has UNITAI_ATTACK.
5. Group the marines and tanks.
6. (Move them along roads to tile with helicopter)
7. Add helicopter to the group.

I've also tried starting them in enemy territory, no asserts and no crashes so far.

Is there some other formula to follow which triggers the asserts? What exactly are you doing which makes it happen reliably?

You're right, I can't reproduce it. I thought it would be simple since it crashed right away, and I also assumed that it was caused by me making a group the AI never would. Stupid assumption should have saved the game and uploaded.

Anyway here is a save that produced a crash. I'm trying to reproduce the hang from gatling gun's save for legends. Unfortunatly converting it to RevDCM looses alot of stuff, and the AI behaves differently. So It hasn't sent the attack stack out to attack the city it did when it hung... So . .. .. .. .ing frustrating. Also, making things even more frustrating is the fact this save I'm uploading wol't always crash, in fact it only did once, the first time I ran it, reloading hasn't been able to reproduced the crash. I think this is because the random seed changes on reloading, caused by going to WB save format I guess. I'm uploading it because assuming you run this save a bunch of times you should get it to make whatever decision it made which caused the crash (every time I try the save the stupid horse archer goes to a differnt place), and also the crash had the same failed assert message as that reported in the second crash type above. Also of note you'll probably need to change Horse Archers to not capture, and turn off battle effects, as these were the conditions in which the crash occured. I tried to run the save a few times to get it to reproduce, but it takes about 15 minutes to load the game on my old machine, and was driving me nuts... Also same thing is driving me crazy trying to get the hang to reproduce. I keep trying to set up the conditions that caused the hang, but the AI never sends it's attack stack up to the English city like it did when the hang occured... And it takes about 10 minutes to run each turn, so it's taking forever. If downloading isn't a problem, please consider trying the save and mod which has this reproduceable hang occuring, WB saving it has ruined reproduceablility and trying to get this to trip again is driving me mad, because the stupid . .. .. .. .ing AI wol't do what it needs to to cause it :mad::mad::mad::mad:
 
Also got an instance of the crash in this save. This one reproduces, at least it tripped twice in a row (and remember to make Horse Archers no capture and turn off battle effects):

BTW this is the failled assert message:
Code:
Assert Failed

File:  CvUnitAI.cpp
Line:  22157
Expression:  pDefender != NULL
Message:
Still haven't gotten the hang to reporduce though, because the damned AI refuses to send it's entire attack stack at the city....
 
(EDIT: was just looking at Better BTS AI code first time ...)

That assert is triggered in AI_RbombardNaval, ie it's in the logic for ranged bombard in Dale's Combat Mod ... this issue could be causing the crash, though I can't see how immediately. It means that under certain conditions an attacker can think it can range-bombard units in a particular tile, but that when it comes time to actually do the bombard there is no acceptable unit there.

If this is the source of all the crashes you're reporting, it's easy to fix ... and, if you turn off ranged bombard in the problem saves, they should no longer crash. This issue would fit with the difficult to reproduce nature of the problem, as ranged bombards are quite probabilistic I think.
 
Whoa, that assert should only be firing for an airstrike! Is that a possibility here?

No, no one has flight yet. This is the same assert the fired that I said was easy to reproduce though, at least I'm nearly sure it is (It was line 20,000 and something and the expression Expression: pDefender != NULL is the same). Like before, it's triggered when I was trying to reproduce the afformentioned fatal hang.
 
Yep, turning off Ranged Bombard caused that assert not to trip, and no subsequent crash.

Unfortunately it had no effect on the fatal hang originally reported. I've spent about 6 hours today trying to get the AI to send it's attack stack at that damn city and reproduce the hang in default RevDCM, but it refuses to :mad:
Any chance you'd be willing to just look at the save causing this hang, I know it isn't pure RevDCM, but try as I might I can't get the AI to reproduce the behavior that causes it (sending an attack stack at a city with a 2 move unit that cannot capture and has a withdraw chance, where the 2 move unit still has one move left, but the rest of the attack stack runs out of moves, and the 2 move unit is running UNITAI_ATTACK).
 
I checked in a simple fix for the DCM issue, so that should be taken care of.

As for the other bug, I feel your pain on trying to replicate it ... these things which require several stars to align to happen are really hard to produce. My plate is full during the week this week, but I'll see if I can manage on the weekend to try debugging the save.
 
Back
Top Bottom