Help! CTD without error message

evertebrate

Chieftain
Joined
Mar 30, 2009
Messages
76
Location
germany
I keep getting ctds with my mod. unfortunately it is to large to just post the whole mod for testing. can someone help me to locate the error?
i know that the error occours sometime in most games. sometimes when loading the autosave you can play just fine. other times the ctd happens every time at the same turn.
when this ctd happens, civ does not even ask me to make a dump file like with other ctds. it is not a python error and all my new functions seem to work, i made a custom log file to test it. it also does not semm to be memory allocation failure, because i get absolutely no error message. compiling a debug dll does also not give me any error message, it just ctds.

can anbody give me advice on how i could find out where the ctd happens? it seems to be while the ai does its turn, but before it moves any units. (i used ctrl-z and "show enemy moves" and it chrashes before anything happens) however all functions in AI_doTurn() are working successfully. are there any other methods to find an error?

the last line in the message log says "Rand = -232408448 on 12230 (AI Attack Odds Change #1)" however i never touched that function or any function that is calling it.
 
i already did that, but even in debug mode it crashes without warning or any message. the only thing i get is an assert failure the turn before the turn it crashes. something about "AI_getNumTrainAIUnits(eIndex) >= 0" which is in the function AI_changeNumTrainAIUnits(). but i don't know if this has anything to do with the crash and i never used this function.
 
If you run it in debug mode, it should break when it crashes and show you the code that caused it to crash. And I imagine that the failed assert has something to do with it. You probably edited some code that calls that function somewhere down the line.
 
i already did that, but even in debug mode it crashes without warning or any message. the only thing i get is an assert failure the turn before the turn it crashes. something about "AI_getNumTrainAIUnits(eIndex) >= 0" which is in the function AI_changeNumTrainAIUnits(). but i don't know if this has anything to do with the crash and i never used this function.

Ah yes. I see you wrote about the debug dll in your first post. My apologies.

Since that assert happens right before the crash, I would guess that they are somehow related. When you get that assert, debug it and look back through the call stack to see where the error is originating.

It that doesn't help, put a bunch of logging messages around the area that seems to be causing the problem. Then you can see what the last message was and figure out that the error occurs after that point but before the next log message and gradually narrow down the location of the troublesome code.
 
using the log system i found out, that the crash happens when calling AI_juggleCitizens() in one of the ai's cities. it is not important which city, it happens just in the first ai citiy where its called.
i still don't know what causes this. :confused: could it be a xml error? i never changed any function related to specialists or plots or yields.

edit: i am sorry, i was looking in the wrong place. the crash actually happens at AI_addBestCitizen(). still that doesn't help me a lot. i never changed anything there and i never called that function.
 
Just a hunch, but since citizens are employed between plots and specialist slots, it could be something to do with terrain/yields. So, some tile within the city's radius is breaking the logic at AI_addBestCitizen(). Double-check everything to do with tiles/terrain.
 
Just a hunch, but since citizens are employed between plots and specialist slots, it could be something to do with terrain/yields. So, some tile within the city's radius is breaking the logic at AI_addBestCitizen(). Double-check everything to do with tiles/terrain.

the problem is, it happens with every city. when i delete all cities but one with the world builder, it still crashes, no matter what city remains. i checked all functions with yields and plots, but i never changed anything in it. i even replaced my mods CIV4TerrainInfos.xml with the original from bts and it still crashes. i tested all the "city work" graphics for that era, and with all tile improvements. but none of that crashes the game.
also AI_addBestCitizen() works in all previous turns for all cities. so something seems to change on that turn. its not the era or a new technology or a new unit or building constructed nor is it a growing city. i tested all these.
i really don't know what else to do.
 
so i narrowed it down even further to the AI_yieldValue() function. it seems from one turn to the next this function fails to work. sorry, for the double post, im a little desperate, because i feel that every time i find something new, something else seems to be the problem. :confused: :confused: :confused:
 
Well, I think this just proves my theory. There is something wrong with your terrain info XML, causing the cities to crash once they try to make sense of it all.

Note that XML not only has to load - the actual values also has to make sense.
 
alright, i reversed almost all changes my mod made to the terrain files. (i had to keep the 2 new bonuses i added, although i prevented them from appearing and i had to keep the city ruins with arcology so it would load at all) - still it crashes. i can't make any sense out of this.
 
