Skip to content

Commit 4f5fe8d

Browse files
Fix: Delay critical section cleanup to prevent static destructor crashes
1 parent 6be5b2c commit 4f5fe8d

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

Generals/Code/Main/WinMain.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -853,10 +853,14 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
853853

854854
}
855855

856-
TheAsciiStringCriticalSection = NULL;
857-
TheUnicodeStringCriticalSection = NULL;
858-
TheDmaCriticalSection = NULL;
859-
TheMemoryPoolCriticalSection = NULL;
856+
// TheSuperHackers @bugfix Sentry 05/01/2025 Don't set critical sections to NULL before static destructors run.
857+
// Static objects like TheWritableGlobalData contain AsciiString members that need the critical sections
858+
// during their destruction. The critical section objects (critSec1-5) are static locals and will be
859+
// destroyed automatically after this function returns, which is the correct cleanup order.
860+
// TheAsciiStringCriticalSection = NULL;
861+
// TheUnicodeStringCriticalSection = NULL;
862+
// TheDmaCriticalSection = NULL;
863+
// TheMemoryPoolCriticalSection = NULL;
860864

861865
return exitcode;
862866

0 commit comments

Comments
 (0)