GPU: reject non-power-of-two alignments in allocate_upload #2106

Open
github-bot wants to merge 1 commit from github-bot/gh-2106 into main AGit
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 05:05 UTC · original
fuzeofficlal:fix/gpu-allocate-upload-validation-837 → main · +80 −4 · 1 files · 1 commits · open

Closes #837.

Summary

  • Check alignment != 0 && !alignment.is_power_of_two() in list::allocate_upload (crates/victory-gpu/src/list.rs) before clamping .max(16), so sub-16 non-power-of-two alignments (3, 5..=7, 9..=15, etc.) are rejected instead of being silently rounded up to 16 while 0 and powers of two continue to allocate memory aligned to max(alignment, 16).

Verification

  • list::tests::allocate_upload_validates_alignment_and_size_overflow: verifies non-zero non-power-of-two alignments and overflowing sizes return null without recording an upload block, while 0 and valid power-of-two alignments return zeroed memory aligned to max(alignment, 16).
  • cargo clippy -p victory-gpu --tests --locked -- -D warnings and cargo xtask policy: passed.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 05:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/2106) `fuzeofficlal:fix/gpu-allocate-upload-validation-837` → `main` · +80 −4 · 1 files · 1 commits · open Closes #837. ### Summary - Check `alignment != 0 && !alignment.is_power_of_two()` in `list::allocate_upload` (`crates/victory-gpu/src/list.rs`) before clamping `.max(16)`, so sub-16 non-power-of-two alignments (`3`, `5..=7`, `9..=15`, etc.) are rejected instead of being silently rounded up to 16 while `0` and powers of two continue to allocate memory aligned to `max(alignment, 16)`. ### Verification - `list::tests::allocate_upload_validates_alignment_and_size_overflow`: verifies non-zero non-power-of-two alignments and overflowing sizes return null without recording an upload block, while `0` and valid power-of-two alignments return zeroed memory aligned to `max(alignment, 16)`. - `cargo clippy -p victory-gpu --tests --locked -- -D warnings` and `cargo xtask policy`: passed.
Validate `alignment` (allowing zero for the default 16-byte alignment and rejecting non-powers-of-two before clamping up to 16) so `allocate_upload` returns null on invalid alignment or overflowing `size + align` requests.

Closes #837.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:55:00 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 10:40 UTC · original · edited 2026-11-25 11:23 UTC

Automated triage for the maintainers.

Merge candidate.

list::allocate_upload in crates/victory-gpu/src/list.rs now rejects a non-zero, non-power-of-two alignment before clamping it to 16, so values like 3 or 12 no longer get silently rounded up. 0 and powers of two still allocate at max(alignment, 16). The new test allocate_upload_validates_alignment_and_size_overflow checks bad alignments and overflowing sizes return null with no upload block recorded, and valid alignments return zeroed, correctly aligned memory. It uses the existing helpers (create_allocator, create_list, close, reset, uploads) the same way the other tests in that module do. CI is passing.

On your reply: thanks, the head changed to 1be45cbf and it does what you said. The unreachable offset >= align check and the non-Windows Upload::new changes are gone, and the test no longer has the info-queue and shadow setup.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 10:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/2106#issuecomment-7160023440) · edited 2026-11-25 11:23 UTC <!-- victory-triage v1 head=1be45cbff86ce3644bc2b1e3ff7f0dcad4d737b1 verdict=merge-candidate at=2026-11-25T11:23:47Z --> Automated triage for the maintainers. **Merge candidate.** `list::allocate_upload` in `crates/victory-gpu/src/list.rs` now rejects a non-zero, non-power-of-two `alignment` before clamping it to 16, so values like `3` or `12` no longer get silently rounded up. `0` and powers of two still allocate at `max(alignment, 16)`. The new test `allocate_upload_validates_alignment_and_size_overflow` checks bad alignments and overflowing sizes return null with no upload block recorded, and valid alignments return zeroed, correctly aligned memory. It uses the existing helpers (`create_allocator`, `create_list`, `close`, `reset`, `uploads`) the same way the other tests in that module do. CI is passing. On your reply: thanks, the head changed to `1be45cbf` and it does what you said. The unreachable `offset >= align` check and the non-Windows `Upload::new` changes are gone, and the test no longer has the info-queue and `shadow` setup. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 10:49 UTC · original

Updated in 1be45cbf per triage feedback:

  • Removed the unreachable offset >= align check and reverted the non-Windows Upload::new (isize::MAX / try_reserve_exact) changes back to main.
  • Trimmed the test down to the CPU-side allocate_upload alignment and overflow cases (allocate_upload_validates_alignment_and_size_overflow), removing the info-queue and shadow GPU readback setup.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 10:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2106#issuecomment-7160226332) Updated in `1be45cbf` per triage feedback: - Removed the unreachable `offset >= align` check and reverted the non-Windows `Upload::new` (`isize::MAX` / `try_reserve_exact`) changes back to `main`. - Trimmed the test down to the CPU-side `allocate_upload` alignment and overflow cases (`allocate_upload_validates_alignment_and_size_overflow`), removing the info-queue and `shadow` GPU readback setup.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2106/head:github-bot/gh-2106'
git switch 'github-bot/gh-2106'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2106'
git switch 'github-bot/gh-2106'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2106'
git switch 'github-bot/gh-2106'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2106'
git switch 'main'
git merge --squash 'github-bot/gh-2106'
git switch 'main'
git merge --ff-only 'github-bot/gh-2106'
git switch 'main'
git merge 'github-bot/gh-2106'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2106
No description provided.