DRED: a device lost under asynchronous submission (the default) reports the fault address and breadcrumbs too #214

Open
github-bot wants to merge 2 commits from github-bot/gh-214 into main AGit
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 23:56 UTC · original
MamaLeVrai:dred-async → main · +75 −18 · 2 files · 2 commits · open

With VICTORY_D3D12_DRED=1 in a diagnostics build, a device loss prints the faulting address and the breadcrumbs only on the synchronous path. Asynchronous submission is the default (VICTORY_ASYNC_SUBMIT), and there a loss prints only host GPU device gone reason=…, so the DRED data that was asked for is never read.

Where. Host::execute_inner checks GetDeviceRemovedReason and calls fail(… removal_data(runs) …) only after it has waited for a submission (host.rs, after slow host submission). An asynchronous submission signals its fence and continues before that point. The loss is then first seen when making a list or an upload/shared buffer fails, and wait_if_removed logs only the reason.

My two runs on an RX 6950 XT (RDNA2) that ended in 0x887A0007 ran asynchronously and logged only the reason. (#151 was on 01aadd1, before asynchronous submission was the default, and did get breadcrumbs, though no fault address.) Note: in my two runs DRED was not switched on either, so they only show where the report would be missing, not what it would say.

The change. When DRED is on, wait_if_removed adds Host::removal_data to its line, over the lists of the submissions still in flight (in_flight, through try_lock; if it is held, over none). If those lists are already reaped, removal_data still gives the page-fault address and allocations and each list's breadcrumb progress, without the pipelines. Without DRED nothing changes.

Checked. cargo clippy --release -p victory-gpu --no-deps, with and without --features diagnostics, builds with no new warning. I have not been able to make a device loss on purpose to see the new line; I have not run the game with it.

AI-assisted (Claude Code); no game data.

🤖 Generated with Claude Code

**@⁠MamaLeVrai** on GitHub · 2026-11-25 23:56 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/214) `MamaLeVrai:dred-async` → `main` · +75 −18 · 2 files · 2 commits · open With `VICTORY_D3D12_DRED=1` in a diagnostics build, a device loss prints the faulting address and the breadcrumbs only on the synchronous path. Asynchronous submission is the default (`VICTORY_ASYNC_SUBMIT`), and there a loss prints only `host GPU device gone reason=…`, so the DRED data that was asked for is never read. **Where.** `Host::execute_inner` checks `GetDeviceRemovedReason` and calls `fail(… removal_data(runs) …)` only after it has waited for a submission (`host.rs`, after `slow host submission`). An asynchronous submission signals its fence and `continue`s before that point. The loss is then first seen when making a list or an upload/shared buffer fails, and `wait_if_removed` logs only the reason. My two runs on an RX 6950 XT (RDNA2) that ended in `0x887A0007` ran asynchronously and logged only the reason. (#151 was on `01aadd1`, before asynchronous submission was the default, and did get breadcrumbs, though no fault address.) Note: in my two runs DRED was not switched on either, so they only show where the report would be missing, not what it would say. **The change.** When DRED is on, `wait_if_removed` adds `Host::removal_data` to its line, over the lists of the submissions still in flight (`in_flight`, through `try_lock`; if it is held, over none). If those lists are already reaped, `removal_data` still gives the page-fault address and allocations and each list's breadcrumb progress, without the pipelines. Without DRED nothing changes. **Checked.** `cargo clippy --release -p victory-gpu --no-deps`, with and without `--features diagnostics`, builds with no new warning. I have not been able to make a device loss on purpose to see the new line; I have not run the game with it. AI-assisted (Claude Code); no game data. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:38:06 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-25 23:56 UTC · original · reviewed

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-25 23:56 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/214#pullrequestreview-6066674593) · **reviewed** Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-26 19:52 UTC · original

Tested on native Windows 11 (26300) with an RX 7900 XT (driver 32.0.32029.2010) and with WARP. Head 9d1f4c4, base 4f62c2a.

Tests:

  • cargo test -p victory-gpu --lib, with and without --features diagnostics, 8 runs each, alternating with base. The only failures were in watch, pipeline::library, frame and queue, which this PR does not touch, and the same tests also fail on base. Other heavy jobs were running on the machine at the same time.

Report path, checked with a local-only test (diagnostics build, VICTORY_D3D12_DRED=1) that calls ID3D12Device5::RemoveDevice and then shared_buffer:

  • The new field is printed: host GPU device gone reason=Err(0x887A0005 ...) layer=None dred=; breadcrumbs (done/count, list) [] (reason shortened). Base prints the same line without dred. WARP and the 7900 XT give the same result.
  • The breadcrumb list stays empty under RemoveDevice, even with a list held behind an unsignalled queue.Wait and left in in_flight. So I could not check the list mapping this way.
  • After RemoveDevice, queue.Signal still returns S_OK and fence.GetCompletedValue() returns u64::MAX, on both adapters. So the next reap_completed (from wait_fence or drain_in_flight_locked) pops every in-flight entry, and in_flight can already be empty when a buffer creation fails.
  • new_list() also fails after RemoveDevice. Its callers in list.rs (lines 296 and 395) only log no host command list and do not call wait_if_removed. Only a failed upload or shared buffer creation prints the new line.

A possible hang (found by reading the code, not reproduced, because it needs a real page fault):

  • shadow::find_copy holds BUFFERS (shadow.rs:2387) when it calls h.shared_buffer (2411). shadow::loose holds LOOSE (2496) when it calls h.shared_buffer (2509).
  • Suppose that call is the first to fail with 0x887A0005, and DRED has a page-fault address. Then wait_if_removed calls removal_data_in_flight, then removal_data, then shadow::near (host.rs:1710). near locks BUFFERS and LOOSE again on the same thread, inside ONCE.call_once.
  • std::sync::Mutex is not reentrant, so that thread hangs. Other threads that reach wait_if_removed block on the Once. A synchronous submission that then sees the removal calls removal_data, and so near, before fail(), and blocks on the same locks. So the run would hang instead of logging the reason.
  • The page-fault case is the main reason to turn DRED on. Possible fixes: use try_lock in shadow::near, or skip the title-memory lookup on this path.

Not tested: a real device hang or page fault, and the game.

**@⁠adrianmjim** on GitHub · 2026-11-26 19:52 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/214#issuecomment-7202046711) Tested on native Windows 11 (26300) with an RX 7900 XT (driver 32.0.32029.2010) and with WARP. Head 9d1f4c4, base 4f62c2a. Tests: - `cargo test -p victory-gpu --lib`, with and without `--features diagnostics`, 8 runs each, alternating with base. The only failures were in watch, pipeline::library, frame and queue, which this PR does not touch, and the same tests also fail on base. Other heavy jobs were running on the machine at the same time. Report path, checked with a local-only test (diagnostics build, `VICTORY_D3D12_DRED=1`) that calls `ID3D12Device5::RemoveDevice` and then `shared_buffer`: - The new field is printed: `host GPU device gone reason=Err(0x887A0005 ...) layer=None dred=; breadcrumbs (done/count, list) []` (reason shortened). Base prints the same line without `dred`. WARP and the 7900 XT give the same result. - The breadcrumb list stays empty under `RemoveDevice`, even with a list held behind an unsignalled `queue.Wait` and left in `in_flight`. So I could not check the list mapping this way. - After `RemoveDevice`, `queue.Signal` still returns S_OK and `fence.GetCompletedValue()` returns `u64::MAX`, on both adapters. So the next `reap_completed` (from `wait_fence` or `drain_in_flight_locked`) pops every in-flight entry, and `in_flight` can already be empty when a buffer creation fails. - `new_list()` also fails after `RemoveDevice`. Its callers in list.rs (lines 296 and 395) only log `no host command list` and do not call `wait_if_removed`. Only a failed upload or shared buffer creation prints the new line. A possible hang (found by reading the code, not reproduced, because it needs a real page fault): - `shadow::find_copy` holds `BUFFERS` (shadow.rs:2387) when it calls `h.shared_buffer` (2411). `shadow::loose` holds `LOOSE` (2496) when it calls `h.shared_buffer` (2509). - Suppose that call is the first to fail with 0x887A0005, and DRED has a page-fault address. Then `wait_if_removed` calls `removal_data_in_flight`, then `removal_data`, then `shadow::near` (host.rs:1710). `near` locks `BUFFERS` and `LOOSE` again on the same thread, inside `ONCE.call_once`. - `std::sync::Mutex` is not reentrant, so that thread hangs. Other threads that reach `wait_if_removed` block on the `Once`. A synchronous submission that then sees the removal calls `removal_data`, and so `near`, before `fail()`, and blocks on the same locks. So the run would hang instead of logging the reason. - The page-fault case is the main reason to turn DRED on. Possible fixes: use `try_lock` in `shadow::near`, or skip the title-memory lookup on this path. Not tested: a real device hang or page fault, and the game.
shadow::find_copy and shadow::loose make buffers under BUFFERS and LOOSE.
If that call is the first to find the device removed, wait_if_removed ->
removal_data -> shadow::near locked them again on the same thread and the
run hung instead of reporting (found by adrianmjim on #214). near now takes
each table only if it is free and says which it left out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-26 23:28 UTC · original

Thanks, @⁠adrianmjim, the hang you found by reading is real. I fixed it in 7d0c446 (pushed to this PR).

  • Fix: shadow::near now takes each table (BUFFERS, LOOSE, SPARSE, its aliases, DIRECT) with try_lock. A table that is held, by this thread or another, is left out, and the line says which: (in use on this thread or another, not looked at: buffers). A poisoned lock is still read.
  • Test: shadow::tests::near_leaves_out_a_table_this_thread_holds holds BUFFERS on the test thread, calls near, and checks the note. Against the previous near the same test hangs (killed after 60 s with has been running for over 60 seconds). With the fix it passes at once.
  • cargo test --release -p victory-gpu --lib (RX 6950 XT): 113 passed, 1 failed, 4 ignored. The failure is list::tests::lists_are_cut_at_waits_that_follow_work, which fails on base in release and is fixed by #210. Clippy reports nothing new in the changed lines.

On your other points: I agree the empty breadcrumbs under RemoveDevice and the in_flight already reaped (fence at u64::MAX) limit what this path can show. Also, the new_list() callers in list.rs only log, so a failed upload or shared buffer is still the main place the line comes from. This PR does not change that.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-26 23:28 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/214#issuecomment-7205576034) Thanks, @⁠adrianmjim, the hang you found by reading is real. I fixed it in `7d0c446` (pushed to this PR). - **Fix:** `shadow::near` now takes each table (`BUFFERS`, `LOOSE`, `SPARSE`, its aliases, `DIRECT`) with `try_lock`. A table that is held, by this thread or another, is left out, and the line says which: `(in use on this thread or another, not looked at: buffers)`. A poisoned lock is still read. - **Test:** `shadow::tests::near_leaves_out_a_table_this_thread_holds` holds `BUFFERS` on the test thread, calls `near`, and checks the note. Against the previous `near` the same test **hangs** (killed after 60 s with `has been running for over 60 seconds`). With the fix it passes at once. - `cargo test --release -p victory-gpu --lib` (RX 6950 XT): 113 passed, 1 failed, 4 ignored. The failure is `list::tests::lists_are_cut_at_waits_that_follow_work`, which fails on base in release and is fixed by #210. Clippy reports nothing new in the changed lines. On your other points: I agree the empty breadcrumbs under `RemoveDevice` and the `in_flight` already reaped (fence at `u64::MAX`) limit what this path can show. Also, the `new_list()` callers in list.rs only log, so a failed upload or shared buffer is still the main place the line comes from. This PR does not change that. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-26 23:31 UTC · original

Thanks @⁠MamaLeVrai. Taking each table with try_lock and saying which one was left out is the right trade for a diagnostic path that may run while the faulting thread holds a lock. A test that hangs on the old code and passes at once on the new one is about as direct as it gets. Nothing else from me on this one.

**@⁠adrianmjim** on GitHub · 2026-11-26 23:31 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/214#issuecomment-7205611417) Thanks @⁠MamaLeVrai. Taking each table with `try_lock` and saying which one was left out is the right trade for a diagnostic path that may run while the faulting thread holds a lock. A test that hangs on the old code and passes at once on the new one is about as direct as it gets. Nothing else from me on this one.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/214/head:github-bot/gh-214'
git switch 'github-bot/gh-214'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-214'
git switch 'github-bot/gh-214'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-214'
git switch 'github-bot/gh-214'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-214'
git switch 'main'
git merge --squash 'github-bot/gh-214'
git switch 'main'
git merge --ff-only 'github-bot/gh-214'
git switch 'main'
git merge 'github-bot/gh-214'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.