bugfix(contain): Ensure container exists when checking if a specific rider is free to exit#2513
bugfix(contain): Ensure container exists when checking if a specific rider is free to exit#2513Stubbjax wants to merge 1 commit intoTheSuperHackers:mainfrom
Conversation
|
| Filename | Overview |
|---|---|
| Generals/Code/GameEngine/Source/GameLogic/Object/Contain/TransportContain.cpp | Adds null-check guard for getContainedBy() before the DISABLED_HELD query in isSpecificRiderFreeToExit; change is correct, minimal, and consistent with existing style |
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/TransportContain.cpp | Mirrors the identical null-check fix from the Generals/ variant for the Zero Hour expansion; correct and consistent |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A([isSpecificRiderFreeToExit]) --> B{specificObject == nullptr?}
B -- Yes --> C([return TRUE])
B -- No --> D{AI says not free to exit?}
D -- Yes --> E([return FALSE])
D -- No --> F{RETAIL_COMPATIBLE_CRC?}
F -- No check --> G([skip held check])
F -- Not retail --> H{getContainedBy != null\nAND container is DISABLED_HELD?}
H -- Yes --> I([return FALSE])
H -- No --> J{Using airborne locomotor?}
G --> J
J -- Yes --> K([return TRUE])
J -- No --> L{No AI update interface?}
L -- Yes --> M([return FALSE])
L -- No --> N{No locomotor?}
N -- Yes --> O([return FALSE])
N -- No --> P{Invalid movement terrain?}
P -- Yes --> Q([return FALSE])
P -- No --> R([return TRUE])
style H fill:#90EE90,stroke:#006400
style I fill:#FFB6C1,stroke:#8B0000
Reviews (1): Last reviewed commit: "fix: Ensure container exists when checki..." | Re-trigger Greptile
Caball009
left a comment
There was a problem hiding this comment.
If this can lead to a crash, the PR should include a crash reproduction.
Why? |
That strikes me as an odd question. The PR is labeled as a crash fix. The PR description and the surrounding code suggest that this shouldn't be a |
|
Yes it is concerning that this function is called on an object that is not a rider. The assert in this function makes clear that this should not happen. Can you check why it happens and if it can be fixed higher up? Even after this fix it would still be a bug, because the assert can be hit. |
I ask because I've only ever seen this to be a suggestion rather than a requirement. A developer might not be in a position to spend hours replicating whatever potentially obscure or convoluted scenario leads to a crash. It could take days or even weeks to figure out. Do we let users keep crashing until that happens? When it comes to live software, plugging the hole is typically the priority; understanding how and why can come later. |
Thankfully it was an easy 3-minute reproduction in this case: Just have a vehicle in the middle of evacuation when it dies. A full Assault Outpost is the best unit for the job. Simply evacuate it and then have it die before all troops have exited. |
The PR description didn't say that this was a crash hotfix, and even if it did, TSH typically doesn't move so quickly that those sort of PRs are merged fast enough. The GeneralsOnline devs put out their own hotfix an hour after the creation of this PR, so there's no longer a sense of urgency:
Thank you, that was helpful. I have dismissed my review, but I do think we should check why this happens at all. FWIW I was able to reproduce this issue with an Attack Outpost but not a Troop Crawler. I created a replay for VC6, but it also works with VS22: crash_containedby.zip Probably not surprising, if Here's the callstack if needed. |
|
Can we stop the evacuation sequence when the container dies? |
This change adds extra safety by null-checking the container before accessing it in
TransportContain::isSpecificRiderFreeToExit. It is unexpected that aTransportContaincan query the free-to-exit status of a non-rider, which may be indicative of a deeper issue elsewhere.