GPU: saturate COM AddRef instead of wrapping its reference count #1105
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1105"
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 NethminaYasas on 2026-11-24T15:47:34Z.
Problem
add_refusedfetch_add(1) + 1, so a reference count atu32::MAXpanicked in debug builds and wrapped to zero in release builds. An object with outstanding references could then look dead and be released early. Refs #931.Change
add_refnow mirrorsrelease:fetch_updatewithchecked_add(1), returning the saturated count when the increment overflows. It never wraps to zero and never panics.releaseandrelease_boxed). Otherwise a reference handed out at the limit is not counted, and later releases could still drop the object while that reference is live (CodeRabbit finding, fixed in review). Normal increments and releases below saturation are unchanged.add_ref_saturates_at_u32_maxandrelease_boxed_keeps_a_saturated_object_alive.Verification
cargo test --workspaceon Windows with Rust 1.98.1: all crates pass;victory-gpuhas 45 passed, 1 ignored (benchmark), including both new tests.rustfmt --edition 2024 --check crates/victory-gpu/src/object.rs: clean. A workspace-widecargo fmtis not clean onmainwith this rustfmt version (it reformats 31 unrelated files), so those unrelated changes were deliberately left out.cargo clippy --workspace: no findings in this change. There is one pre-existing, unrelated warning invictory-hle/src/modules/xmem.rs:747(field_reassign_with_default), left untouched.This verifies reference-count behaviour only. I did not run the title. AI-assisted (OpenCode). No game data, game assets, or files from a game dump were used or committed; both tests use synthetic in-memory objects.
Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T18:01:53Z.
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
6273f06:cargo test -p victory-gpupasses, 45 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 Marvisak on 2026-11-25T00:32:20Z.
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).
Saturates AddRef at u32::MAX and makes a saturated object immortal. Hardening against 4 billion unreleased references to one object, which no title reaches; it replaces a single atomic add on a hot path with compare-exchange loops in AddRef and Release.
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