Skip to content

GPU: a null SRV has no alias source - #2851

Closed
Ingenioeren wants to merge 1 commit into
Marvisak:mainfrom
Ingenioeren:fix/2847-null-srv-alias-source
Closed

Ingenioeren wants to merge 1 commit into
Marvisak:mainfrom
Ingenioeren:fix/2847-null-srv-alias-source

Conversation

@Ingenioeren

Copy link
Copy Markdown
Contributor

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

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 <noreply@anthropic.com>
@Machad3x

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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.

@davesousa

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

6 participants