Host failures quote the error that broke the list #4574

Open
github-bot wants to merge 3 commits from github-bot/gh-4573 into main AGit
Owner

@⁠frametrace on GitHub · 2026-11-30 22:56 UTC · original
frametrace:fix/failure-quotes-last-error → main · +281 −9 · 2 files · 3 commits · open

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

**@⁠frametrace** on GitHub · 2026-11-30 22:56 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4573) `frametrace:fix/failure-quotes-last-error` → `main` · +281 −9 · 2 files · 3 commits · open 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)
With VICTORY_D3D12_DEBUG=1, fail() added the first error the debug layer had queued. A list that will not close is checked at Close, after whatever earlier submissions said, so the quote could be unrelated: in one run a list failed on CopyTextureRegion BC3_TYPELESS -> BC7_TYPELESS (id 874), and the failure quoted an earlier root-view state error that ExecuteCommandLists raises (id 538, 52,187 of them in that run). Other threads also drain the queue as they land submissions; in another run one took the copy errors 0.25 ms before fail() asked, and it quoted nothing.

Every drain now notes its errors, one record per id (count in the current burst, last text, last time), whichever thread drained them. A failure quotes the newest error raised while a list was recorded (its text names a command list's call) within 2 s; otherwise the newest error of any kind, with its age when older. It lists the other ids still being raised, with the length of their current burst. The choice lives in host::failure_quote, with unit tests for a flood of execute-time errors after the copy, a drain before fail() asks, and an old error. log_messages() is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 22:57:39 +00:00
Author
Owner

@⁠tyr0nsur on GitHub · 2026-12-01 01:31 UTC · original

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?

**@⁠tyr0nsur** on GitHub · 2026-12-01 01:31 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4573#issuecomment-7297595933) 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?
A drain reads GetNumStoredMessages and then ClearStoredMessages empties
the whole queue, so an error raised between the two by a thread
recording a list was seen by nobody (review of #4573). With
ID3D12InfoQueue1, a message callback notes each error on the raising
thread at emission; the drains then only log. Without it, the drains
note errors as before, and the log says so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The callback runs inside D3D12 calls from the layer's C++ code: its body
now runs under catch_unwind, and is a plain function
(failure_quote::note_raised) with unit tests for the severity cut, a
missing description and invalid UTF-8. SEEN_ERRORS documents that no
D3D12 or info-queue call may be made while it is held, and why the
drains stop noting once the callback is on (they stamp drain time,
not emission time).

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

@⁠frametrace on GitHub · 2026-12-01 04:30 UTC · original

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.

**@⁠frametrace** on GitHub · 2026-12-01 04:30 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4573#issuecomment-7300807115) 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.
github-bot force-pushed github-bot/gh-4573 from a5f198dcdf to d64753fe5d 2026-12-01 05:05:21 +00:00 Compare
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/4574/head:github-bot/gh-4573'
git switch 'github-bot/gh-4573'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4573'
git switch 'github-bot/gh-4573'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4573'
git switch 'github-bot/gh-4573'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4573'
git switch 'main'
git merge --squash 'github-bot/gh-4573'
git switch 'main'
git merge --ff-only 'github-bot/gh-4573'
git switch 'main'
git merge 'github-bot/gh-4573'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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/trustno1-coder--VIctory-NVIDIA!4574
No description provided.