GPU: allocate_upload accepts invalid sub-16 alignments and aborts on oversized/OOM requests (fix on a fork) #837
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#837
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:56 UTC · original
Pull requests are currently restricted to collaborators (#717), so I am sharing this bug report and verified fix from a fork branch off
main(ffe310e).github.com/AndyLatimer/VIctory@57c61f2d82Bug
In
crates/victory-gpu/src/list.rs(extern "system" fn allocate_upload):Two bugs violate the "null on failure" contract across this FFI entry point:
.max(16)runs before!align.is_power_of_two(), so non-power-of-two alignments3, 5, 6, 7, 9..15(and values failingusize::try_from) are silently rounded up to16and succeed instead of returning null.extern "system"on oversized or unallocatable requests:size + align > isize::MAX(e.g.,alignment = 1 << 63withsize = 16, orsize = isize::MAXwithalignment = 16) passeschecked_addandis_power_of_two, then panics withcapacity overflowinsidevec. Similarly, unallocatable sizes belowisize::MAX(OOM) triggerhandle_alloc_errorand abort instead of returning null.Fix
this.is_null()and validatealignment(allowing0as default 16-byte alignment and rejecting non-powers-of-two before.max(16)).Vec::try_reserve_exact(len)+block.resize(len, 0), returningnull_mut()cleanly on bothCapacityOverflow(len > isize::MAX) andAllocError(OOM).offset >= alignbeforestart.add(offset).list::tests::allocate_upload_rejects_bad_alignments_and_oversized_requestscovering null list, sub-16 non-power-of-two alignments (3..15), oversized/wrapping/unallocatable sizes and alignments (1 << 63,isize::MAX,u64::MAX,1 << 50), and valid alignments (0, 1, 2, 4, 8, 16, 64) +resetcleanup.Verification
allocate_upload_rejects_bad_alignments_and_oversized_requestsfailed immediately on alignment3(non-power-of-two alignment 3 must fail), and oversized power-of-two alignments/sizes aborted across FFI.cargo test -p victory-gpu: 51 passed, 0 failed, 1 ignored.cargo test -p victory-gpu --features diagnostics: 54 passed, 0 failed, 1 ignored.cargo clippy -p victory-gpu --all-targets -- -D warnings(default and--features diagnostics): clean.cargo check -p victory --features diagnostics: clean.rustfmt --edition 2024 --checkon all modified lines oflist.rs: clean.cargo xtask policy: 154 files ok.Disclosure
Synthetic tests only; no game data or console SDK assets were used. Assisted by Google Antigravity.
@nopsled0x on GitHub · 2026-11-24 12:27 UTC · original
Independently verified
57c61f2(fix/gpu-allocate-upload-validation) on native Windows, cargo 1.98.1. It fast-forwarded frommainwhen I checked.cargo test -p victory-gpu: 51 passed, 0 failed, 1 ignored, includinglist::tests::allocate_upload_rejects_bad_alignments_and_oversized_requests.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.I read the diff and the logic matches the description: the power-of-two check runs before
.max(16),try_reserve_exactreplacesvec!, and the newoffset < alignguard precedesstart.add.Possible concern, not observed: the
1 << 50case relies on the allocator refusing 1 PiB, which might succeed under overcommit (e.g. Linux) and make that assertion flaky.Not tested: the new test failing on
mainwithout the fix,--features diagnostics,cargo xtask policy,rustfmt, or any title run. Synthetic tests only.(AI-assisted: the checks were run by me; the diff review and this comment were prepared with Claude's help.)
@Louisreed on GitHub · 2026-11-24 13:25 UTC · original
This fills the gaps in the earlier verification of
57c61f2(Windows 10 22H2 19045, Rust 1.98.1 MSVC; baseffe310eis stillmain):main's code,allocate_upload_rejects_bad_alignments_and_oversized_requestsfails, panicking inside the new test (list.rs:1466in the combined file).cargo test -p victory-gpu --locked: 51 passed, 0 failed, 1 ignored. Clippy-D warningsis clean.cargo xtask policy: 154 files ok.rustfmt --edition 2024 --check list.rsreports hunks (e.g.ClearDepthStencilViewnear line 754), but none fall inside this diff, andmain'slist.rshas the same 6 hunks.On the
1 << 50overcommit concern: Windows can't commit 1 PiB (x64 user address space is 128 TiB), so that assertion is deterministic here. It could still matter for a non-Windows host build.AI-assisted (Claude). I ran the checks locally. Synthetic inputs only.
@wanchudao on GitHub · 2026-11-24 15:47 UTC · original
Tested AndyLatimer/VIctory's fix/gpu-allocate-upload-validation branch at 57c61f2 on
Windows 11 Pro build 26300, Ryzen 5 5500, rustc 1.98.1, MSVC 14.44.35207,
and Windows SDK 10.0.26100.0.
cargo test -p victory-gpu --lib allocate_upload -- --nocaptureResult: 1 passed, 0 failed, 0 ignored, 51 filtered out. This is an additional
Windows result for the CPU-side alignment and allocation-size assertions. The test
setup can create a D3D12 command list, and the log does not identify the adapter.
AI use — DeepSeek Harness (DeepSeek V4.1 Flash) ran the test and drafted this report.
OpenAI Codex (GPT-6.2 Sol) checked the archived result and revised it.
@Marvisak on GitHub · 2026-11-25 03:54 UTC · original
Automated triage for the maintainers.
Partly confirmed on current
main,crates/victory-gpu/src/list.rs,allocate_upload:.max(16)runs before theis_power_of_two()check, so a non-power-of-two alignment below 16 (3, 5, 6, 7, 9 to 15) is rounded up to 16 and succeeds instead of returning null.0f63757the block comes fromUpload::new, which usesVirtualAlloc2on Windows and returnsNone, and therefore null, when the allocation fails. There is novec!on that path any more.Your branch is based on
ffe310eand no longer applies to this code. Pull requests are open to everyone again (see #717), so please open a PR against currentmainwith the alignment check and the test cases that still apply.Generated by Claude Code