Skip to content

fix(contain): remove destroyed detached occupants - #236

Merged
fbraz3 merged 2 commits into
fbraz3:mainfrom
mreza0100:fix/contain-dead-rider
Jul 26, 2026
Merged

fix(contain): remove destroyed detached occupants#236
fbraz3 merged 2 commits into
fbraz3:mainfrom
mreza0100:fix/contain-dead-rider

Conversation

@mreza0100

Copy link
Copy Markdown

Summary

  • remove destroyed occupants before restoring a temporarily detached containment list
  • mirror the fix in Generals and Zero Hour
  • keep RETAIL_COMPATIBLE_CRC behavior unchanged

Root cause

OpenContain::processDamageToContained temporarily swaps m_containList out to avoid iterator invalidation. A nested destroyObject call cannot deregister a rider while that list is detached. If the rider is marked destroyed without becoming effectively dead, the old code restores it; deferred deletion then leaves a dangling pointer. A later container eviction can call TransportContain::onRemoving on the destructed object and crash in Object::onDisabledEdge because m_behaviors is null.

The fix excludes both effectively-dead and explicitly destroyed occupants before restoring the detached list. The normal live-occupant path is unchanged.

Validation

  • macOS ARM64 Zero Hour target z_generals builds successfully
  • macOS ARM64 Generals target g_generals builds successfully
  • git diff --check passes
  • retail-compatible CRC branch is unchanged

AI assistance

The crash report and engine lifecycle were analyzed with AI assistance. The final logic change was manually scoped to the identified list-detachment invariant and verified against both game variants and full native builds.

Comment thread Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp Outdated
Comment thread GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp Outdated
Address review: switch the @BugFix comment prefix from TheSuperHackers to
GeneralsX, per CONTRIBUTING.md.
@mreza0100

Copy link
Copy Markdown
Author

Thanks for the review! Updated both comment blocks (Generals/ and GeneralsMD/ OpenContain.cpp) to the GeneralsX @bugfix convention per CONTRIBUTING.md. Pushed in dba6867 — done.

@fbraz3
fbraz3 merged commit 69746c2 into fbraz3:main Jul 26, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants