Skip to content

Conversation

@xezon
Copy link

@xezon xezon commented Oct 26, 2025

This change tentatively fixes a hang in the file exist cache. It was observed when loading a map with a VS2022 build.

The logic was stuck in an infinite hash map lookup.

The theory is that 2 threads modified the FileSystem::m_fileExist map at the same time and corrupted its state.

The callstack indicates that the texture loader thread was perhaps involved, which is one of the few multi threaded systems in the game process.

Perhaps it is a VS2022 specific issue. VC6 builds use a different hash map implementation.

>	generalszh.exe!rts::string_key_equal<AsciiString>::operator()(const rts::string_key<AsciiString> & a, const rts::string_key<AsciiString> & b) Line 292	C++
 	generalszh.exe!std::_Uhash_compare<rts::string_key<AsciiString>,rts::string_key_hash<AsciiString>,rts::string_key_equal<AsciiString>>::operator()<rts::string_key<AsciiString>,rts::string_key<AsciiString>>(const rts::string_key<AsciiString> & _Keyval1, const rts::string_key<AsciiString> & _Keyval2) Line 150	C++
 	generalszh.exe!std::_Hash<std::_Umap_traits<rts::string_key<AsciiString>,FileSystem::FileExistData,std::_Uhash_compare<rts::string_key<AsciiString>,rts::string_key_hash<AsciiString>,rts::string_key_equal<AsciiString>>,std::allocator<std::pair<rts::string_key<AsciiString> const ,FileSystem::FileExistData>>,0>>::_Find_last<rts::string_key<AsciiString>>(const rts::string_key<AsciiString> & _Keyval, const unsigned int _Hashval) Line 1596	C++
 	generalszh.exe!std::_Hash<std::_Umap_traits<rts::string_key<AsciiString>,FileSystem::FileExistData,std::_Uhash_compare<rts::string_key<AsciiString>,rts::string_key_hash<AsciiString>,rts::string_key_equal<AsciiString>>,std::allocator<std::pair<rts::string_key<AsciiString> const ,FileSystem::FileExistData>>,0>>::_Find<rts::string_key<AsciiString>>(const rts::string_key<AsciiString> & _Keyval, const unsigned int _Hashval) Line 1221	C++
 	generalszh.exe!std::_Hash<std::_Umap_traits<rts::string_key<AsciiString>,FileSystem::FileExistData,std::_Uhash_compare<rts::string_key<AsciiString>,rts::string_key_hash<AsciiString>,rts::string_key_equal<AsciiString>>,std::allocator<std::pair<rts::string_key<AsciiString> const ,FileSystem::FileExistData>>,0>>::find(const rts::string_key<AsciiString> & _Keyval) Line 1232	C++
 	generalszh.exe!FileSystem::doesFileExist(const char * filename, unsigned char instance) Line 230	C++
 	generalszh.exe!GameFileClass::Set_Name(const char * filename) Line 189	C++
 	generalszh.exe!GameFileClass::GameFileClass(const char * filename) Line 82	C++
 	generalszh.exe!W3DFileSystem::Get_File(const char * filename) Line 458	C++
 	generalszh.exe!file_auto_ptr::file_auto_ptr(FileFactoryClass * fac, const char * filename) Line 64	C++
 	generalszh.exe!DDSFileClass::DDSFileClass(const char * name, unsigned int reduction_factor) Line 57	C++
 	generalszh.exe!Get_Texture_Information(const char * filename, unsigned int & reduction, unsigned int & w, unsigned int & h, unsigned int & d, WW3DFormat & format, unsigned int & mip_count, bool compressed) Line 1319	C++
 	generalszh.exe!TextureLoadTaskClass::Begin_Compressed_Load() Line 1413	C++
 	generalszh.exe!TextureLoadTaskClass::Begin_Load() Line 1187	C++
 	generalszh.exe!TextureLoadTaskClass::Finish_Load() Line 1256	C++
 	generalszh.exe!TextureLoader::Request_Foreground_Loading(TextureBaseClass * tc) Line 749	C++
 	generalszh.exe!TextureClass::Init() Line 869	C++
 	generalszh.exe!TextureClass::TextureClass(const char * name, const char * full_path, MipCountType mip_level_count, WW3DFormat texture_format, bool allow_compression, bool allow_reduction) Line 757	C++
 	generalszh.exe!WW3DAssetManager::Get_Texture(const char * filename, MipCountType mip_level_count, WW3DFormat texture_format, bool allow_compression, TextureBaseClass::TexAssetType type, bool allow_reduction) Line 1113	C++
 	generalszh.exe!W3DAssetManager::Get_Texture(const char * filename, MipCountType mip_level_count, WW3DFormat texture_format, bool allow_compression, TextureBaseClass::TexAssetType type, bool allow_reduction) Line 183	C++
 	generalszh.exe!Render2DClass::Set_Texture(const char * filename) Line 134	C++
 	generalszh.exe!W3DDisplay::drawImage(const Image * image, int startX, int startY, int endX, int endY, int color, Display::DrawImageMode mode) Line 2646	C++
 	generalszh.exe!GameWindowManager::winDrawImage(const Image * image, int startX, int startY, int endX, int endY, int color) Line 80	C++
 	generalszh.exe!W3DGameWinDefaultDraw(GameWindow * window, WinInstanceData * instData) Line 331	C++
 	generalszh.exe!GameWindowManager::drawWindow(GameWindow * window) Line 1233	C++
 	generalszh.exe!GameWindowManager::winRepaint() Line 1288	C++
 	generalszh.exe!W3DInGameUI::draw() Line 434	C++
 	generalszh.exe!W3DDisplay::draw() Line 1858	C++
 	generalszh.exe!LoadScreen::update(int percent) Line 168	C++
 	generalszh.exe!MultiPlayerLoadScreen::update(int percent) Line 1473	C++
 	generalszh.exe!GameLogic::updateLoadProgress(int progress) Line 1110	C++
 	generalszh.exe!GameLogic::startNewGame(bool loadingSaveGame) Line 1323	C++
 	generalszh.exe!GameLogic::update() Line 3684	C++
 	generalszh.exe!SubsystemInterface::UPDATE() Line 73	C++
 	generalszh.exe!GameEngine::update() Line 922	C++
 	generalszh.exe!Win32GameEngine::update() Line 90	C++
 	generalszh.exe!GameEngine::execute() Line 985	C++
 	generalszh.exe!GameMain() Line 55	C++
 	generalszh.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 903	C++
 	generalszh.exe!invoke_main() Line 107	C++
 	generalszh.exe!__scrt_common_main_seh() Line 288	C++
 	generalszh.exe!__scrt_common_main() Line 331	C++
 	generalszh.exe!WinMainCRTStartup(void * __formal) Line 17	C++
 	kernel32.dll!74e05d49()	Unknown
 	[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]	
 	ntdll.dll!7730d6db()	Unknown
 	ntdll.dll!7730d661()	Unknown

@xezon xezon added this to the Stability fixes milestone Oct 26, 2025
@xezon xezon added Critical Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour Crash This is a crash, very bad System Is Systems related labels Oct 26, 2025
Copy link

@Skyaero42 Skyaero42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@Skyaero42 Skyaero42 added the Approved Pull Request was approved label Oct 27, 2025
@xezon
Copy link
Author

xezon commented Oct 27, 2025

Added a code comment to describe the bug fix

@xezon xezon merged commit 789af64 into TheSuperHackers:main Oct 27, 2025
17 checks passed
@xezon xezon deleted the xezon/fix-filesystem-hang branch October 27, 2025 19:49
fbraz3 pushed a commit to fbraz3/GeneralsX that referenced this pull request Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved Pull Request was approved Crash This is a crash, very bad Critical Severity: Minor < Major < Critical < Blocker System Is Systems related ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants