Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe change updates stale containment cleanup and reports removal success from tunnel trackers. ChangesStale containment cleanup
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Sequence Diagram(s)sequenceDiagram
participant GameLogicReset
participant ObjectDestructor
participant GameLogic
participant TunnelTracker
GameLogicReset->>ObjectDestructor: destroy all objects
ObjectDestructor->>GameLogic: find containing object by ID
ObjectDestructor->>TunnelTracker: remove stale object from containment
TunnelTracker-->>ObjectDestructor: report removal success
GameLogicReset->>GameLogicReset: rebuild m_objHash
Merge Risk: 🟠 High · up to Destroying or resetting occupants after a transferred tunnel is removed can still crash the game, so the liveness check must be made safe before merge. 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation The changes target Resolution Guard every access to Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 05462f18-5541-4952-bf16-ef691cac9291
📒 Files selected for processing (1)
Generals/Code/GameEngine/Source/GameLogic/Object/Contain/TunnelContain.cpp
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
e013859 to
79cd96b
Compare
…estroyed container
79cd96b to
a4f6a80
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 1cb11c8f-3dfa-44f4-a2f0-6908eeb4faff
📒 Files selected for processing (4)
Generals/Code/GameEngine/Include/Common/TunnelTracker.hGenerals/Code/GameEngine/Source/Common/RTS/TunnelTracker.cppGenerals/Code/GameEngine/Source/GameLogic/Object/Object.cppGenerals/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
The use of GameLogic::findObjectByID relies on this.
09e91b4 to
a25c611
Compare
|
Please clean up the PR description. The issue reproduction steps are inaccurate, because the crash is much rarer than this. It's currently a wall of text that I think can be reduced by at least half without losing important information; it also references things like the VC6 replay that's not included anywhere. Edit: Feel free to reorganize the commits if that helps for clean diffs. |
|
| #if RTS_GENERALS && RETAIL_COMPATIBLE_CRC | ||
| // TheSuperHackers @bugfix bobtista / Caball009 17/09/2026 Remove stranded tunnel occupants during destruction. | ||
| // The lookup detects unregistered IDs, but cannot detect reuse of the freed container memory. | ||
| if (!TheGameLogic->findObjectByID(m_containedBy->getID())) |
There was a problem hiding this comment.
Stale container still dereferenced When a transferred tunnel has been freed but an occupant still points to it, this check reads the freed tunnel to get its ID. The condition above also reads it to get its contain module. If that memory is inaccessible, destruction can crash before the new cleanup runs. If the memory has been reused by a registered object with a contain module, the lookup can instead take the normal removal path and leave the occupant in its tunnel tracker.
There was a problem hiding this comment.
Yes, it still reads through the stale pointer and cannot detect memory reused by another live object. Those limitations are in the description. The underlying dangling-pointer issue remains in #3316.
There was a problem hiding this comment.
Agreed. The PR description explicitly documents both limitations, and #3316 tracks the broader dangling-m_containedBy issue during gameplay. This change is intentionally a teardown-only safeguard, so I don’t have an additional actionable concern on this line.
| if( m_containedBy && m_containedBy->getContain() ) | ||
| { | ||
| m_containedBy->getContain()->removeFromContain( this ); | ||
| #if RTS_GENERALS && RETAIL_COMPATIBLE_CRC |
There was a problem hiding this comment.
I am skeptical about this change because it explicitly addresses Generals, indicating that this is no issue in Zero Hour, which then begs the question why and can we merge the Zero Hour code responsible for fixing this instead of having a separate fix for Generals that eventually will conflict with Zero Hour when merging?
There was a problem hiding this comment.
TunnelContain::onCapture is not retail compatible in Generals, hence Generals specific issues.
There was a problem hiding this comment.
Will all the code of this change disappear on merge?
There was a problem hiding this comment.
Only if the merge coincides with abandoning retail compatibility.
…stroying all objects
In retail-compatible Generals, surrendering can transfer Tunnel Networks without updating their tunnel tracker. If those tunnels are later sold or destroyed, occupants can retain stale container pointers and crash when destroyed, including during match cleanup. These steps do not reliably reproduce the crash; it depends on what happens to the freed memory.
Now
Object::onDestroychecks whether the container ID is still registered. If it is missing, the occupant is removed from its tunnel tracker and its container link is cleared. The object lookup table also stays available until match cleanup finishes deleting objects in both Generals and Zero Hour.Note: It still reads through the stale pointer and cannot detect memory reused by another live object. Cleanup is also skipped if the stale container no longer exposes a contain module. Other uses of the dangling pointer are in #3316. The new destruction check is limited to retail-compatible Generals.
Teardown-order testing found no simulation regression in the tested replays. Propaganda Center ownership restoration was not exercised, and audible teardown effects were not verified.
generals_3315_tunnel_reset_crash.zip
Todo: