Skip to content

fix(contain): remove destroyed detached occupants#236

Open
mreza0100 wants to merge 1 commit into
fbraz3:mainfrom
mreza0100:fix/contain-dead-rider
Open

fix(contain): remove destroyed detached occupants#236
mreza0100 wants to merge 1 commit 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.

object->kill(); // in case we are carrying flame proof troops we have been asked to kill

if ( object->isEffectivelyDead() )
// TheSuperHackers @bugfix mreza0100 23/07/2026 A destroyed occupant cannot remove itself

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Could you please change the comment for the GeneralsX pattern? thanks!
// GeneralsX @keyword author DD/MM/YYYY A meaningful description for this change.

Details: https://github.com/fbraz3/GeneralsX/blob/main/CONTRIBUTING.md

object->kill(); // in case we are carrying flame proof troops we have been asked to kill

if ( object->isEffectivelyDead() )
// TheSuperHackers @bugfix mreza0100 23/07/2026 A destroyed occupant cannot remove itself

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Same here

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