GPU: saturate COM AddRef against a u32 wrap, with tests for object.rs #1100
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!1100
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1100/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?
@adamdotpy on GitHub · 2026-11-24 15:44 UTC · original
adamdotpy:gpu/object-addref-saturates→main· +376 −1 · 1 files · 1 commits · closed without mergingCarries @geiyiliyabumo's commit from #931, verified here; AI-assisted.
The change is
geiyiliyabumo@b82fb12, pushed unchanged with its authorship, because the issue says external PR creation is still restricted and offers the branch for cherry-pick.The fix
object::add_refdidfetch_add(1).wrapping_add(1). Atu32::MAXthat wraps to 0: in a release build the object looks unreferenced, the nextReleasefrees it while COM still holds it, and every later use is a use-after-free. It now saturates:AddRefreturningu32::MAXfor ever is what COM expects of a saturated count, and it never returns 0.The tests
object.rshad none. This adds 17: the reference-count paths (AddRefsaturation,Releasenever below zero, last-ref free and private-data cleanup,hand_outaccept/reject/ask,answer), the ABI the title pins (Object's header bits and count,IUnknownat the head of a table,D3D12Object's methods at the PC offsets),is_matchesover whole ids only, private data round-trip and its ownership,SetName, andparent_deviceanswering only the device ids.Verification here
Windows 11, Rust 1.98.1, on
ffe310ewith this commit applied:cargo test -p victory-gpu: 67 passed, 1 ignored (50 before; 17 new).cargo clippy -p victory-gpu --all-targets --all-features -- -D warnings: clean.cargo build --release -p victory: builds.fetch_addback failsadd_ref_saturates_instead_of_wrapping(in a debug test run it is an overflow panic at the+ 1; in a release build the count wraps to 0, which the count assertion catches). The tests are not passing vacuously.One note for whoever runs the suite: two of the tests lean on
staticobjects (UNREFERENCED,SATURATED), each owned by exactly one test, so they do not race each other under the default threaded runner — but a future test that reuses either static would need to serialise against it.Fixes #931.
@Zipettte on GitHub · 2026-11-24 16:29 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
b82fb12:cargo test -p victory-gpupasses, 67 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@adamdotpy on GitHub · 2026-11-24 17:10 UTC · original
Thanks for the run @Zipettte — 67 passed / 0 failed on
victory-gpuatb82fb12with the main baseline green on the same machine. Noted; nothing actionable in the report.@Marvisak on GitHub · 2026-11-25 00:32 UTC · original
Automated triage for the maintainers. Closing because it does not change behaviour the project needs (formatting, guards for cases that cannot occur, or notes and translations that cannot be kept current).
If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed