GPU: saturate COM AddRef against a u32 wrap, with tests for object.rs #1100
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1100"
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?
Imported from Marvisak/VIctory. Originally posted by adamdotpy on 2026-11-24T15:44:09Z.
Carries @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.
Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T16:29:31Z.
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).
Imported from Marvisak/VIctory. Originally posted by adamdotpy on 2026-11-24T17:10:19Z.
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.Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T19:58:53Z.
Review: APPROVED
Tested
b82fb125on Windows 11, RTX 5070, MSVC:cargo test -p victory-gpupasses on the head (67 passed, 1 ignored), including the new object tests.clippy -D warnings(default and all features) are all clean.The fix is right.
fetch_update(checked_add)stops atu32::MAX, so a saturated object is never freed by a laterRelease. Leaking it is the safe outcome, and the use-after-free is gone. The returned count stays monotonic withsaturating_add.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:32:15Z.
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