Skip to content

[GEN][ZH] Fix Memory Manager initialization issues #1275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

xezon
Copy link

@xezon xezon commented Jul 13, 2025

This change fixes Memory Manager initialization issues and is an alternative implementation to #1236.

The Memory Pools are now created before the debug logging is initialized. To not lose asserts during Memory Manager initialization, the DEBUG_CRASH can now create message boxes without logging.

TODO

  • Replicate in Generals

@xezon xezon requested a review from helmutbuhler July 13, 2025 20:34
@xezon xezon added Minor Severity: Minor < Major < Critical < Blocker ThisProject The issue was introduced by this project, or this task is specific to this project Memory Is memory related Fix Is fixing something, but is not user facing labels Jul 13, 2025
Copy link

@helmutbuhler helmutbuhler left a comment

Choose a reason for hiding this comment

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

Very nice, thanks!

@xezon xezon force-pushed the xezon/fix-memory-initialization-issues-2 branch from 733e293 to bc3b27c Compare July 14, 2025 20:19
@xezon
Copy link
Author

xezon commented Jul 14, 2025

Replicated to Generals with conflicts

$ git diff e5110b67b2f6224a78d97e6cf7a65ca8c5b3e2c4..4247d471ed2ba3c7795f24acc91f0571adb73f91 > changes.patch

$ git apply -p2 --directory=Generals --reject --whitespace=fix changes.patch
changes.patch:86: trailing whitespace.
                if (ignoringAsserts())
changes.patch:109: trailing whitespace.
        if (result == IDIGNORE && TheCurrentIgnoreCrashPtr != NULL)
changes.patch:136: trailing whitespace.
                else
changes.patch:203: trailing whitespace.

Checking patch Generals/Code/GameEngine/Source/Common/System/Debug.cpp...
Hunk #1 succeeded at 166 (offset -1 lines).
Hunk #2 succeeded at 362 (offset -1 lines).
Hunk #3 succeeded at 480 (offset -1 lines).
Hunk #4 succeeded at 493 (offset -1 lines).
Checking patch Generals/Code/GameEngine/Source/Common/System/GameMemory.cpp...
Hunk #1 succeeded at 124 (offset -2 lines).
Hunk #2 succeeded at 3424 (offset 10 lines).
Hunk #3 succeeded at 3436 (offset 10 lines).
Hunk #4 succeeded at 3490 (offset 10 lines).
Hunk #5 succeeded at 3500 (offset 10 lines).
Hunk #6 succeeded at 3547 (offset 10 lines).
Checking patch Generals/Code/Main/WinMain.cpp...
Hunk #1 succeeded at 768 (offset -26 lines).
error: while searching for:
                gLoadScreenBitmap = (HBITMAP)LoadImage(hInstance, "Install_Final.bmp", IMAGE_BITMAP, 0, 0, LR_SHARED|LR_LOADFROMFILE);
#endif

                // register windows class and create application window
                if(!TheGlobalData->m_headless && initializeAppWindows(hInstance, nCmdShow, TheGlobalData->m_windowed) == false)
                        return exitcode;

error: patch failed: Generals/Code/Main/WinMain.cpp:834
Hunk #3 succeeded at 803 (offset -51 lines).
Hunk #4 succeeded at 826 (offset -51 lines).
Hunk #5 succeeded at 844 (offset -52 lines).
Applied patch Generals/Code/GameEngine/Source/Common/System/Debug.cpp cleanly.
Applied patch Generals/Code/GameEngine/Source/Common/System/GameMemory.cpp cleanly.
Applying patch Generals/Code/Main/WinMain.cpp with 1 reject...
Hunk #1 applied cleanly.
Rejected hunk #2.
Hunk #3 applied cleanly.
Hunk #4 applied cleanly.
Hunk #5 applied cleanly.

@xezon xezon merged commit 9c8b539 into TheSuperHackers:main Jul 14, 2025
14 checks passed
@xezon xezon deleted the xezon/fix-memory-initialization-issues-2 branch July 14, 2025 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Is fixing something, but is not user facing Memory Is memory related Minor Severity: Minor < Major < Critical < Blocker ThisProject The issue was introduced by this project, or this task is specific to this project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix debug memory crash on exit in VS22 due to recent TheGlobalData refactor
2 participants