GPU: a null SRV has no alias source #2851

Closed
github-bot wants to merge 1 commit from gh-pr/2851/head into gh-pr/2851/base
Owner

@⁠Ingenioeren on GitHub · 2026-11-25 22:20 UTC · original
Ingenioeren:fix/2847-null-srv-alias-source → main · +10 −0 · 1 files · 1 commits · closed without merging

What

Return None from resource::alias_source when the resource pointer is null. Add a Windows regression test that calls alias_source directly with a null pointer.

Why

Since #1273, draw::readable looks for a texture alias for every SRV, including View::Shader(0, _). Passing that zero pointer to resource() causes a null dereference. The guard protects every caller of alias_source.

host_resource already returns None for null, which skips texture::upload and the diagnostics GetDesc call. list::ensure_state exits through HostList::transition when host_copy returns None.

Thanks to frenziedcoder for diagnosing the crash.

How tested

  • cargo test --locked --offline -p victory-gpu resource::tests::a_null_shader_view_has_no_alias_source -- --exact — with the guard stashed and the test staged, the test binary reported a null pointer dereference in resource() and aborted with 0xc0000409 (STATUS_STACK_BUFFER_OVERRUN). With the guard restored, the same command passed (1 passed, 0 failed).
  • cargo test --locked --offline -p victory-gpu — 229 passed, 0 failed, 1 ignored (the existing synthetic benchmark). The doc-test harness ran 0 tests and passed.
  • cargo clippy --locked --offline -p victory-gpu --all-targets — passed with no warnings.
  • cargo run --locked --offline -p xtask -- policy --staged — passed after git add. The asset policy accepted the one staged file.

What was not tested

No game run and no hardware run of the game.

Fixes #2847

AI assistance: prepared with OpenAI Codex under Claude Code's direction, reviewed by Ingenioeren.

🤖 Generated with Claude Code

**@⁠Ingenioeren** on GitHub · 2026-11-25 22:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2851) `Ingenioeren:fix/2847-null-srv-alias-source` → `main` · +10 −0 · 1 files · 1 commits · closed without merging ## What Return `None` from `resource::alias_source` when the resource pointer is null. Add a Windows regression test that calls `alias_source` directly with a null pointer. ## Why Since #1273, `draw::readable` looks for a texture alias for every SRV, including `View::Shader(0, _)`. Passing that zero pointer to `resource()` causes a null dereference. The guard protects every caller of `alias_source`. `host_resource` already returns `None` for null, which skips `texture::upload` and the diagnostics `GetDesc` call. `list::ensure_state` exits through `HostList::transition` when `host_copy` returns `None`. Thanks to frenziedcoder for diagnosing the crash. ## How tested - `cargo test --locked --offline -p victory-gpu resource::tests::a_null_shader_view_has_no_alias_source -- --exact` — with the guard stashed and the test staged, the test binary reported a null pointer dereference in `resource()` and aborted with `0xc0000409` (`STATUS_STACK_BUFFER_OVERRUN`). With the guard restored, the same command passed (1 passed, 0 failed). - `cargo test --locked --offline -p victory-gpu` — 229 passed, 0 failed, 1 ignored (the existing synthetic benchmark). The doc-test harness ran 0 tests and passed. - `cargo clippy --locked --offline -p victory-gpu --all-targets` — passed with no warnings. - `cargo run --locked --offline -p xtask -- policy --staged` — passed after `git add`. The asset policy accepted the one staged file. ## What was not tested No game run and no hardware run of the game. Fixes #2847 AI assistance: prepared with OpenAI Codex under Claude Code's direction, reviewed by Ingenioeren. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Return no alias source before dereferencing a null resource, and cover the null SRV with a regression test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:15:55 +00:00
github-bot closed this pull request 2026-11-26 05:15:55 +00:00
Author
Owner

@⁠Machad3x on GitHub · 2026-11-25 22:30 UTC · original

Confirms the crash on a second host (RTX 3080 Ti, driver 621.24, Windows 11), in a fork that had cherry-picked #1273: access violation (read 0x60) at world load, symbolised to Resource::data under alias_source from draw::readable. The same null guard in alias_source fixed it: one 7-minute run in play afterwards, no crash and no device removal. Tested with an equivalent local change, not this head.

Ran with AI assistance (Claude Code).

**@⁠Machad3x** on GitHub · 2026-11-25 22:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/2851#issuecomment-7176440585) Confirms the crash on a second host (RTX 3080 Ti, driver 621.24, Windows 11), in a fork that had cherry-picked #1273: access violation (read 0x60) at world load, symbolised to `Resource::data` under `alias_source` from `draw::readable`. The same null guard in `alias_source` fixed it: one 7-minute run in play afterwards, no crash and no device removal. Tested with an equivalent local change, not this head. Ran with AI assistance (Claude Code).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 22:34 UTC · original

Verified 6cb83cda on Windows 11 (RTX 5090 + WARP) against main (f3578e3):

  • cargo xtask policy (190 files ok), cargo clippy --locked -p victory-gpu --all-targets (default & --features diagnostics, 0 warnings).
  • RTX 5090 (--features diagnostics): resource::tests 18/18, draw::tests 20/20 passed.
  • WARP (--features diagnostics): resource::tests 18/18, draw::tests 20/20 passed.
  • Audited draw::readable and sibling entry points on f3578e3: both SRV and UAV paths already null-guard host_resource, made_copy, buffer_bytes, and capture::note_target, leaving alias_source as the missing null guard. (Optional nit: a test calling draw::readable with View::Shader(0, ...) would also cover the full caller path.)

Looks clean and ready to merge.

**@⁠fuzeofficlal** on GitHub · 2026-11-25 22:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/2851#issuecomment-7176528843) Verified `6cb83cda` on Windows 11 (RTX 5090 + WARP) against `main` (`f3578e3`): - `cargo xtask policy` (`190 files ok`), `cargo clippy --locked -p victory-gpu --all-targets` (default & `--features diagnostics`, 0 warnings). - RTX 5090 (`--features diagnostics`): `resource::tests` 18/18, `draw::tests` 20/20 passed. - WARP (`--features diagnostics`): `resource::tests` 18/18, `draw::tests` 20/20 passed. - Audited `draw::readable` and sibling entry points on `f3578e3`: both `SRV` and `UAV` paths already null-guard `host_resource`, `made_copy`, `buffer_bytes`, and `capture::note_target`, leaving `alias_source` as the missing null guard. (Optional nit: a test calling `draw::readable` with `View::Shader(0, ...)` would also cover the full caller path.) Looks clean and ready to merge.
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 22:49 UTC · original

This just landed on main as 219878a ('GPU: a null shader view has no alias source') — same guard, same test name. This PR is now a no-op; suggest closing.

**@⁠kotekompotek** on GitHub · 2026-11-25 22:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2851#issuecomment-7176835720) This just landed on main as 219878a ('GPU: a null shader view has no alias source') — same guard, same test name. This PR is now a no-op; suggest closing.
Author
Owner

@⁠moe-miau on GitHub · 2026-11-25 23:04 UTC · original

Tested on an RTX 4070 SUPER (driver 32.0.16.1742, Windows 11 26300), title 1.0.2.1, Series X profile, diag build, scripted Enter presses. Tree: main f3578e3 + #2464 + #2098 + #2626 + #2628 + #2711.

result
without this PR title gone at 129 s, during loading: 0xc0000005 reading 0x30 in resource::alias_source (resource.rs:1883, called from draw.rs:1910), the crash of #2847
with this PR (6cb83cd) no crash in a 6-minute run; reaches the opening credits; no device removal

Two runs in all, one each. AI-assisted (Claude Code). Runs done on my machine.

