fix(headless): Fix use-after-free crash when replay ends in headless mode in debug build#2219
fix(headless): Fix use-after-free crash when replay ends in headless mode in debug build#2219bobtista wants to merge 2 commits intoTheSuperHackers:mainfrom
Conversation
Greptile Overview
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp | Changed ParticleSystemManager from reset() to update() to prevent use-after-free crash with DrawModule raw pointers |
| GeneralsMD/Code/Main/WinMain.cpp | Set DX8Wrapper_IsWindowed to false in headless mode to suppress assertion dialogs during shutdown |
Sequence Diagram
sequenceDiagram
participant Main as WinMain
participant GD as GlobalData
participant DX8 as DX8Wrapper
participant GC as GameClient
participant PSM as ParticleSystemManager
participant DM as DrawModules
Note over Main,DX8: Startup (WinMain.cpp)
Main->>GD: Check m_headless
alt headless mode
Main->>DX8: Set DX8Wrapper_IsWindowed = false
Note over DX8: Enables ignoringAsserts()<br/>throughout process lifetime
else windowed mode
Main->>Main: initializeAppWindows()
end
Note over GC,DM: Headless Replay Loop
loop Each frame
GC->>PSM: updateHeadless()
PSM->>PSM: update() (NEW)
Note over PSM: Only deletes finished<br/>particle systems
Note over PSM,DM: DrawModules' raw pointers<br/>remain valid
end
Note over GC,DM: Shutdown
Main->>GC: Cleanup game
GC->>DM: Destroy DrawModules
Note over DM: Safe: particle systems<br/>still exist if active
GC->>PSM: Final cleanup
xezon
left a comment
There was a problem hiding this comment.
Fast shutdown is a common way to exit apps, but it is not a good sign to do this to avoid problems here. Where is the problem exactly?
…articleSystemManager::update() instead of reset()
… suppress assertion dialogs during shutdown
Did a bunch of testing and found the crash was:
Pushed two fixes - first, we use update() instead of reset(), which leaves active particles intact. Second, I was getting memory leak debug asserts even with ignoreAsserts enabled. It seems that: The second fix is to set |
0fc66f8 to
3198cff
Compare
|
After the changes in #2235 to use and search for ParticleID's instead of holding pointers, is this valid anymore? |
Summary
ParticleSystemManager::reset()deleting all particle systems while DrawModules still hold raw pointers to them. Useupdate()instead, which only cleans up finished systems.DX8Wrapper_IsWindowedto false in headless mode soignoringAsserts()works correctly during shutdown afterTheGlobalDatahas been destroyed.Test plan
-replay test.rep -headless -ignoreAsserts)