GPU: since #1273, null SRVs reach alias_source and crash (0xc0000005, read 0x30) as the world loads #2847

Open
opened 2026-11-26 05:15:47 +00:00 by github-bot · 5 comments
Owner

@⁠frenziedcoder on GitHub · 2026-11-25 22:10 UTC · original

Since #1273, draw::readable calls resource::alias_source for every shader-resource view, including null SRVs (View::Shader(0, _)), and alias_source(0) dereferences a null Resource: 0xc0000005 (read 0x30) as the world loads. A *resource != 0 guard fixes it here.

What happens: RTX 5080 (driver 621.40), Windows 11 26200, title 1.0.2.1, Series X profile, diag build. Tree: main 61bfc77 plus the NVIDIA stack from #2464 / #2176 (#1906, #2098, #2626, #2628, #2464, #2176, #2118) — plain main does not reach the world on NVIDIA, so I could not run it alone. Two runs, both at the same point (frame 1,328, as the world's first compute pipelines bind, ~55 s):

VIctory: unhandled exception 0xc0000005 at victory-diag.exe+0x229813 (read 0x30: nothing mapped there)

Symbolised with the build's PDB:

victory_gpu::resource::alias_source::closure$1   resource.rs (the `bytes(&b.desc)` closure)
victory_gpu::resource::alias_source
victory_gpu::draw::readable                      draw.rs  (the call #1273 added)
victory_gpu::draw::State::bind
victory_gpu::draw::State::dispatch
victory_gpu::list::state::dispatch

Why: before #1273, alias_source was only called for the View::Shader that placed_texture() returned, i.e. a texture made by texture_at, as its doc says ("For a texture made for a placed view"). #1273 moved the call into readable's (View::Shader(resource, _), ResourceType::Srv) arm, so it now runs for every SRV. A null SRV is View::Shader(0, None) (descriptor.rs's own test: create_srv(null, …) → View::Shader(0, None)), and resource() is an unchecked &*this.cast::<Resource>(), so alias_source(0) reads b.desc at a null base. Nothing here is NVIDIA-specific; any title that binds a null SRV to a dispatch should reach it.

Check:

  • Same tree with #1273 reverted (git revert 61bfc77, clean): no crash, world reached, 180 s.
  • Same tree with #1273 and this guard: no crash, full 600 s run, world drawn, no other change in behaviour I could see:
             // A view of memory the GPU writes through another title texture
             // whose host copy this one could not share reads that copy.
-            if let Some(a) = crate::resource::alias_source(*resource as This) {
+            if *resource != 0
+                && let Some(a) = crate::resource::alias_source(*resource as This)
+            {
                 crate::texture::alias_copy(list, a, *resource as This);
             }

An early return None in alias_source for a null placed would cover other callers too.

Not tested: plain main; AMD; whether any other caller passes a null view to alias_source.

AI use: Claude Code (Claude Opus 5.5) found the crash in runs on my machine (sandboxed at Low integrity, game folder read-only), symbolised it, bisected it to #1273 and tested the guard, and wrote this issue.

**@⁠frenziedcoder** on GitHub · 2026-11-25 22:10 UTC · [original](https://github.com/Marvisak/VIctory/issues/2847) **Since #1273, `draw::readable` calls `resource::alias_source` for every shader-resource view, including null SRVs (`View::Shader(0, _)`), and `alias_source(0)` dereferences a null `Resource`: `0xc0000005` (read `0x30`) as the world loads. A `*resource != 0` guard fixes it here.** **What happens:** RTX 5080 (driver 621.40), Windows 11 26200, title 1.0.2.1, Series X profile, `diag` build. Tree: `main` `61bfc77` plus the NVIDIA stack from #2464 / #2176 (#1906, #2098, #2626, #2628, #2464, #2176, #2118) — plain `main` does not reach the world on NVIDIA, so I could not run it alone. Two runs, both at the same point (frame 1,328, as the world's first compute pipelines bind, ~55 s): ``` VIctory: unhandled exception 0xc0000005 at victory-diag.exe+0x229813 (read 0x30: nothing mapped there) ``` Symbolised with the build's PDB: ``` victory_gpu::resource::alias_source::closure$1 resource.rs (the `bytes(&b.desc)` closure) victory_gpu::resource::alias_source victory_gpu::draw::readable draw.rs (the call #1273 added) victory_gpu::draw::State::bind victory_gpu::draw::State::dispatch victory_gpu::list::state::dispatch ``` **Why:** before #1273, `alias_source` was only called for the `View::Shader` that `placed_texture()` returned, i.e. a texture made by `texture_at`, as its doc says ("For a texture made for a placed view"). #1273 moved the call into `readable`'s `(View::Shader(resource, _), ResourceType::Srv)` arm, so it now runs for every SRV. A null SRV is `View::Shader(0, None)` (`descriptor.rs`'s own test: `create_srv(null, …)` → `View::Shader(0, None)`), and `resource()` is an unchecked `&*this.cast::<Resource>()`, so `alias_source(0)` reads `b.desc` at a null base. Nothing here is NVIDIA-specific; any title that binds a null SRV to a dispatch should reach it. **Check:** - Same tree with #1273 reverted (`git revert 61bfc77`, clean): no crash, world reached, 180 s. - Same tree with #1273 and this guard: no crash, full 600 s run, world drawn, no other change in behaviour I could see: ```diff // A view of memory the GPU writes through another title texture // whose host copy this one could not share reads that copy. - if let Some(a) = crate::resource::alias_source(*resource as This) { + if *resource != 0 + && let Some(a) = crate::resource::alias_source(*resource as This) + { crate::texture::alias_copy(list, a, *resource as This); } ``` An early `return None` in `alias_source` for a null `placed` would cover other callers too. **Not tested:** plain `main`; AMD; whether any other caller passes a null view to `alias_source`. *AI use: Claude Code (Claude Opus 5.5) found the crash in runs on my machine (sandboxed at Low integrity, game folder read-only), symbolised it, bisected it to #1273 and tested the guard, and wrote this issue.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:15:47 +00:00
Author
Owner

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

Verified on main: draw::readable (draw.rs:1712) calls alias_source(*b) for every placed View::Shader — a null SRV arrives as View::Shader(0, _), and alias_source(0) reads b.desc at offset 0x30 through a null Resource (resource.rs:1389-1391), exactly the reported 0xc0000005 read 0x30. The *b != 0 guard at the call site (or inside alias_source) is the right fix — cheap and unambiguous.

**@⁠kotekompotek** on GitHub · 2026-11-25 22:12 UTC · [original](https://github.com/Marvisak/VIctory/issues/2847#issuecomment-7176063975) Verified on main: draw::readable (draw.rs:1712) calls alias_source(*b) for every placed View::Shader — a null SRV arrives as View::Shader(0, _), and alias_source(0) reads b.desc at offset 0x30 through a null Resource (resource.rs:1389-1391), exactly the reported 0xc0000005 read 0x30. The *b != 0 guard at the call site (or inside alias_source) is the right fix — cheap and unambiguous.
Author
Owner

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

Confirmed fixed by 219878a ("a null shader view has no alias source") on the RTX 5080 (621.40): main 842b0cb with the same NVIDIA stack, without my local guard, ran 600 s into the world with no 0xc0000005 (the old tree crashed at the same frame twice). This can be closed from my side.

**@⁠frenziedcoder** on GitHub · 2026-11-25 23:25 UTC · [original](https://github.com/Marvisak/VIctory/issues/2847#issuecomment-7177549129) Confirmed fixed by `219878a` ("a null shader view has no alias source") on the RTX 5080 (621.40): `main` `842b0cb` with the same NVIDIA stack, without my local guard, ran 600 s into the world with no `0xc0000005` (the old tree crashed at the same frame twice). This can be closed from my side.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 00:43 UTC · original · edited 2026-11-26 03:43 UTC

Automated triage for the maintainers.

Fixed in main. Commit 219878a ("GPU: a null shader view has no alias source") makes alias_source in crates/victory-gpu/src/resource.rs return None for a null view before it reads the description, with the test a_null_view_has_no_alias_source. The reporter confirmed above that 842b0cb runs 600 s into the world without the crash; the later comment points to the same commit. Open pull request #2865 adds further guards in the same function and can continue on its own.

This issue will be closed in 48 hours unless the reporter replies or a maintainer removes the triage: proposed close label.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 00:43 UTC · [original](https://github.com/Marvisak/VIctory/issues/2847#issuecomment-7179044494) · edited 2026-11-26 03:43 UTC <!-- victory-issue-triage v1 verdict=proposed-close seen=2026-11-26T03:00:42Z at=2026-11-26T03:52:00Z --> Automated triage for the maintainers. Fixed in `main`. Commit 219878a ("GPU: a null shader view has no alias source") makes `alias_source` in `crates/victory-gpu/src/resource.rs` return `None` for a null view before it reads the description, with the test `a_null_view_has_no_alias_source`. The reporter confirmed above that `842b0cb` runs 600 s into the world without the crash; the later comment points to the same commit. Open pull request #2865 adds further guards in the same function and can continue on its own. This issue will be closed in 48 hours unless the reporter replies or a maintainer removes the `triage: proposed close` label. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-26 03:00 UTC · original

Heads-up: this should be fixed on main by 219878a (GPU: a null shader view has no alias source) — readable now returns an ordinary view for a null SRV instead of handing the null pointer to alias_source, which was the read-0x30 crash site. Worth a retest on the world-loading path that hit it.

**@⁠kotekompotek** on GitHub · 2026-11-26 03:00 UTC · [original](https://github.com/Marvisak/VIctory/issues/2847#issuecomment-7181315223) Heads-up: this should be fixed on main by 219878a (`GPU: a null shader view has no alias source`) — `readable` now returns an ordinary view for a null SRV instead of handing the null pointer to `alias_source`, which was the read-0x30 crash site. Worth a retest on the world-loading path that hit it.
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-26 06:55 UTC · original

This is fixed on main: 219878a ("GPU: a null shader view has no alias source") makes alias_source return None for a null resource — the exact crash site in your stack — and adds a_null_view_has_no_alias_source. The readable call it guards is at draw.rs:1918 on current main.

**@⁠kotekompotek** on GitHub · 2026-11-26 06:55 UTC · [original](https://github.com/Marvisak/VIctory/issues/2847#issuecomment-7184921400) This is fixed on main: `219878a` ("GPU: a null shader view has no alias source") makes `alias_source` return None for a null resource — the exact crash site in your stack — and adds `a_null_view_has_no_alias_source`. The `readable` call it guards is at draw.rs:1918 on current main.
This discussion has been locked. Commenting is limited to contributors.
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#2847
No description provided.