GPU: validate allocate_upload alignments and handle oversized requests #1346
No reviewers
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!1346
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1346/head"
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?
@fuzeofficlal on GitHub · 2026-11-24 17:34 UTC · original
fuzeofficlal:fix/allocate-upload-alignment-oom-837→main· +85 −7 · 1 files · 1 commits · closed without mergingFixes #837.
Summary
raw_align != 0 && !raw_align.is_power_of_two()before clampingraw_align.max(16)inallocate_upload, rejecting invalid sub-16 non-power-of-two alignments (3, 5..15, etc.) while keeping0and1, 2, 4, 8promoted to 16-byte alignment.Vec::try_reserve_exact(len)beforeresize(len, 0)and guardoffset >= alignso oversized (> isize::MAX,u64::MAX) or OOM requests returnnull_mut()cleanly instead of panicking or aborting across theextern "system"FFI boundary.Verification
list::tests::allocate_upload_validates_alignments_and_handles_oversized_requestscovering nullthis, invalid alignments, oversized/OOM requests, valid power-of-two alignments (0, 1..4096), zero-sized allocations, andresetcleanup:VICTORY_D3D12_DEBUG=1): passedVICTORY_D3D12_DEBUG=1): passedcargo clippy --workspace --all-targets --all-featuresandcargo xtask policy: passed.@acetonahard-code on GitHub · 2026-11-24 19:20 UTC · original
Tested this on a GPU with SM 6.6 support (RTX 4070 SUPER, driver 621.14, Windows 11, repo toolchain), merged into current
main(ffe310e).cargo test -p victory-gpumainmain+ this PRmain,--all-featuresmain+ this PR,--all-features--nocapture, and no "no SM 6.6 ... device; skipped" lines were printed, so no GPU test skipped for lack of a device.cargo clippy --all-targets -- -D warnings, with and without--all-features: clean.I didn't test with game data.
Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.
@Marvisak on GitHub · 2026-11-25 00:37 UTC · original
Automated triage for the maintainers. Closing because this change is already in
main, ormainhas since replaced the code it patches.Hardens the old Vec-based body of allocate_upload (try_reserve, alignment order); main rewrote it on VirtualAlloc2 in [4 GiB, 2^40), which already returns null on failure. What is left (alignment 3 taken as 16) cannot matter.
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