Please Help! Recurrent CTD: How do I Isolate Error

riesscar

Chieftain
Joined
May 11, 2006
Messages
57
I sure hope that someone is willing to help me with this. I have a recurring CTD that produces a Python exception:

Traceback (most recent call last):

File "CvEventInterface", line 30, in onEvent

File "CvCustomEventManager", line 136, in handleEvent

File "CvCustomEventManager", line 147, in _handleDefaultEvent

File "CvEventManager", line 415, in onEndPlayerTurn

File "ModFunctions", line 115, in onEndPlayerTurn

RuntimeError: unidentifiable C++ exception
ERR: Python function onEvent failed, module CvEventInterface

I also generated a crash dump and used Windbg:

*******************************************************************************
* *
* Exception Analysis *
* *
*******************************************************************************

Loading symbols for 04340000 CvGameCoreDLL.dll -> CvGameCoreDLL.dll
*** WARNING: Unable to verify checksum for CvGameCoreDLL.dll
Loading symbols for 76480000 gdi32.dll -> gdi32.dll

FAULTING_IP:
CvGameCoreDLL!CvPlot::changeCombatTypeStrength+13
04478c33 66010c42 add [edx+eax*2],cx

EXCEPTION_RECORD: ffffffff -- (.exr ffffffffffffffff)
ExceptionAddress: 04478c33 (CvGameCoreDLL!CvPlot::changeCombatTypeStrength+0x00000013)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000001
Parameter[1]: 65695e90
Attempt to write to address 65695e90

DEFAULT_BUCKET_ID: APPLICATION_FAULT

PROCESS_NAME: Civ4Warlords.exe

ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%08lx referenced memory at 0x%08lx. The memory could not be %s.

WRITE_ADDRESS: 65695e90

BUGCHECK_STR: ACCESS_VIOLATION

THREAD_ATTRIBUTES:
LAST_CONTROL_TRANSFER: from 044b7c97 to 04478c33

STACK_TEXT:
0012fc3c 044b7c97 0000001b 1da6ff00 e30bd320 CvGameCoreDLL!CvPlot::changeCombatTypeStrength+0x13
0012fcb8 043aa022 00000000 ffffffff 00001b90 CvGameCoreDLL!CvUnit::kill+0x1f7
0012fcfc 043b0065 03b3fa58 015cd710 043fc760 CvGameCoreDLL!CvGame::createBarbarianUnits+0x482
0012fda8 043b038b 015cd710 0012fed0 043fc760 CvGameCoreDLL!CvGame::doTurn+0x285
0012fe4c 764acfd0 012b95cc 00000000 00000000 CvGameCoreDLL!CvGame::update+0xab
0012fe54 00000000 00000000 0012ff88 006a854d gdi32!AddFontResourceA+0x11


FOLLOWUP_IP:
CvGameCoreDLL!CvPlot::changeCombatTypeStrength+13
04478c33 66010c42 add [edx+eax*2],cx

SYMBOL_STACK_INDEX: 0

FOLLOWUP_NAME: MachineOwner

SYMBOL_NAME: CvGameCoreDLL!CvPlot::changeCombatTypeStrength+13

MODULE_NAME: CvGameCoreDLL

IMAGE_NAME: CvGameCoreDLL.dll

DEBUG_FLR_IMAGE_TIMESTAMP: 4ad79848

STACK_COMMAND: .ecxr ; kb

FAILURE_BUCKET_ID: ACCESS_VIOLATION_CvGameCoreDLL!CvPlot::changeCombatTypeStrength+13

BUCKET_ID: ACCESS_VIOLATION_CvGameCoreDLL!CvPlot::changeCombatTypeStrength+13

Followup: MachineOwner

I used Asserts but it I couldn't figure out which assert was the correct indicator of the problem... If I had to guess, I would say this one:

Assert Failed

File: CvPlayer.cpp
Line: 10467
Expression: getBuildingClassCount(eIndex) <= (GC.getBuildingClassInfo(eIndex).getMaxPlayerInstances() + GC.getBuildingClassInfo(eIndex).getExtraPlayerInstances())
Message: BuildingClassCount is expected to be less than or match the number of max player instances plus extra player instances
'

With regard to logs, they tell me nothing. My python debug log's last entry tells me that some city grew on the last turn. I wish that I knew how to set up logging so that all occurrences in a turn were sequentially recorded in an external log... that way I could pinpoint exactly what, where and who is generating the CTD. I know its possible, but I've searched high and low and I cant find an intelligible explanation of how to implement this sort of logging

Anyway, I have been at it for weeks and have had no success figuring out where things are going wrong. Could someone please offer me a suggestion? I will check back with frequency for a response and I will be glad to furnish any additional requisite data or info.

Thank you so much in advance!:)
 
Let's start a little further back. What have you changed? Are you using vanilla, plus some of your own python? Have you changed any of the sdk code on your own? Are there other modcomps which you have already integrated?

The key part of the dump which you gave is the following stack trace (less useful machine addresses removed)

CvPlot::changeCombatTypeStrength
CvUnit::kill
CvGame::createBarbarianUnits
CvGame::doTurn

So, createBarbarianUnits() called kill() which called changeCombatTypeStrength(). If you have changed any of these functions, start with your changes. If you are familiar with C programming, look at this trace in the code and see what could go wrong.
 
I am playing TRMOD 2.4 for Warlords. I have only added a civ, changed maxplayers, and modded map to facilitate those changes. I haven't added any python. The only sdk code ive touched is cvdefines.h in order to allow for more players on the map (from 24-27... added some already implemented minor civs to the map).
 
I am playing TRMOD 2.4 for Warlords. I have only added a civ, changed maxplayers, and modded map to facilitate those changes. I haven't added any python. The only sdk code ive touched is cvdefines.h in order to allow for more players on the map (from 24-27... added some already implemented minor civs to the map).

Just to check, after you changed cvdefines.h, you did a full recompile of all the objects, right?
 
Correct, I did a full compile. Since I wrote that post I have learned more about what is causing the crash, but I still haven't figured out how to fix it. Despite many other instable functions in the mod, as evidenced by assert errors, there is one that is behaving strangly and causing the CTD, while the others are causing behind the scenes isolated errors. After switching to a visualstudio2008 I used the debug function to find out as much as I could, and while I cant imagine fixing all of the bugs without affecting save compatibility, I would like to fix the crash if its possible and try and make it as far as I can. Here's what I know:

The mod uses a feature called 'stack aid' which increases unit strength according to number and quality of other units on the plot. The feature is malfunctioning and although I dont know why, I have a few ideas that may or may not be plausible.

First of all, when I changed max_players I did not do so in another header file that holds a related value: extrasavedata.h. This file has a value called extrasavedata_max_players that is referenced in concert with the max_players value of cvdefines.h... for what Im not exactly sure. I did discover this and edited and recompiled without save incompatibility, but the damage might've been done, as this may have screwed up the identification of certain units and teams.

The stackaid function is failing because it is trying to give crazily high and low negative numbers as values for combat strength, and it is only doing it with team=27, which are barbarians. I wonder if I went through and deleted all of the barbarian units if it might fix it... ill try it and probably come back sulking. As I write this I think it is less and less likely that you can help without having a copy of my modded mod and the savefile. What do you think?
 
Does the original mod randomly crash, before you made any changes? If so, then it is likely to be corrupting data on its own, and anything you add will just make things worse. If you are sure the original mod does not crash, then I suggest you back out *all* of your changes, and then add them in a few at a time to see when the crash starts.
 
Top Bottom