[GEN][ZH] Fix crash in StateMachine when a chained StateMachine update deletes the executor StateMachine#890
Conversation
There was a problem hiding this comment.
This header was never used... so FAIL_IF failed to compile. No clue what that was supposed to be.
There was a problem hiding this comment.
I am guessing it was some older form of custom assert like the debug asserts.
|
I wonder if this behaviour is also why i see leaked Ai states at times. This will need some further testing for compat. It will definitely break compat in the situation it fixes, but then the vanilla game crashes at that point anyway. |
|
I think this fix does not break compat at all. It does not change what the StateMachine does. |
It probably doesn't, i was just considering if there are any other silent issues surrounding this same problem that affect the transfer still. But the parent state machine should still be destroyed in the same frame so probably doesn't affect the transfer. This fix just made me think of the fix for the garrison contain initialisation. That fix caused a mismatch in the end since it changed initial contain behaviour from being multi to single framed. |
98521c6 to
4addf04
Compare
Mauller
left a comment
There was a problem hiding this comment.
Looks good to me, i tested VC6 with GR1 and it was fine.
I also tested without the fix and could replicate the issue with a battlebus filled with low health rebels, a humvee didn't seem to cause the same issue. So this must have some unique code path due to how the battlebus dies.
Tested locally with fix and all looked good.
|
I think in the future we should ref count all states and state machines or have some form of dirty flag a state can set that can tell a state machine to clean itself up at the end of it's update. |
|
I looked at State class, and I think these need no attention, because they are childs of StateMachine and bound to its life time. So as long as StateMachine lives, then so will all its contained States. |
There was a problem hiding this comment.
This should be called "machine" rather than state to match the convention used within states.
4addf04 to
f2165ac
Compare
|
Rebased with recent main for testing purposes. |
|
@helmutbuhler Shared a replay that crashed the game, it appears that it was also due to an attacking battlebus being hit by a nuclear weapon. This PR allowed the replay to end gracefully with the scorescreen appearing. |
…e deletes the executor StateMachine
f2165ac to
44ae554
Compare
…e deletes the executor StateMachine (TheSuperHackers#890)
…e deletes the executor StateMachine (TheSuperHackers#890)
This change fixes a crash in
StateMachinethat happens when a chainedStateMachineupdate destroys the prior executorStateMachine. This issue happened with #212, where the Ranger'sStateMachinein the Bus would kill the Power Plant, and then the Power Plant weapon would kill the Bus, which would then delete theStateMachineof the Ranger.