Skip to content

Commit de54dab

Browse files
committed
fix(particle): Fix use-after-free crash in headless replay by using ParticleSystemManager::update() instead of reset()
1 parent 75d5937 commit de54dab

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,11 +786,16 @@ void GameClient::updateHeadless()
786786
// TheSuperHackers @info helmutbuhler 03/05/2025
787787
// When we play a replay back in headless mode, we want to skip the update of GameClient
788788
// because it's not necessary for CRC checking.
789-
// But we do reset the particles. The problem is that particles can be generated during
789+
// But we do update the particles. The problem is that particles can be generated during
790790
// GameLogic and are only cleaned up during rendering. If we don't clean this up here,
791791
// the particles accumulate and slow things down a lot and can even cause a crash on
792792
// longer replays.
793-
TheParticleSystemManager->reset();
793+
// TheSuperHackers @fix bobtista 02/02/2026 Use update() instead of reset() to avoid
794+
// use-after-free crash. reset() deletes all particle systems immediately, but DrawModules
795+
// (W3DTruckDraw, W3DTankDraw, etc.) hold raw pointers to particle systems. When those
796+
// DrawModules are later destroyed during game shutdown, they crash accessing freed memory.
797+
// update() only cleans up finished particle systems, leaving active ones intact.
798+
TheParticleSystemManager->update();
794799
}
795800

796801
/** -----------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)