GPU: read small buffer diagnostics via read_into instead of VirtualQuery #2142

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

@⁠fuzeofficlal on GitHub · 2026-11-25 05:55 UTC · original
fuzeofficlal:fix/gpu-describe-small-read-into-913 → main · +219 −6 · 1 files · 1 commits · open

Problem

While 6d021fe switched describe()'s View::Constant path to host::read_into, the small closure added right above it in 7000573 (crates/victory-gpu/src/draw.rs) still queries texture::committed (VirtualQuery) and constructs std::slice::from_raw_parts over live title memory for <= 64-byte buffer SRV and UAV views. That walks pool regions on every noted draw/dispatch, leaves a TOCTOU window against concurrent unmapping or page-guard changes, and passes (null, 0) to from_raw_parts when at == 0 && len == 0.

Changes

  • Read 4..=64-byte buffer SRV/UAV spans into a 64-byte stack buffer via crate::host::read_into (omitting empty and sub-dword < 4-byte spans), eliminating VirtualQuery and unsafe slice construction.
  • Add draw::tests::describe_reads_small_buffers_without_faulting_on_unmapped_memory under diagnostics covering unaligned SRV/UAV float formatting, boundary lengths (0, 2, 6, 64, 68), and reserved/unmapped page boundaries.

Closes #913.

**@⁠fuzeofficlal** on GitHub · 2026-11-25 05:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/2142) `fuzeofficlal:fix/gpu-describe-small-read-into-913` → `main` · +219 −6 · 1 files · 1 commits · open ### Problem While `6d021fe` switched `describe()`'s `View::Constant` path to `host::read_into`, the `small` closure added right above it in `7000573` (`crates/victory-gpu/src/draw.rs`) still queries `texture::committed` (`VirtualQuery`) and constructs `std::slice::from_raw_parts` over live title memory for `<= 64`-byte buffer SRV and UAV views. That walks pool regions on every noted draw/dispatch, leaves a TOCTOU window against concurrent unmapping or page-guard changes, and passes `(null, 0)` to `from_raw_parts` when `at == 0 && len == 0`. ### Changes - Read `4..=64`-byte buffer SRV/UAV spans into a 64-byte stack buffer via `crate::host::read_into` (omitting empty and sub-dword `< 4`-byte spans), eliminating `VirtualQuery` and `unsafe` slice construction. - Add `draw::tests::describe_reads_small_buffers_without_faulting_on_unmapped_memory` under `diagnostics` covering unaligned SRV/UAV float formatting, boundary lengths (`0`, `2`, `6`, `64`, `68`), and reserved/unmapped page boundaries. Closes #913.
`describe` still queried `texture::committed` (`VirtualQuery`) and formed a
raw slice over live title memory for `<= 64`-byte buffer SRV and UAV ranges,
walking pool regions on every noted draw and dispatch while exposing a TOCTOU
window against concurrent unmapping or page protection changes. Read `4..=64`
byte spans into a 64-byte stack buffer with `host::read_into`, matching the
constant-view path.

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

@⁠Marvisak on GitHub · 2026-11-25 11:23 UTC · original · edited 2026-11-26 01:21 UTC

Automated triage for the maintainers.

Merge candidate. It is rebased onto current main (one commit, c994126) and merges cleanly. It fixes #913, a diagnostics-only path. In describe in crates/victory-gpu/src/draw.rs, the small closure no longer checks texture::committed and then builds a slice over live title memory. Instead, it copies 4 to 64 bytes into a stack buffer through host::read_into, the same way main already reads the View::Constant path just below. That closes the window between the check and the read, and it drops the (null, 0) slice case. The only visible change: spans under 4 bytes now print nothing instead of = []. The new test (diagnostics, Windows) covers unaligned SRV/UAV reads, the 0/2/6/64/68-byte limits, and a view that crosses into a reserved but uncommitted page.

CI: passing (check). Recommending a look, not approving.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 11:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/2142#issuecomment-7160993908) · edited 2026-11-26 01:21 UTC <!-- victory-triage v1 head=c994126800e14e5aba1679c6d62b6ce84c6c108e verdict=merge-candidate at=2026-11-26T01:21:24Z --> Automated triage for the maintainers. **Merge candidate.** It is rebased onto current `main` (one commit, `c994126`) and merges cleanly. It fixes #913, a diagnostics-only path. In `describe` in `crates/victory-gpu/src/draw.rs`, the `small` closure no longer checks `texture::committed` and then builds a slice over live title memory. Instead, it copies 4 to 64 bytes into a stack buffer through `host::read_into`, the same way `main` already reads the `View::Constant` path just below. That closes the window between the check and the read, and it drops the `(null, 0)` slice case. The only visible change: spans under 4 bytes now print nothing instead of `= []`. The new test (diagnostics, Windows) covers unaligned SRV/UAV reads, the 0/2/6/64/68-byte limits, and a view that crosses into a reserved but uncommitted page. CI: passing (`check`). Recommending a look, not approving. --- _Generated by [Claude Code](https://claude.ai/code)_
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/2142/head:github-bot/gh-2142'
git switch 'github-bot/gh-2142'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2142'
git switch 'github-bot/gh-2142'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2142'
git switch 'github-bot/gh-2142'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2142'
git switch 'main'
git merge --squash 'github-bot/gh-2142'
git switch 'main'
git merge --ff-only 'github-bot/gh-2142'
git switch 'main'
git merge 'github-bot/gh-2142'
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!2142
No description provided.