Savegames from other people sometimes crash when using a debug DLL

Maniac

Apolyton Sage
Joined
Nov 27, 2004
Messages
5,588
Location
Gent, Belgium
But they don't crash if I use a normal DLL instead. Any idea what could cause this?

I get the following error message. Ignore doesn't work - I get the same message again an infinite number of times. Retry crashes the game.



The error refers to this code:

Code:
template <class T>
void FFreeListTrashArray<T>::load(T* pData)
{
	int iIndex;

	assert(pData != NULL);
	assert((pData->getID() & FLTA_ID_MASK) < m_iCurrentID);
	assert(m_pArray != NULL);

	iIndex = (pData->getID() & FLTA_INDEX_MASK);

	assert(iIndex < FLTA_MAX_BUCKETS);
	assert(iIndex <= m_iLastIndex);
	assert(m_pArray[iIndex].pData == NULL);
	assert(m_pArray[iIndex].iNextFreeIndex == FFreeList::INVALID_INDEX);

	m_pArray[iIndex].pData = pData;
}

***

I also always get an error message when starting the game. On that message I can simply click Ignore though. And the game then runs without any problem.

That's for Planetfall's debug DLLs. I have compiled a debug DLL for vanilla BtS before, and then I didn't get this message. No clue what could cause this though. The makefiles for the Planetfall and vanilla debug DLL are identical, except for adding two new cpp/h files to the Planetfall makefile.



Code:
//---------------------------------------------------------------------------------------
// inline bool FVariableSystem::GetValue( const char * szVariable, int & iValue ) const
//---------------------------------------------------------------------------------------
//! \brief Gets the value of the given variable
//! \param szVariable The name of the variable containing the value to query
//! \param iValue Contains the value of the variable if the function succeeds
//! \retval true if the variable value was retrieved, false otherwise (value will be unchanged from input).
//---------------------------------------------------------------------------------------
inline bool FVariableSystem::GetValue( const char * szVariable, int & iValue ) const
{
	FVariable * pkVariable;
	VSIteratorC iIterator;
	iIterator = m_mapVariableMap.find ( szVariable );
	if ( iIterator == m_mapVariableMap.end())
	{
		return false;
	}
	pkVariable = iIterator->second;
	assert( pkVariable->m_eType == FVARTYPE_INT );
	iValue = pkVariable->m_iValue;
	return true;
}
 
An update.

The reason I want to investigate saves with a debugger is because of a persistent crash after clicking endturn. I have now discovered that saves from 18 turns before the save that crashes upon clicking endturn, start crashing when loading them with a debug DLL.

I have also narrowed down the problem to m_iCurrentID of 'FFreeListTrashArray<CvPlotGroup> m_plotGroups' of one AI player becoming negative in between turns.

If I remove the ability of barbarian Isles of the Deep to blockade, then the problem goes away: m_iCurrentID stays positive. Unfortunately I can't pin down the problem to a single IoD. Perhaps that's because the saves I was provided use Random Seed Reload. I don't know. So I'm stuck again.

Does anyone what the hell FFreeListTrashArrays are, what m_iCurrentID is, how it gets changed and how it could become negative? Is there some function I could put a breakpoint or assery in to figure this out? I've put a couple in the code below, but for some reason it doesn't cause assert messages. :confused:

FFreeListTrashArray.h
Code:
void setCurrentID(int iNewValue)
	{
		assert((iNewValue & FLTA_INDEX_MASK) == 0);
		assert((iNewValue & FLTA_ID_MASK) != 0);
		assert((iNewValue & FLTA_ID_MASK) > 0); // Planetfall Maniac
		assert(iNewValue > 0); // Planetfall Maniac
		m_iCurrentID = iNewValue;
	}
 
Are you able to link the debugger? This function is a basic function that saves modders from having to actually understand fundamental code principals and commands, as such it is used for MANY different items which need not have anything to do with one another at all. In an attached process Debugger you would see a stack trace which ought to show you WHICH list/array is being dealt with at the time. If it has to do with blockade capabilities I would suspect it is the traderoutes (try setting the global setting of max trade routes per city to 0 and see if that prevents the crash, though setting that mid-game might have other issues which break saves...)
 
Are you able to link the debugger?

The error occurs during loading a save. So I just get debug info as shown in the screenshot. Is that meaningful info?

Anyway, I had the idea to comment out the assert. (Why didn't I think of this earlier? :rolleyes: ) Then I could load the save with a debug DLL. It turns out the crash is completely unrelated to that plotgroup trasharray. So problem solved for now.

Still it is weird that m_iCurrentID can end up having a negative value. I wonder if this is an indication of some other problem or bug.
 
Bah, stacktrace in the screenie shows that it is deep in exe processes unfortunately, so no clue what/where it is happening to try and fix it unfortunately. Thus there is no way to know for sure if that is an issue or not (ideally the line following whatever made this call accounts for the possibility of a failure and there is no lasting impact).
 
Top Bottom