GPU: guard OMSetRenderTargets handle expansion on empty, null, or oversized calls #1427
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1428"
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 fuzeofficlal on 2026-11-24T17:57:56Z.
Fixes #796.
Summary
state::target_handlesincrates/victory-gpu/src/list.rssoOMSetRenderTargets(state::targets) expands handles into a stack-allocated[u64; D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT]array:count == 0orhandlesis null soOMSetRenderTargets(0, p, TRUE, &dsv)never dereferences a stale or uninitializedpRenderTargetDescriptorspointer.counttoD3D12_SIMULTANEOUS_RENDER_TARGET_COUNT(8).Verification
list::tests::target_handles_guards_empty_null_and_clamps_to_eight: coverscount == 0with a dangling pointer, null pointer, single-range expansion, array expansion, and clamping to 8.list::tests::om_set_render_targets_zero_count_does_not_read_handles: calls vtable slot0x190(OMSetRenderTargets) withcount == 0and aPAGE_NOACCESSpointer (one_range = 1with&dsvandone_range = 0with null DSV).cargo clippy -p victory-gpu --tests --locked -- -D warningsandcargo xtask policy: passed.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:27:28Z.
Automated triage for the maintainers.
Merge candidate.
state::targetsincrates/victory-gpu/src/list.rsnow goes throughstate::target_handles. It returns no handles whencount == 0orhandlesis null, soOMSetRenderTargets(0, p, TRUE, &dsv)no longer reads*p, which is the bug in #796. It also capscountatD3D12_SIMULTANEOUS_RENDER_TARGET_COUNTand uses a stack array in place of aVec. The array path still goes throughitems, as before. The tests are short:target_handlesassertions for the empty, null, single-range, array and clamp cases.om_set_render_targets_zero_count_does_not_read_handles, which calls vtable slot0x190(state::targets, entry 50 of the list vtable) withcount == 0and aPAGE_NOACCESSpointer. That test would fault onmain.CI is passing (
check), and the PR merges cleanly.On your reply: thanks, the head changed to
ec57a6eand it does what the last triage asked. The rendering test is gone, the overflow and zero-base guards are dropped, and the crash is covered directly.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T09:44:29Z.
Updated in
ec57a6e4per triage feedback:D3DCompile/MRT rendering test and replaced the vtable coverage withom_set_render_targets_zero_count_does_not_read_handles, which callsOMSetRenderTargets(0x190) withcount == 0against aPAGE_NOACCESSpage (one_range = 1with&dsvandone_range = 0with null DSV), alongside the puretarget_handlesunit checks.u64::MAXoverflow and zero-base checks, keeping only thecount == 0/ null early return and theD3D12_SIMULTANEOUS_RENDER_TARGET_COUNT(8) clamp.Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-27T02:05:04Z.
Independent CPU-only verification on Windows (Rust 1.100.0/MSVC, worktree-local
CARGO_TARGET_DIR,CARGO_BUILD_JOBS=2, no game data).ec57a6e, merge base940d32f.cargo test --locked -p victory-gpu --lib -- list::tests::target_handles_guards_empty_null_and_clamps_to_eight --exact --test-threads=1 --quiet->test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 146 filtered out.git diff --check 940d32f HEAD-> exit 0.940d32f(git grep -c ... crates/victory-gpu/src/list.rs-> exit 1).Note: only the named synthetic test was replayed; the full crate suite was not run. GPU/driver: N/A (CPU-only list test). AI-assisted (Hy4 flash). No game data, assets, extracted shaders or DRM involved.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.