GPU: a null SRV has no alias source #2849

Closed
Ingenioeren wants to merge 1 commit from upstream-pr/2851 into main
Ingenioeren commented 2026-11-25 22:20:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Ingenioeren on 2026-11-25T22:20:12Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:issue:6614929657 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2851). Originally posted by [Ingenioeren](https://github.com/Ingenioeren) on 2026-11-25T22:20:12Z. --- ## 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)
Machad3x commented 2026-11-25 23:06:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Machad3x on 2026-11-25T22:30:09Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176440585 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2851#issuecomment-7176440585). Originally posted by [Machad3x](https://github.com/Machad3x) on 2026-11-25T22:30:09Z. --- 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).
fuzeofficlal commented 2026-11-25 23:06:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T22:34:21Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176528843 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2851#issuecomment-7176528843). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T22:34:21Z. --- 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.
kotekompotek commented 2026-11-25 23:06:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T22:49:48Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176835720 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2851#issuecomment-7176835720). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T22:49:48Z. --- 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.
moe-miau commented 2026-11-25 23:06:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by moe-miau on 2026-11-25T23:04:40Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177119947 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2851#issuecomment-7177119947). Originally posted by [moe-miau](https://github.com/moe-miau) on 2026-11-25T23:04:40Z. --- 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.
upstream-sync closed this pull request 2026-11-26 00:02:50 +00:00
davesousa commented 2026-11-26 00:03:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by davesousa on 2026-11-25T23:22:25Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177471417 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2851#issuecomment-7177471417). Originally posted by [davesousa](https://github.com/davesousa) on 2026-11-25T23:22:25Z. --- 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.
Ingenioeren commented 2026-11-26 00:03:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Ingenioeren on 2026-11-25T23:59:10Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7178270517 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2851#issuecomment-7178270517). Originally posted by [Ingenioeren](https://github.com/Ingenioeren) on 2026-11-25T23:59:10Z. --- 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

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2849
No description provided.