Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(gameengine): name the module and the INI line behind a crash

Olcay Seygan0153b0c2d4fa
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp b/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp
index ca50b0d59..1cc71e0b4 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp
@@ -391,8 +391,14 @@ void INI::load( AsciiString filename, INILoadType loadType, Xfer *pXfer )
} catch (...) {
DEBUG_CRASH(("Error parsing block '%s' in INI file '%s'\n", token, m_filename.str()) );
+ /* The line the block *started* on, which is what this used to report on its own,
+ is rarely the line that is wrong: the parser has read its way down the block by
+ the time anything throws. m_lineNum is where it actually got to, and the last
+ thing it read is usually the answer. Without it a report of this reads "one of
+ these nine fields", and the only way on is to guess. */
char buff[1024];
- sprintf(buff, "Error parsing INI file '%s' (Line: '%s')\n", m_filename.str(), currentLine.str());
+ sprintf(buff, "Error parsing INI file '%s' (Line: '%s', reached line %d: '%s')\n",
+ m_filename.str(), currentLine.str(), m_lineNum, m_buffer);
throw INIException(buff);
}
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp
index a32a80aa3..d43b29c37 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp
@@ -299,9 +299,31 @@ void GetFunctionDetails(void *pointer, char*name, char*filename, unsigned int* l
{
*address = (unsigned int)line.Address;
}
- }
+ }
}
}
+ else if (name)
+ {
+ /* No symbol for it, which for anything outside this exe is the normal case: a system DLL,
+ the Direct3D runtime, a display driver. The stack then read `<Unknown> 0x582843F0` for
+ every one of those frames, which says nothing at all - a crash inside a driver during a
+ device reset looked exactly like a crash inside the game. The module and the offset into
+ it are free and are the whole of the answer: `d3d9on12.dll+0x143f0` is something that can
+ be looked up, argued about, and worked around. */
+ HMODULE module = NULL;
+ if (::GetModuleHandleEx( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
+ (LPCSTR)pointer, &module ) && module != NULL)
+ {
+ char modulePath[ MAX_PATH ];
+ modulePath[ 0 ] = 0;
+ if (::GetModuleFileName( module, modulePath, sizeof( modulePath ) ) > 0)
+ {
+ const char *leaf = strrchr( modulePath, '\\' );
+ leaf = leaf ? leaf + 1 : modulePath;
+ sprintf( name, "%s+0x%X;", leaf, (unsigned int)((char *)pointer - (char *)module) );
+ }
+ }
+ }
}