Host failures quote the error that broke the list #4573

Open
frametrace wants to merge 3 commits from upstream-pr/4573 into main
frametrace commented 2026-11-30 22:56:51 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by frametrace on 2026-11-30T22:56:51Z.


With VICTORY_D3D12_DEBUG=1 (diagnostics builds), fail() adds a debug-layer message to a host GPU failure, so the report names the bad command. Two things made that quote unreliable.

  1. It quoted the first error queued. A list that won't close is checked at Close, after whatever earlier submissions raised. In one run (RTX 5090, hardware RT), a list failed on CopyTextureRegion BC3_TYPELESS -> BC7_TYPELESS (id 874; see #2914 / #3043), but the failure quoted an earlier root-view state error that ExecuteCommandLists raises (id 538), of which that run logged 52,187.
  2. Other threads drain the same queue as they land submissions (log_messages() in the relay and landing paths). In another run, one of them took the copy errors 0.25 ms after Close failed and before fail() asked, and the failure quoted nothing.

What changes:

  • Errors are noted as the debug layer raises them (ID3D12InfoQueue1::RegisterMessageCallback, on the raising thread), in one record per id (current burst count, last text, time raised). A drain counts the queue and then clears it, so an error raised in between was seen by nobody; the callback closes that window, and stamps errors when raised rather than when drained. Where ID3D12InfoQueue1 is missing, every drain notes its errors instead, whichever thread drained them, and the log says so.
  • A failure quotes the newest error raised while a list was recorded (its text names a command-list call, ID3D12CommandList::… / ID3D12GraphicsCommandList…) within 2 s. Execute-time errors come after a list closed, so they can't be why it didn't.
  • Fallbacks: if there's no such error, it quotes the newest error of any kind, with its age if older than 2 s. It never quotes nothing when an error was seen.
  • Context: it lists the other ids still being raised, with the length of their current burst.
  • Scope: the choice lives in host::failure_quote, with 6 unit tests (a flood of execute-time errors after the copy; a drain by another thread before fail() asks; an old error; bursts; the callback's severity cut; a missing or invalid-UTF-8 message). The callback makes no D3D12 calls and runs under catch_unwind. log_messages() is unchanged. Nothing changes without the debug layer.

Tested on main (v2026.11.30.03, without #3043, so the copy failure still happens), diagnostics build, debug layer on, hardware RT. The run failed 2.6 min into the prologue, and crashes.log reads:

host GPU failure: a host command list did not close (0x80070057): a command recorded into it was invalid; debug layer: ID3D12CommandList::CopyTextureRegion: The source and destination resource formats are incompatible. The source format is BC3_TYPELESS and the destination format is BC7_TYPELESS. … (id 874, 7 like it); other errors still being raised: id 538 (…)

That run was with the previous wording of the last part ("id 538 x42436"). The final wording is covered by the unit tests.

What it guarantees: with the callback, errors are captured at emission; without it, only the errors a drain read. Errors the queue's filters deny are not seen either way. In both cases the quote is the newest record-time error, not a proven link to the failing list: it can belong to another thread's list.

Callback check (after review): RTX 5090, driver 616.92, the same setup. The callback registered, and 3 of 3 runs that failed quoted the copy (BC3 -> BC7 twice, BC3 -> BC6H once), and in the two runs checked, the "like it" count matched the id-874 messages the drains logged. The fallback path has only the unit tests, and nothing ran on Windows 10.

Relation to #3488: #3488 names a failed Close's command without the debug layer, by replaying what was recorded. This PR only fixes which debug-layer message fail() quotes, for any kind of host failure. They don't overlap in code.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5575291498 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4573). Originally posted by [frametrace](https://github.com/frametrace) on 2026-11-30T22:56:51Z. --- With `VICTORY_D3D12_DEBUG=1` (diagnostics builds), `fail()` adds a debug-layer message to a host GPU failure, so the report names the bad command. Two things made that quote unreliable. 1. **It quoted the first error queued.** A list that won't close is checked at `Close`, after whatever earlier submissions raised. In one run (RTX 5090, hardware RT), a list failed on `CopyTextureRegion BC3_TYPELESS -> BC7_TYPELESS` (id 874; see #2914 / #3043), but the failure quoted an earlier root-view state error that `ExecuteCommandLists` raises (id 538), of which that run logged 52,187. 2. **Other threads drain the same queue** as they land submissions (`log_messages()` in the relay and landing paths). In another run, one of them took the copy errors 0.25 ms after `Close` failed and before `fail()` asked, and the failure quoted nothing. **What changes:** - **Errors are noted as the debug layer raises them** (`ID3D12InfoQueue1::RegisterMessageCallback`, on the raising thread), in one record per id (current burst count, last text, time raised). A drain counts the queue and then clears it, so an error raised in between was seen by nobody; the callback closes that window, and stamps errors when raised rather than when drained. Where `ID3D12InfoQueue1` is missing, every drain notes its errors instead, whichever thread drained them, and the log says so. - **A failure quotes the newest error raised while a list was recorded** (its text names a command-list call, `ID3D12CommandList::…` / `ID3D12GraphicsCommandList…`) within 2 s. Execute-time errors come after a list closed, so they can't be why it didn't. - **Fallbacks:** if there's no such error, it quotes the newest error of any kind, with its age if older than 2 s. It never quotes nothing when an error was seen. - **Context:** it lists the other ids still being raised, with the length of their current burst. - **Scope:** the choice lives in `host::failure_quote`, with 6 unit tests (a flood of execute-time errors after the copy; a drain by another thread before `fail()` asks; an old error; bursts; the callback's severity cut; a missing or invalid-UTF-8 message). The callback makes no D3D12 calls and runs under `catch_unwind`. `log_messages()` is unchanged. Nothing changes without the debug layer. **Tested** on main (v2026.11.30.03, without #3043, so the copy failure still happens), diagnostics build, debug layer on, hardware RT. The run failed 2.6 min into the prologue, and `crashes.log` reads: > host GPU failure: a host command list did not close (0x80070057): a command recorded into it was invalid; debug layer: ID3D12CommandList::CopyTextureRegion: The source and destination resource formats are incompatible. The source format is BC3_TYPELESS and the destination format is BC7_TYPELESS. … (id 874, 7 like it); other errors still being raised: id 538 (…) That run was with the previous wording of the last part ("id 538 x42436"). The final wording is covered by the unit tests. **What it guarantees:** with the callback, errors are captured at emission; without it, only the errors a drain read. Errors the queue's filters deny are not seen either way. In both cases the quote is the newest record-time error, not a proven link to the failing list: it can belong to another thread's list. **Callback check** (after review): RTX 5090, driver 616.92, the same setup. The callback registered, and 3 of 3 runs that failed quoted the copy (BC3 -> BC7 twice, BC3 -> BC6H once), and in the two runs checked, the "like it" count matched the id-874 messages the drains logged. The fallback path has only the unit tests, and nothing ran on Windows 10. **Relation to #3488:** #3488 names a failed `Close`'s command without the debug layer, by replaying what was recorded. This PR only fixes which debug-layer message `fail()` quotes, for any kind of host failure. They don't overlap in code. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
tyr0nsur commented 2026-12-01 01:31:13 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tyr0nsur on 2026-12-01T01:31:13Z.


I ran the four failure_quote unit tests from 7851d0c4 on native Windows and all passed. One capture window remains before selection: this drain reads only the count sampled by GetNumStoredMessages and then clears the entire info queue. If a recording error arrives after that count is read but before this clear, SEEN_ERRORS never sees it. Saving messages from every drain helps with an already-consumed message, and still leaves this arrival window. ClearStoredMessages contract

This is from the code path and API contract. The local machine does not expose the D3D12 debug interface, so I did not reproduce the live queue timing. Could the guarantee in the description be scoped to messages read by a drain, or could an InfoQueue callback capture the error at emission?

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7297595933 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4573#issuecomment-7297595933). Originally posted by [tyr0nsur](https://github.com/tyr0nsur) on 2026-12-01T01:31:13Z. --- I ran the four `failure_quote` unit tests from `7851d0c4` on native Windows and all passed. One capture window remains before selection: this drain reads only the count sampled by `GetNumStoredMessages` and then clears the entire info queue. If a recording error arrives after that count is read but before this clear, `SEEN_ERRORS` never sees it. Saving messages from every drain helps with an already-consumed message, and still leaves this arrival window. [ClearStoredMessages contract](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12infoqueue-clearstoredmessages) This is from the code path and API contract. The local machine does not expose the D3D12 debug interface, so I did not reproduce the live queue timing. Could the guarantee in the description be scoped to messages read by a drain, or could an InfoQueue callback capture the error at emission?
frametrace commented 2026-12-01 04:30:40 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by frametrace on 2026-12-01T04:30:40Z.


Thanks for running the tests and for spotting the gap. You're right: drain_messages reads GetNumStoredMessages, then ClearStoredMessages drops anything raised in between, so a record-time error from another thread could be lost.

I took the callback route (3421dbc8, a5f198dc):

  • The callback: with VICTORY_D3D12_DEBUG, the host registers ID3D12InfoQueue1::RegisterMessageCallback. It notes each error into SEEN_ERRORS on the raising thread as it's emitted, and the drains then only log.
  • Fallback: where ID3D12InfoQueue1 isn't available, the drains note errors as before, and the log says so.
  • Timestamps: errors are now stamped when they're raised, not when a drain happened to read them. So "newest record-time error" means what the description says. That's also why the drains stop noting once the callback is on.
  • Safety: the callback only takes the mutex and notes, with no D3D12 calls. Its body runs under catch_unwind, so a panic can't unwind into the layer. It's a plain function with unit tests (severity cut, missing text, invalid UTF-8).

Live check: RTX 5090, driver 616.92, Windows 11, diagnostics build, VICTORY_D3D12_DEBUG=1, hardware RT, on .03 (which still hits the BC3→BC7 copy without #3043).

  • Registration: the callback registered, and the log says "errors are noted as raised".
  • Run 1 failed with "did not close". It quoted ID3D12CommandList::CopyTextureRegion ... BC3_TYPELESS ... BC7_TYPELESS (id 874, 7 like it). The drains logged exactly 7 id-874 messages before the failure, so the callback saw what the drains saw.
  • Run 2 failed the same way, with the same quote in crashes.log. Its play log lost the final line to an unrelated log-flush issue.
  • Rerun after a5f198dc: the callback registered, and the run failed the same way. The quote was CopyTextureRegion ... BC3_TYPELESS ... BC6H_TYPELESS (id 874, 8 like it); other errors still being raised: id 538 (122548 without a 2 s pause), and the play log has exactly 8 id-874 messages. BC6H this time, the same copy family as #2914.

Limits:

  • Filters still apply. With the callback, no error is lost between a drain's count and its clear. Errors the queue's filters deny are still not seen.
  • The quote isn't proven attribution. It's the newest record-time error within 2 s, which could belong to another thread's list. Since the callback runs on the raising thread, tagging errors by thread is a possible follow-up.
  • Not tested: the fallback path has only the unit tests since this change, and nothing ran on Windows 10 or anywhere ID3D12InfoQueue1 is missing.

I've updated the description to match: with the callback, errors are captured at emission; without it, only errors a drain read; in both cases the quote is the newest record-time error, not a proven link to the failing list.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7300807115 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4573#issuecomment-7300807115). Originally posted by [frametrace](https://github.com/frametrace) on 2026-12-01T04:30:40Z. --- Thanks for running the tests and for spotting the gap. You're right: `drain_messages` reads `GetNumStoredMessages`, then `ClearStoredMessages` drops anything raised in between, so a record-time error from another thread could be lost. **I took the callback route** (3421dbc8, a5f198dc): - **The callback:** with `VICTORY_D3D12_DEBUG`, the host registers `ID3D12InfoQueue1::RegisterMessageCallback`. It notes each error into `SEEN_ERRORS` on the raising thread as it's emitted, and the drains then only log. - **Fallback:** where `ID3D12InfoQueue1` isn't available, the drains note errors as before, and the log says so. - **Timestamps:** errors are now stamped when they're raised, not when a drain happened to read them. So "newest record-time error" means what the description says. That's also why the drains stop noting once the callback is on. - **Safety:** the callback only takes the mutex and notes, with no D3D12 calls. Its body runs under `catch_unwind`, so a panic can't unwind into the layer. It's a plain function with unit tests (severity cut, missing text, invalid UTF-8). **Live check:** RTX 5090, driver 616.92, Windows 11, diagnostics build, `VICTORY_D3D12_DEBUG=1`, hardware RT, on .03 (which still hits the BC3→BC7 copy without #3043). - **Registration:** the callback registered, and the log says "errors are noted as raised". - **Run 1** failed with "did not close". It quoted `ID3D12CommandList::CopyTextureRegion ... BC3_TYPELESS ... BC7_TYPELESS (id 874, 7 like it)`. The drains logged exactly 7 id-874 messages before the failure, so the callback saw what the drains saw. - **Run 2** failed the same way, with the same quote in `crashes.log`. Its play log lost the final line to an unrelated log-flush issue. - **Rerun after a5f198dc:** the callback registered, and the run failed the same way. The quote was `CopyTextureRegion ... BC3_TYPELESS ... BC6H_TYPELESS (id 874, 8 like it); other errors still being raised: id 538 (122548 without a 2 s pause)`, and the play log has exactly 8 id-874 messages. BC6H this time, the same copy family as #2914. **Limits:** - **Filters still apply.** With the callback, no error is lost between a drain's count and its clear. Errors the queue's filters deny are still not seen. - **The quote isn't proven attribution.** It's the newest record-time error within 2 s, which could belong to another thread's list. Since the callback runs on the raising thread, tagging errors by thread is a possible follow-up. - **Not tested:** the fallback path has only the unit tests since this change, and nothing ran on Windows 10 or anywhere `ID3D12InfoQueue1` is missing. I've updated the description to match: with the callback, errors are captured at emission; without it, only errors a drain read; in both cases the quote is the newest record-time error, not a proven link to the failing list.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/4573:upstream-pr/4573'
git switch 'upstream-pr/4573'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/4573'
git switch 'upstream-pr/4573'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/4573'
git switch 'upstream-pr/4573'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/4573'
git switch 'main'
git merge --squash 'upstream-pr/4573'
git switch 'main'
git merge --ff-only 'upstream-pr/4573'
git switch 'main'
git merge 'upstream-pr/4573'
git push origin 'main'
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
trustno1-coder/VIctory-NVIDIA!4573
No description provided.