Skip to content

GPU tests: a device removal fails the test that found it, later tests skip (#2317 item 1) - #2430

Open
KainanP wants to merge 2 commits into
Marvisak:mainfrom
KainanP:fix/gpu-test-device-removal
Open

KainanP wants to merge 2 commits into
Marvisak:mainfrom
KainanP:fix/gpu-test-device-removal

Conversation

@KainanP

@KainanP KainanP commented Nov 25, 2026 •

Copy link
Copy Markdown

Part of #2317 (item 1: one device removal takes the whole victory-gpu test run down with it). Items 2 and 3 are covered by #2315 / #2322 and are not touched here.

Root cause

The victory-gpu tests share one host device: host() keeps it in a OnceLock, and D3D12 hands a process the same device per adapter anyway. When a test removes it:

  • through a submission, Host::execute sees the removal and calls fail(). In tests nothing set on_failure, so fail() calls std::process::abort(). On Windows that is __fastfail, which shows up as 0xc0000409 (STATUS_STACK_BUFFER_OVERRUN). That is the "stack overrun" in the issue. The report goes through tracing::error!, and tests have no subscriber, so it is lost. The binary dies mid-line (test x ... and nothing after it) without naming a test or a reason.
  • any other way (a device call that removes it, or a removal nobody checks for), every later test fails at its next device call with the same 0x887A0005. Each of those failures looks like its own bug, and the test that actually removed the device may not even fail.

Design (test builds only; runtime builds are unchanged)

New #[cfg(test)] mod host::removal, wired into host.rs with #[cfg(test)] hooks only:

  • fail() panics in the test that called it instead of aborting. Its message already has device removed: <reason> plus the DRED data (removal_data) when it is on. On a victory-* worker thread, which tests do not join, it writes the report to stderr and aborts as before.
  • The first test found holding a removed device gets recorded. That can happen in fail(), in host(), or in a panic. The harness writes one line to the real stderr (outside libtest's capture, so it still shows if the process ends early). With VICTORY_D3D12_DRED=1 (diagnostics builds) the line also carries the DRED/breadcrumb data:
    victory-gpu tests: `<test>` found the host device removed (0x887A0005 …); GPU tests after it skip the host GPU
  • After that, host() returns None to every other test. Tests already treat that as "no host GPU here" and return early, and runtime code called through the console's tables already handles None. Each skipping test writes one line: `<test>` skips the host GPU: the device was found removed in `<culprit>` (<reason>). The recorded test keeps its host, so it fails on its own calls. host() itself never panics, because it is reached from extern "system" functions, which cannot unwind.
  • A panic hook, installed when the host is made, adds a note to any panic after a removal. In the culprit: the host device is removed (<reason>); this test was the first to find it so …. In any other test: the host device was found removed in `<culprit>` … this failure may only follow from that. This mainly helps tests already running in parallel when the removal happened.

I did not recreate the device for later tests. Many statics hold objects made on the device: descriptor heaps, title-buffer copies, pipelines and root signatures, the bindless upload list. A new device would mix objects from two devices. A skip is honest and keeps the scope to tests.

Known limit: if fail() is reached under an extern "system" frame (a test calling a console table function that submits), the panic cannot unwind past that frame and the process still aborts. The stderr line naming the test and the reason is written before that happens.

Tests

host::removal::tests::a_test_that_removes_the_device_fails_alone runs this test binary in child processes, because a removal in-process would remove the device for every test. In each child, child_1 removes the device with ID3D12Device5::RemoveDevice and then either submits a list (submission), makes a device call (call), or does nothing more (unnoticed). child_2 and child_3 are ordinary GPU tests that run after it. --test-threads=1 keeps them in that order. The parent checks that:

  • the child exits as a run with failed tests (101), not an abort;
  • exactly one test fails (child_1, or child_2 in the unnoticed case, since it is the first to find the removal), with the reason;
  • the tests after it pass by skipping, and their skip line names the culprit.

The child_* tests do nothing unless VICTORY_TEST_REMOVES_DEVICE is set, so the normal run never removes the shared device. The assertions use only our own English strings, not the localized HRESULT text.

Before (main 940d32f, same test):

scenario result on main
submission child exits -1073740791 (0xc0000409) after test …child_1_removes_the_device ... , no message
call child_1, child_2, child_3 all FAILED with the same HRESULT(0x887A0005) unwrap
unnoticed child_1 ok (the culprit passes), child_2 and child_3 FAILED with the same unwrap

The parent test fails on main, on RTX and on WARP: left: Some(-1073740791) right: Some(101).

After: in every scenario exactly one test fails and names the reason, the later ones are ok with the skip line, and the exit code is 101. The parent test passes.

Results

RTX 4060 Laptop (driver 610.47), Windows 11 26200, Rust 1.98.1. WARP is VICTORY_WARP=1 VICTORY_D3D12_WARP=1 with --all-features, because VICTORY_D3D12_WARP needs the diagnostics feature.

run main 940d32f this branch
cargo test --workspace --locked --no-fail-fast (RTX) gpu 141 ok / 2 failed, shader 244 / 3 gpu 145 ok / 2 failed, shader 244 / 3
--all-features (RTX) (same 5 failures) gpu 148 ok / 2 failed, shader 244 / 3
--all-features, WARP gpu 146 ok / 0, shader 245 / 2 gpu 150 ok / 0, shader 245 / 2
cargo clippy --workspace --all-targets [--all-features] -- -D warnings clean (both)
cargo xtask policy ok

On both sides, the RTX failures are the known ones: dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views (NVIDIA heap cap, #2315), plus the three victory-shader tests fixed by #2322. The WARP victory-shader failures (gathers_at_a_level_match_the_hardware, permutes_read_the_lane_named_and_zero_from_lanes_left_out) are identical on main. The new test also passes inside the full parallel run on both adapters. A RemoveDevice in the child process does not disturb the parent's device. With VICTORY_D3D12_DRED=1 the found-removed line carries the breadcrumb data.

No game data was used: everything here is cargo test.

AI use: Claude Code (Claude Opus 5.5)

🤖 Generated with Claude Code

@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown

Verification — head d38411372a6508280adb7d76d0413ff5d888d9dc

Environment: Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1, DXC/dxil 1.8.2502.11 (Windows Kits 10.0.26100.0 x64). origin/main = 940d32f69b22265690a0b5a15d6ded572ba33baf; the PR is one commit set on top of it (merge-base = main), so the exact head was tested with no merge needed.

  • cargo test -p victory-gpu --lib --features diagnostics -- --test-threads=1: 150 passed, 0 failed, 2 ignored (+4 vs main). New tests host::removal::tests::a_test_that_removes_the_device_fails_alone and child_1/2/3 ran and passed: the parent re-runs its own test binary as a child process for the three removal modes (inherits the WARP env) and RemoveDevice works on WARP.
  • clippy with and without diagnostics: clean. cargo xtask policy: ok (183 files).
  • GPU tests ran with VICTORY_D3D12_WARP=1 and --features diagnostics (the switch has no effect without that feature), -- --test-threads=1; warp_adapter_accepts_only_software ran and passed (adapter vendor 0x1414, software flag). Baseline origin/main for the same command: 146 passed, 0 failed, 2 ignored.

Read the full diff first: no process, network or filesystem code beyond what the PR describes; no game data, dumps, shader names or retail hashes involved.

Verified by Claude Code (Claude Sonnet 5.5), an AI assistant; this is a test report, not a code review or approval.

@kotekompotek

Copy link
Copy Markdown

Verified on Windows 10 / GTX 1050 at d384113: cargo test -p victory-gpu --lib host::removal — 4/4 pass, including the subprocess harness (a_test_that_removes_the_device_fails_alone) exercising real RemoveDevice on hardware through all three paths (submission / call / unnoticed).

Design notes:

  • host() → usable() means the culprit test still gets the device (its own calls surface the real error) while every later test sees None and skips — matches how the suite already treats host-less machines.
  • failed() panicking only on test threads and writing to stderr on victory-* worker threads is the right split: workers cannot unwind (called through the console's tables), so the report is logged and the process still ends — now with the culprit named on stderr instead of a bare 0xc0000409.
  • REPORTING gating the panic hook avoids double-annotating the failure report panic itself.
  • Runtime builds unchanged (#[cfg(test)] throughout; #[cfg(not(test))] host() is the old created()).

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:

  • Isolating device removal so only the first removing test fails and subsequent tests skip (#2317 item 1) works cleanly on both RTX 5090 and WARP!
  • cargo test -p victory-gpu removal: 5/5 passed on RTX 5090, 5/5 passed on WARP (including a_test_that_removes_the_device_fails_alone).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 184 files ok.

AI-assisted (Gemini 4 Neon).

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPU tests: a device removal fails the test that found it (+286). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs work: needs the maintainer's decision. This adds test-only infrastructure in crates/victory-gpu/src/host.rs and host/removal.rs. When a test removes the device, that test fails, later tests see host() as None and skip, and stderr names the test that found the removal. Before, the removal cascaded into later tests or aborted the process. All of it is #[cfg(test)], and runtime builds are unchanged. CI is passing.

Reply to the author: both points from the last triage are addressed in ca5f7baa. a_test_that_removes_the_device_fails_alone is now #[ignore], which matches the #[ignore = "..."] tests already in victory-formats, victory-gpu/src/object.rs and victory-shader. The note to the test that finds the removal now also covers a test running alongside it. The ignored test still re-runs the test binary through std::process::Command when someone runs it. Whether the suite should carry a test that starts processes is still the maintainer's call, so the verdict stays. The PR is ready if the maintainer accepts that test, or wants it dropped.

CI: check passing.


Generated by Claude Code

… skip

The victory-gpu tests share one host device (`host()`'s OnceLock, and
D3D12 gives a process one device per adapter anyway). When a test
removed it:

- through a submission, `fail()` found no `on_failure` report set and
  called `std::process::abort()`: the test binary ended with 0xc0000409
  and the report, logged through `tracing` with no subscriber in tests,
  was lost, so no test was named;
- otherwise every later test failed at its next device call with the
  same DXGI_ERROR_DEVICE_REMOVED, the culprit among them or not at all.

In test builds only (`host::removal`): a failure report panics in the
test that made it; the first test found holding a removed device is
named on the process's standard error with the removal reason (and the
device-removed data with VICTORY_D3D12_DRED); after it `host()` is None
to every other test, which skips the host GPU as on a machine without
one; and a panic after the removal notes it. Runtime builds are
unchanged.

The new test runs this binary in child processes in which a test removes
the device (ID3D12Device5::RemoveDevice) by a submission, by a call, or
unnoticed, and checks that exactly one test fails, with the reason, the
others skip naming it, and the run ends as failed tests (101), not an
abort. On main it aborts with 0xc0000409.

Part of Marvisak#2317 (item 1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KainanP
KainanP force-pushed the fix/gpu-test-device-removal branch from d384113 to c3d2fcd Compare November 25, 2026 16:56
@KainanP

KainanP commented Nov 25, 2026

Copy link
Copy Markdown
Author

Rebased onto main 67e8ae1; a_test_that_removes_the_device_fails_alone passes (RTX/WARP), victory-gpu --all-features passes on RTX except dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views, which fail the same way on main (capped NVIDIA heap); clippy and policy pass.

AI use: Claude Code (Claude Opus 5.5).

Triage asked for a maintainer decision on a test that spawns processes. It
now carries #[ignore], as the repository's other tests that need something
outside a plain run do, so 'cargo test' starts no process; '--ignored' runs
it. The note to the test that first finds the device removed also says it
may have been removed in a test running alongside it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KainanP

KainanP commented Nov 25, 2026

Copy link
Copy Markdown
Author

Both triage points are addressed in ca5f7baa:

  • Spawning processes: a_test_that_removes_the_device_fails_alone now carries #[ignore = "starts this test binary again; run with --ignored"], the same convention as the repository's other tests that need more than a plain run (victory-formats benchmarks and reference-file tests). A plain cargo test therefore starts no process; cargo test -p victory-gpu --lib host::removal -- --ignored runs it. Nothing else in the suite depends on it, so the maintainer can drop it entirely if preferred.
  • Parallel tests: the note to the first test that finds the device removed now says it was removed "here, in a test before this one, or in one running alongside it".

RTX 4060 Laptop: host::removal 3 passed, 1 ignored; with --ignored the subprocess test passes (1.6 s). cargo clippy -p victory-gpu --all-targets -- -D warnings clean, rustfmt --check clean.

AI use: Claude Code (Claude Opus 5.5) made the change and ran the tests.

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 25, 2026
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants