GPU: OMSetRenderTargets dereferences invalid handles on empty or null single-range calls (fix on a fork) #796
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#796
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@AndyLatimer on GitHub · 2026-11-24 11:06 UTC · original
Summary
In
crates/victory-gpu/src/list.rs(state::targets, implementingID3D12GraphicsCommandList::OMSetRenderTargets), theRTsSingleHandleToDescriptorRange != 0path has four bugs:count == 0with non-nullhandles:if one_range != 0 && !handles.is_null()dereferencesunsafe { *handles }even whenNumRenderTargetDescriptors == 0(unlikeitems(handles, count)right above it, which guardscount == 0). In D3D12, depth-only passes may callOMSetRenderTargets(0, pRTVs, TRUE, &dsv)with an unread/stale non-null pointer; verified on host Windows 11 D3D12 thatOMSetRenderTargets(0, 0x10, true, None)succeeds without dereferencing the pointer.*handles == 0andcount >= 2: steppingfirst + 128 * ifrom a null handle0produces0x80, 0x100, ..., whichdescriptor::rtv_recordthen treats as non-null pointers and dereferences in the null page (0xC0000005).u64arithmetic:first + 128 * ipanics in debug builds (and wraps to low memory in release) iffirstis nearu64::MAX.count:countwas not capped atD3D12_SIMULTANEOUS_RENDER_TARGET_COUNT(8), allowing excessive allocation or invalid counts to reach the host command list.Fix on fork
AndyLatimer/VIctory@fix/gpu-om-set-render-targets-bounds(based onmainffe310e)github.com/AndyLatimer/VIctory@de663d2Extracted
state::target_handlesincrates/victory-gpu/src/list.rsto ignorehandleswhencount == 0, capcountat8, preserve null slots (vec![0; count]) when a single range starts at0, and checkfirst.checked_add(128 * i)against overflow.Verification
list::tests::om_set_render_targets_guards_empty_and_null_single_ranges(verified onorigin/mainbefore the fix: host Windows 11 D3D12 accepts the empty single-range call whilestate::targetscrashes with0xc0000005STATUS_ACCESS_VIOLATION; passes after the fix).cargo test -p victory-gpu: 51 passed, 0 failed, 1 ignoredcargo test -p victory-gpu --features diagnostics: 54 passed, 0 failed, 1 ignoredcargo clippy -p victory-gpu --all-targets -- -D warnings(default and--features diagnostics): cleancargo check -p victory --features diagnostics: cleancargo xtask policy: 154 files okrustfmt --edition 2024 --check crates/victory-gpu/src/list.rs: 0 diffs on touched lines (pre-existing untouched diffs only)Disclosure
@LAKSHYA-cmd-tech on GitHub · 2026-11-24 11:08 UTC · original
Cherry-picked and merged downstream in https://github.com/LAKSHYA-cmd-tech/VIctory/pull/10.
Verified clean on Windows 11 D3D12 runtime across all 86 \ictory-gpu\ tests including \list::tests::om_set_render_targets_guards_empty_and_null_single_ranges.
@nopsled0x on GitHub · 2026-11-24 12:54 UTC · original
I checked
fix/gpu-om-set-render-targets-bounds(de663d2, on top offfe310e) on Windows 10, debug build:cargo test -p victory-gpu --locked -- om_set_render_targets: 1/1 pass (om_set_render_targets_guards_empty_and_null_single_ranges), on my machine, which has a real GPU. The test does not print whether its host D3D12 section ran, so I cannot say it was exercised.cargo clippy -p victory-gpu --all-targets --locked -- -D warnings: clean.extern "system"function. A zero handle is skipped bytagged_record(descriptor.rs) without reading memory.countabove 8 is truncated silently instead of reaching the host.set_targetsskips that slot and the following render targets shift down one position. Skipping slots without a recorded view (and the resulting shift) already happened before the diff; the change only adds new cases that hit it. The open PR #450 ("preserve typed null render target slots") addresses a related slot shift for typed null RTVs; I have not checked how it interacts with this diff.Not verified:
--features diagnostics,cargo test --workspace,xtask policy, workspace-wide clippy, or in-game behavior.AI-assisted verification (Claude); tests were run locally by me.
@Marvisak on GitHub · 2026-11-25 03:53 UTC · original
Automated triage for the maintainers.
Confirmed on
main: incrates/victory-gpu/src/list.rs,state::targetsreads*handleswheneverone_range != 0and the pointer is non-null, even forcount == 0, and expands the range asfirst + 128 * iwith no check. From a zero first handle that yields 0x80, 0x100, ..., whichrtv_record/tagged_record(descriptor.rs) dereference, since only a handle of exactly 0 is skipped.countis not capped at 8.Open PR #1428 already carries this change (empty, null and oversized calls). Pull requests are open to everyone, so please compare your branch with #1428 and comment there, or open your own PR if yours differs. As noted in the comments, the slot shift for skipped targets overlaps with #450.
Generated by Claude Code