**@⁠moe-miau** on GitHub · 2026-11-25 23:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/2851#issuecomment-7177119947) Tested on an RTX 4070 SUPER (driver 32.0.16.1742, Windows 11 26300), title 1.0.2.1, Series X profile, diag build, scripted Enter presses. Tree: `main` `f3578e3` + #2464 + #2098 + #2626 + #2628 + #2711. | | result | |---|---| | without this PR | title gone at 129 s, during loading: `0xc0000005` reading `0x30` in `resource::alias_source` (`resource.rs:1883`, called from `draw.rs:1910`), the crash of #2847 | | with this PR (`6cb83cd`) | no crash in a 6-minute run; reaches the opening credits; no device removal | Two runs in all, one each. AI-assisted (Claude Code). Runs done on my machine.
Author
Owner

@⁠davesousa on GitHub · 2026-11-25 23:22 UTC · original

Game run of this head on current main: RTX 3070 Ti 8 GB (Ampere), driver 621.40, Windows 11 26200. diag build, VICTORY_D3D12_DRED=1. Tree: main f3578e3 + #2319 (boot on NVIDIA) + #2178 (W from #1968); cache and pipelines rebuilt for it.

Tree Run
f3578e3 + #2319 + #2178 0xc0000005 at victory.exe+0x224443 (read 0x30) about 100 s in, as world compute binds (frame about 1,660). Symbolised with the build's PDB: resource::alias_source::closure$1 (resource.rs:1817), resource::alias_source, draw::readable (draw.rs:1897), draw::State::bind, draw::State::dispatch, list::state::dispatch. Same as #2847.
+ this PR (6cb83cd, merges cleanly; its test passes) No crash. 15 min, stopped by me: world reached at about 100 s, intro cutscene, up to 7,552 draws/frame, frames 0.40-2.0 s (median 0.98 s), no device removal

One run each, so the counts are small, but the stop is the one #2847 describes and the guard removes it on a third card.

AI-assisted (Claude Code); the runs are on my machine.

**@⁠davesousa** on GitHub · 2026-11-25 23:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/2851#issuecomment-7177471417) Game run of this head on current `main`: RTX 3070 Ti 8 GB (Ampere), driver 621.40, Windows 11 26200. `diag` build, `VICTORY_D3D12_DRED=1`. Tree: `main` `f3578e3` + #2319 (boot on NVIDIA) + #2178 (W from #1968); cache and pipelines rebuilt for it. | Tree | Run | |---|---| | `f3578e3` + #2319 + #2178 | `0xc0000005` at `victory.exe+0x224443` (read 0x30) about 100 s in, as world compute binds (frame about 1,660). Symbolised with the build's PDB: `resource::alias_source::closure$1` (resource.rs:1817), `resource::alias_source`, `draw::readable` (draw.rs:1897), `draw::State::bind`, `draw::State::dispatch`, `list::state::dispatch`. Same as #2847. | | + this PR (`6cb83cd`, merges cleanly; its test passes) | No crash. 15 min, stopped by me: world reached at about 100 s, intro cutscene, up to 7,552 draws/frame, frames 0.40-2.0 s (median 0.98 s), no device removal | One run each, so the counts are small, but the stop is the one #2847 describes and the guard removes it on a third card. AI-assisted (Claude Code); the runs are on my machine.
Author
Owner

@⁠Ingenioeren on GitHub · 2026-11-25 23:59 UTC · original

Closing: main already has this guard as 219878a ("GPU: a null shader view has no alias source"), so this PR is a no-op now. Thanks to everyone who tested it.

**@⁠Ingenioeren** on GitHub · 2026-11-25 23:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/2851#issuecomment-7178270517) Closing: main already has this guard as 219878a ("GPU: a null shader view has no alias source"), so this PR is a no-op now. Thanks to everyone who tested it.

Pull request closed

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!2851
No description provided.