If you can't figure this issue out intellectually, then you need to start eliminating components of you mod, one after another. Alternatively start all over again with the basic BtS game and introduce components, only one at the time. Once the issue makes itself known, then you know what change caused it. It may still not make any sense, but at least you know what doesn't work.
 
so i narrowed it down even further to the AI_yieldValue() function.

(i had to keep the 2 new bonuses i added

Since you're having a crash in AI_yieldValue(), I would guess that it has something to do with your new bonuses. Can you give us info/code about these bonuses?

Also, you can add further debug logging within the AI_yieldValue() function to narrow down which section of the function is causing the error.
 
it crashes exactly at this part:

Code:
for (int iI = 0; iI < NUM_COMMERCE_TYPES; iI++)
	{
		if (aiCommerceYieldsTimes100[iI] != 0)
		{
			int iCommerceWeight = GET_PLAYER(getOwnerINLINE()).AI_commerceWeight((CommerceTypes)iI);
			if (AI_isEmphasizeCommerce((CommerceTypes)iI))
			{
				iCommerceWeight *= 200;
				iCommerceWeight /= 100;
			}
			if (iI == COMMERCE_CULTURE)
			{
				if (getCultureLevel() <= (CultureLevelTypes) 1)
				{
					iCommerceValue += (15 * aiCommerceYieldsTimes100[iI]) / 100;
				}
			}
			iCommerceValue += (iCommerceWeight * (aiCommerceYieldsTimes100[iI] * iBaseCommerceValue) * GET_PLAYER(getOwnerINLINE()).AI_averageCommerceExchange((CommerceTypes)iI)) / 1000000;
		}
	}

my new bonuses are as follows:

Code:
		<BonusInfo>
			<Type>BONUS_TOBACCO</Type>
			<Description>TXT_KEY_BONUS_TOBACCO</Description>
			<Civilopedia>TXT_KEY_YIELD_TOBACCO_PEDIA</Civilopedia>
			<BonusClassType>BONUSCLASS_GENERAL</BonusClassType>
			<ArtDefineTag>ART_DEF_BONUS_TOBACCO</ArtDefineTag>
			<TechReveal>NONE</TechReveal>
			<TechCityTrade>TECH_CALENDAR</TechCityTrade>
			<TechObsolete>NONE</TechObsolete>
			<YieldChanges>
				<iYieldChange>0</iYieldChange>
				<iYieldChange>0</iYieldChange>
				<iYieldChange>1</iYieldChange>
			</YieldChanges>
			<iAITradeModifier>0</iAITradeModifier>
			<iAIObjective>0</iAIObjective>
			<iHealth>0</iHealth>
			<iHappiness>1</iHappiness>
			<iPlacementOrder>5</iPlacementOrder>
			<iConstAppearance>50</iConstAppearance>
			<iMinAreaSize>3</iMinAreaSize>
			<iMinLatitude>0</iMinLatitude>
			<iMaxLatitude>60</iMaxLatitude>
			<Rands>
				<iRandApp1>10</iRandApp1>
				<iRandApp2>10</iRandApp2>
				<iRandApp3>0</iRandApp3>
				<iRandApp4>0</iRandApp4>
			</Rands>
			<iPlayer>100</iPlayer>
			<iTilesPer>0</iTilesPer>
			<iMinLandPercent>0</iMinLandPercent>
			<iUnique>0</iUnique>
			<iGroupRange>1</iGroupRange>
			<iGroupRand>50</iGroupRand>
			<bArea>1</bArea>
			<bHills>0</bHills>
			<bFlatlands>1</bFlatlands>
			<bNoRiverSide>0</bNoRiverSide>
			<bNormalize>1</bNormalize>
			<TerrainBooleans>
				<TerrainBoolean>
					<TerrainType>TERRAIN_GRASS</TerrainType>
					<bTerrain>0</bTerrain>
				</TerrainBoolean>
			</TerrainBooleans>
			<FeatureBooleans>
				<FeatureBoolean>
					<FeatureType>FEATURE_JUNGLE</FeatureType>
					<bFeature>0</bFeature>
				</FeatureBoolean>
				<FeatureBoolean>
					<FeatureType>FEATURE_FOREST</FeatureType>
					<bFeature>0</bFeature>
				</FeatureBoolean>
			</FeatureBooleans>
			<FeatureTerrainBooleans>
				<FeatureTerrainBoolean>
					<TerrainType>TERRAIN_GRASS</TerrainType>
					<bFeatureTerrain>0</bFeatureTerrain>
				</FeatureTerrainBoolean>
			</FeatureTerrainBooleans>
			<bUseLSystem>1</bUseLSystem>
		</BonusInfo>
		<BonusInfo>
			<Type>BONUS_COTTON</Type>
			<Description>TXT_KEY_BONUS_COTTON</Description>
			<Civilopedia>TXT_KEY_YIELD_COTTON_PEDIA</Civilopedia>
			<BonusClassType>BONUSCLASS_GENERAL</BonusClassType>
			<ArtDefineTag>ART_DEF_BONUS_COTTON</ArtDefineTag>
			<TechReveal>NONE</TechReveal>
			<TechCityTrade>TECH_CALENDAR</TechCityTrade>
			<TechObsolete>NONE</TechObsolete>
			<YieldChanges>
				<iYieldChange>0</iYieldChange>
				<iYieldChange>0</iYieldChange>
				<iYieldChange>1</iYieldChange>
			</YieldChanges>
			<iAITradeModifier>0</iAITradeModifier>
			<iAIObjective>0</iAIObjective>
			<iHealth>0</iHealth>
			<iHappiness>1</iHappiness>
			<iPlacementOrder>4</iPlacementOrder>
			<iConstAppearance>50</iConstAppearance>
			<iMinAreaSize>3</iMinAreaSize>
			<iMinLatitude>30</iMinLatitude>
			<iMaxLatitude>90</iMaxLatitude>
			<Rands>
				<iRandApp1>10</iRandApp1>
				<iRandApp2>10</iRandApp2>
				<iRandApp3>0</iRandApp3>
				<iRandApp4>0</iRandApp4>
			</Rands>
			<iPlayer>0</iPlayer>
			<iTilesPer>32</iTilesPer>
			<iMinLandPercent>0</iMinLandPercent>
			<iUnique>0</iUnique>
			<iGroupRange>0</iGroupRange>
			<iGroupRand>0</iGroupRand>
			<bArea>1</bArea>
			<bHills>1</bHills>
			<bFlatlands>1</bFlatlands>
			<bNoRiverSide>1</bNoRiverSide>
			<bNormalize>1</bNormalize>
			<TerrainBooleans>
				<TerrainBoolean>
					<TerrainType>TERRAIN_GRASS</TerrainType>
					<bTerrain>0</bTerrain>
				</TerrainBoolean>
				<TerrainBoolean>
					<TerrainType>TERRAIN_PLAINS</TerrainType>
					<bTerrain>0</bTerrain>
				</TerrainBoolean>
			</TerrainBooleans>
			<FeatureBooleans/>
			<FeatureTerrainBooleans/>
			<bUseLSystem>1</bUseLSystem>
		</BonusInfo>

although it seems now that the problem is related to commerces?
 
YIELD_COMMERCE is a YieldType, yes...
 
Is Visual Studio breaking when the crash occurs? I've never had the game crash without Visual Studio breaking. You are running a debug DLL and attaching to the process in Visual Studio, right?

Alternatively, you could set "Generate Crash Dumps" to 1 in the .ini, which will then ask you if you want to save a diagnostic file when the game crashes. Click either normal dump or full dump (I'm not sure exactly what the difference is :dunno:), and it will save it to Documents and Settings\Owner\Local Settings\Temp\Civ4BeyondSword.exe.dmp. Open the file with Visual Studio, click Debug->Start New Instance, and it will debug the crash as if the game was running.

Or, if you are already doing one of these things, could you post the exact line where it's crashing?
 
i already tried to generate crash dumps before and that never worked. it just crashed without asking.
i wasjust using the other method you described, and visual studio is giving me this error on crash:

Code:
Unhandled exception at 0x029da749 (CvGameCoreDLL.dll) in Civ4BeyondSword.exe: 0xC00000FD: Stack overflow.

also i was getting a very strange assertion faillure. it was telling me, that a PROJECT_CURE_CANCER was not found and was referencing from the CIV4EspionageMissionInfo.xml - however there are noreferences to that project in this xml file, i didn't even modify it for my mod. its also not present in the custom assets folder. in fact i cannot find that project anywhere in the xml files. that is very strange. :confused:
 
Back
Top Bottom