GPU: saturate COM AddRef at u32::MAX instead of wrapping #2059
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2059
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2059/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@fuzeofficlal on GitHub · 2026-11-25 04:17 UTC · original
fuzeofficlal:fix/gpu-addref-saturate-931→main· +113 −5 · 1 files · 1 commits · closed without mergingCloses #931.
Summary
object::add_refto incrementrefsviafetch_update+checked_add(1)so COM reference counts saturate atu32::MAXinstead of wrapping to0in release builds (which could allow a subsequentReleaseto drop a still-referenced object), matching the existing CAS floor inobject::releaseandobject::release_boxed.Testing
object::tests::add_ref_saturates_at_u32_max_without_wrappingcovering both heap-allocated (hand_out+release_boxed) and static (Object+release) COM objects acrossu32::MAX - 1 -> u32::MAXsaturation, decrement without premature drop, and final1 -> 0destruction.cargo test -p victory-gpu(debug & release),cargo clippy --workspace --all-targets --all-features -- -D warnings, andcargo xtask policy.@jeremygold02 on GitHub · 2026-11-25 04:21 UTC · original
Triage verdict — Keep the overflow fix, define ownership at saturation (
37e69e7)Evidence
Checks and limits
Next step
This verification was AI-assisted.
@upipibi on GitHub · 2026-11-25 04:41 UTC · original
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
37e69e7.victory-gpu: 142 passed, 2 failed, 2 ignored; the newadd_ref_saturates_at_u32_max_without_wrappingpasses. The 2 failures are #1744's heap-cap failures onmain. Same asmainon this hardware. Not run: a title.AI-assisted (Claude Code).
@fuzeofficlal on GitHub · 2026-11-25 05:00 UTC · original
Updated in
57535164— thanks @jeremygold02. Saturation atu32::MAXis now sticky across bothobject::releaseandobject::release_boxed((n != u32::MAX).then(|| n.checked_sub(1)).flatten()), so interface queries orAddRefcalls atu32::MAXcannot be balanced down by laterReleasecalls to drop a still-referenced object. Expanded the unit test to verify normal decrement atu32::MAX - 1, sticky saturation acrossanswer+Releaseatu32::MAX, and ordinary1 -> 0destruction.@Marvisak on GitHub · 2026-11-25 09:24 UTC · original
Automated triage for the maintainers.
Proposed close.
object::add_ref,object::releaseandobject::release_boxed(crates/victory-gpu/src/object.rs) now stop the reference count atu32::MAXand then never drop the object. The count can only get there if a title holds about 4.29 billion references to one object at the same time. A title does not do that, so this is a guard for a case that cannot occur.The guard also has a cost. Real COM lets the count wrap, so this differs from it. An object that did reach the limit would leak for good. The new test must free the saturated box by hand, which also skips the cleanup of the interface map in
release_boxed. The same idea is already open in #1100 and #1105.This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label. A reproduction showing a title, or a VIctory code path, that actually reaches this count would change the verdict.
CI: passing (
check).Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-25 10:17 UTC · original
Agreed with the triage analysis —
u32::MAXsimultaneous live references cannot occur in practice and pinning the count diverges from COM cleanup. Closing.Pull request closed