D3D12.X: a device hang names Windows' GPU timeout when it was one #2748
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2748
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2748"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Raul-Paiva on GitHub · 2026-11-26 09:58 UTC · original
Raul-Paiva:d3d12x-tdr-diagnostic→main· +320 −4 · 5 files · 1 commits · openA
0x887a0006(DEVICE_HUNG) or0x887a0007(DEVICE_RESET) removal can be Windows' GPU timeout (TDR): WDDM resets the GPU when it does not preempt withinTdrDelayseconds of the scheduler asking (2 s by default, at the defaultTdrLevel). The removal code alone does not tell that apart from a hang the driver detected itself. The log now says whether Windows logged one. At start it names the timeout in effect. After such a removal it looks in the System log for theDisplayevent 4101 Windows writes when it was its timeout. Logging only. Part of #505.On an 8 GB laptop card, every
0x887a0006at a retail title's world start had a 4101 event at the same time (14 of 14 runs). RaisingTdrDelaytook them away (#505 comment). Without the event, testers on slower cards report these as GPU hangs.What is in it
crates/xcl/src/gpu/tdr.rs(new):settings()readsTdrDelay/TdrLevelfromHKLM\System\CurrentControlSet\Control\GraphicsDrivers. Read only, no elevation.describe()turns them into the log line:TdrDelayas the GPU's preemption timeout, and whatTdrLeveldoes then (0 off, 1 a bug check with no recovery, 3 or unset a reset; 2 is not implemented by Windows). The line says the values are the registry's, which Windows reads at boot, so a change not yet applied is not taken for the one in effect.recent_resets()countsDisplay4101 events of the last 30 s withEvtQuery. A read that fails with anything butERROR_NO_MORE_ITEMSgives "unknown", not a count.removal_note()does this forDEVICE_HUNG/DEVICE_RESETonly, waiting up to 3 s for the event because Windows can write it just after the title sees the removal. A recent event is reported as consistent with the timeout, not as proof: the event names no device.crates/xcl/src/hle/d3d12x/mod.rs: the timeout line afterbackend 'real'.crates/xcl/src/hle/d3d12x/real.rs:log_device_removedadds the note afterD3D12 device removed. A second caller now waits for the first one's report, for at most 5 s (ReportOnce). Without that,stop_if_device_removedon another thread ended the process before the note was written; in one run that was 70 ms after the removal. The wait is bounded and not a lock: the reporting thread can come back itself through the unhandled-exception filter.crates/xcl/Cargo.toml: theWin32_System_EventLogfeature ofwindows-sys, forEvtQuery. No new dependency.Tested
RTX 3070 Laptop 8 GB, driver 621.24, i7-11800H, 32 GB RAM, Windows 10 19045, Rust 1.100.0, debug for the suite.
cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4onc20818a: 1445 passed, 1 failed, 47 ignored; 25SKIPPEDlines: "no wave64" on this adapter, per-lane forms the driver refuses, and one "no heap windows". The failure ishle::d3d12x::list_x::tests::a_reset_while_the_last_submit_runs_records_on_another_pc_list, which fails intermittently onmaintoo; alone it passed 3 of 3 runs. This change does not touchlist_x.rs. On4c8f841, one test change before, the same suite had 1446 passed, 0 failed.The 9 tests in
gpu::tdr::testspass, among them a reader that fails on its first call (ERROR_TIMEOUT), one that fails after a partial batch, an injected recent event, and a malformed query, which Windows refuses withERROR_EVT_INVALID_QUERY. The two tests that read the real System log printSKIPPEDwhere a valid query cannot read it (Wine'swevtapigives error 0), and otherwise fail only on a query Windows refuses. The 2 tests inreal::report_once_testspass: a second caller waits for the report, and the reporting thread coming back (through the unhandled-exception filter) does not hang. The query ofrecent_resets, run over the last 24 h withGet-WinEvent -FilterXPath, found the 24 events 4101 of this machine that day.In the PR's smoke run the log has, after the adapter line:
(
TdrDelayis 10 on this machine for an earlier test; it is 2 s when not set.)Real removals, each in a 600 s run of a retail title. The tree was this PR on a test tree:
main+ #2404 and others, with a 1 GiB shader heap profile.4c8f841(itstdr.rsandReportOncecopied in as they are; the headc20818achanges only a test since). The thread number is in brackets:nvlddmkm153 events in the 15 s before.stop_if_device_removedon another thread ended the process 6 ms after the note.0x887a0007at 233.3 s. The noteno Display 4101 event in the System log in the last 30 s: …came at 236.6 s, and the process ended after it. The System log has no 4101 in that window.Test reports from others (on earlier heads:
c9e51e5is before both review fixes and the report lock,e1ac7f0before theTdrLevelwording,4c8f841before the Wine skip)e1ac7f0(emirduran707): the 8gpu::tdrtests pass. The suite had 1441 passed and 2 failed, bothdxil::fuzz_teststhat fail onmainthere too. Smoke: 1601 frames, 0 removals (main: 1603).4c8f841(pickles976): 8 of 9gpu::tdrtests and bothreport_oncetests pass. Wine'swevtapireads no System log (error 0), anda_query_windows_refuses_is_told_apartfailed on that. It now skips there like the other System-log test (c20818a). Under Wine the note after a removal should readthe System log could not be read …(not run there).c9e51e5(sage-sage): 1440 passed, 0 failed, and thegpu::tdrtests of that head pass, including the System log read.Regression run
main:
this PR:
Both with the same settings, one after the other (main first, right after its build);
xcl.exehas a 1 GiB shader heap profile (#2590) on this machine for both.Not tested
TdrDdiDelay, the time a thread may stay inside the driver (5 s by default), is another way to a TDR. The start line does not name it; the removals measured here were the GPU not preempting.AI use
🤖 Generated with Claude Code
@luckyteagirl on GitHub · 2026-11-26 10:02 UTC · original · reviewed
On
c9e51e5,recent_resetstreats everyEvtNext == FALSEas the normal end of the System-log query and returnsSome(n). Microsoft'sEvtNextcontract says onlyGetLastError() == ERROR_NO_MORE_ITEMSmeans enumeration finished; a one-second timeout setsERROR_TIMEOUT, and other read errors can occur. If the firstEvtNextfails that way, this code returnsSome(0), andremoval_noteeventually reports no Display 4101 event / probably not a Windows timeout even though the evidence could not be read. A failure after a partial batch can likewise present an incomplete count as a complete query.Could the read return an unknown/error outcome for any false result other than
ERROR_NO_MORE_ITEMS, preserving the distinction from a genuinely empty query? Please close the query handle on both paths and cover a first-call timeout plus finite empty enumeration with an injected/mock event reader. This is exact-head source review based on the Win32 API contract; I did not force an Event Log timeout at runtime.@luckyteagirl on GitHub · 2026-11-26 10:02 UTC · original · reviewed
On
c9e51e5,removal_notereports “it was Windows' GPU timeout” whenever it finds any system-wide Display 4101 in the prior 30 seconds. The query does not identify this device or bind the event to this removal. On a multi-adapter machine, another display adapter can reset in that interval; even on one adapter, an earlier recovered timeout can coexist with a later unrelated removal. The evidence is useful, but it does not establish that this specific device removal was caused by that event.Could the log call this a recent Display 4101 event consistent with a Windows timeout, unless the event can be correlated to this device and removal time more tightly? A test can inject a recent event and assert the note stays probabilistic. This is exact-head source review; I did not reproduce a multi-adapter reset.
@Raul-Paiva on GitHub · 2026-11-26 10:24 UTC · original
Thanks @luckyteagirl, both points were right. Fixed in
abdb439(squashed into the one commit):EvtNextfailures. The loop now goes throughcount_events, which ends with a count only onERROR_NO_MORE_ITEMS. Any otherGetLastError, on the first read or after a partial batch, givesNone, and the note then says the System log could not be read, not "no event". The query handle is closed on both paths (EvtClose(h)aftercount_events, whatever it returns).only_the_end_of_the_query_gives_a_countdrives it with an injected reader: an empty end, two batches then the end, a first-callERROR_TIMEOUT, and a timeout after a batch.N Display 4101 event(s) in the System log in the last 30 s, consistent with Windows' GPU timeout (the event does not name the device).a_recent_event_is_evidence_not_proofinjects a recent event and checks that wording.an_event_written_after_the_removal_is_still_foundcovers the 3 s wait.The description has the new test counts and a smoke run on
abdb439. The one suite failure in that run isvram::tests::d32s8_targets_take_their_own_size_of_video_memory(E_FAILunder parallel load; it passes alone and this change does not touchvram.rs).AI use: Claude Code (Claude Opus 5.5) made the changes and wrote this reply.
@sage-sage on GitHub · 2026-11-26 10:30 UTC · original
Test report: passes on NVIDIA. Exact head
c9e51e5c(its base is currentmainb49be18, so head = merged).Tested
cargo test --workspace -- --test-threads=4: 1440 passed, 0 failed, 47 ignored; the fourgpu::tdr::testspass, includingthe_system_log_and_the_settings_can_be_readon this Windows buildmainon this machine (wave64, debug layer, Developer Mode, heap windows)Not tested
removal_note()on a hung device; AMD, Intel.Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
@Raul-Paiva on GitHub · 2026-11-26 10:44 UTC · original
One more fix, squashed in
e1ac7f0. It comes from a real removal, not the review.On another run with this PR, the device was removed and the note never reached the log. Two threads saw the removal at the same time:
D3D12 device removedand waited for the 4101 event;stop_if_device_removedon a second thread found the report already started (DONEwas set) and ended the process 70 ms later.log_device_removednow holds a lock for the whole report, so a second caller waits for it and then returns.With the lock, on the next real removal (
0x887a0007at 233.3 s, no 4101 event in the System log), the note came at 236.6 s and the process ended after it.On
e1ac7f0:The description is updated.
@sage-sage, thanks for the test on
c9e51e5. The change since is intdr.rs, plus the lock inreal.rs.AI use: Claude Code (Claude Opus 5.5) found the race in the run log, made the fix and wrote this.
@luckyteagirl on GitHub · 2026-11-26 10:49 UTC · original · reviewed
On current head
e1ac7f0213876e499786a4307deea67ca16b5c52,describe(Settings { level: Some(1), delay: Some(10) })says Windows resets the GPU after a submission runs over 10 seconds. Microsoft's TDR registry documentation definesTdrLevel=1as a system bug check on detected timeout, with no recovery;TdrDelayis the scheduler's preemption-wait threshold. This note would therefore give the wrong outcome for a configured level 1, and it also treats the unimplemented level 2 as recovery. Coulddescribedistinguish these levels and phrase the delay as a preemption timeout? A table-driven test for levels 0, 1, and 3 would capture the important distinction. This is a source and API-contract check; I did not trigger a TDR.AI use: OpenAI Codex (GPT-6.2 Sol) found and checked the configuration path; OpenAI Codex (GPT-6.2 Astra) verified the source and Microsoft documentation and wrote this review.
@emirduran707 on GitHub · 2026-11-26 10:58 UTC · original
Independent AMD RDNA4 (native wave64) verification of exact PR head
e1ac7f0213876e499786a4307deea67ca16b5c52on Windows 11 Pro 26300 (AMD Radeon RX 9060 XT 16 GB, driver32.0.31044.16, Ryzen 5 5600, Rust 1.100.0 MSVC, DXC1.9.2602.17).Tested
cargo build --workspace(debug): passed (0errors).cargo test --workspace --no-fail-fast -- --test-threads=4:1441 passed, 2 failed, 47 ignored(8 SKIPPED: 6 per-lane DXIL forms refused by host adapter/driver, 1heap_window_out_of_memory_falls_back_to_the_switch_formno heap windows, 1pso_measurement_compiles_an_exact_synthetic_recordWindows Developer Mode off).gpu::tdr::tests::*tests passed on this Windows 11 machine (a_recent_event_is_evidence_not_proof,an_event_written_after_the_removal_is_still_found,only_hung_and_reset_devices_are_timeouts,only_the_end_of_the_query_gives_a_count,other_removals_get_no_note,the_query_asks_for_display_4101_in_a_window,the_settings_are_described_as_windows_applies_them,the_system_log_and_the_settings_can_be_read).gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1andfuzz_validate_and_gpu_3) are pre-existing on unmodifiedmainon this RX 9060 XT / driver32.0.31044.16.cargo build --release -p xcl+ 60 s retail-title smoke test (scripts/smoke.ps1, offline):(Compare against
mainb49be183on this machine:1603 frames, 18576 MB peak, 0 device removals, 0 crashes.)Not tested
AI use
@Raul-Paiva on GitHub · 2026-11-26 10:58 UTC · original
Thanks @luckyteagirl, right again. Fixed in
1949ac1(squashed;e0ddf63has the same tree with the old commit message).describenow follows the TDR registry keys.TdrDelayis phrased as the preemption timeout, and the level decides what follows:TdrLevel0: detection off.TdrLevel1:Windows bug-checks, with no recovery, when the GPU does not preempt within N s ….TdrLevel3 or unset:Windows resets the GPU when it does not preempt within N s ….the_settings_are_described_as_windows_applies_themis now a table over unset, 0, 1, 2 and 3. The module comment and the commit message had the same "submission runs over N s" wording; both are fixed.On
e0ddf63, the suite had 1442 passed and 1 failed. The failure waslist_x::tests::a_reset_while_the_last_submit_runs_records_on_another_pc_list, an intermittent one that also fails onmain; it passed 3 of 3 runs alone. The smoke run on1949ac1is in the description.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this reply.
@Aniseto on GitHub · 2026-11-26 11:09 UTC · original
Ran the TDR diagnostics tests at
1949ac11:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
All eight tests pass here, including the one that reads this machine's real System log and registry
TdrDelay/TdrLevelsettings.What this adds: the existing NVIDIA report is on an RTX 4080 SUPER (and an AMD one on RX 9060 XT), both on earlier heads. This is a Blackwell wave32 host at the current head, with a different driver and settings. I did not produce a real device removal here, so I am not adding evidence about the 4101 event in a live run.
Not tested: a real
0x887a0006/0x887a0007removal on this host, the full workspace suite, a paired 60 s smoke run, AMD and Intel GPUs, Wine, release profile, title data.AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
1949ac11a6to4c8f841178@pickles976 on GitHub · 2026-11-26 11:27 UTC · original
Wine/NVIDIA verification of exact head
4c8f8411783ff092df10aaaec45f6a21573f9f89(Linux 6.17, Wine 11.0, RTX 4060 Laptop 8 GB, NVIDIA 590.48.1, DXVK 3.1.1, Rust 1.98.1 x86_64-pc-windows-msvc). Caveat: locally built diagnostic-relaxed vkd3d-proton 3.2.02576c0b4adfae4a+— not stock-runtime certification. Unchanged owner code; fresh 28.37 s compile; one test thread; 9 GiB/512 MiB cgroup scope. Logverify-pr2748-tdr.logkept locally.gpu::tdr::tests8/9. Passing:only_hung_and_reset_devices_are_timeouts,the_settings_are_described_as_windows_applies_them,the_query_asks_for_display_4101_in_a_window,only_the_end_of_the_query_gives_a_count,a_recent_event_is_evidence_not_proof,an_event_written_after_the_removal_is_still_found,other_removals_get_no_note, andthe_system_log_and_the_settings_can_be_read— the last via its designed skip path: under Wine the System log is not readable (error 0), which is exactly the case the test's guard is written for.One failure, and it is a Wine
wevtapifidelity gap, not a logic defect:a_query_windows_refuses_is_told_apartpanics witha malformed query gave Err(0)—EvtExecuteQuery("*[System[EventID=")returnsErr(0)under Wine rather thanERROR_EVT_INVALID_QUERY. On Windows this test would classify the refusal; Wine's wevtapi does not distinguish a malformed query from other failures here. I did not modify the test. This means the TDR-verification value of the PR on Wine stacks is limited to the non-query logic (settings description, hang-code classification, removal-note construction), while the actual System-log query needs Windows to prove out.real::report_once_tests2/2:a_second_caller_waits_for_the_first_reportandthe_reporting_thread_coming_back_does_not_hangboth pass (0.21 s each), including the reporting-thread reuse path.No device removal was triggered here and no title was run; this is the module's unit surface only.
AI use: omp, harness model
openai-codex/gpt-6-astra, ran the checks and drafted this report. No upstream code changes or assets attached.4c8f841178toc20818ac7c@Raul-Paiva on GitHub · 2026-11-26 11:43 UTC · original
@pickles976, thanks for the Wine run. You were right about the cause, and the test was the problem:
a_query_windows_refuses_is_told_apartonly skipped onERROR_ACCESS_DENIED. It now first runs a valid query, and if that cannot read the System log (yourerror 0), it printsSKIPPEDlikethe_system_log_and_the_settings_can_be_read. It assertsERROR_EVT_INVALID_QUERYonly where the log can be read.That is in
c20818a, the new head; only that test changed since4c8f841. When you have time, could you rungpu::tdr::teststhere again under Wine? I expect 9 passed, with 2SKIPPEDlines. If you also runreal::report_once_testsand the rest of the suite, that would help too.AI use: Claude Code (Claude Opus 5.5) made the change and wrote this.
@Aniseto on GitHub · 2026-11-26 12:00 UTC · original
Re-ran the TDR diagnostics tests at
c20818acafter the head moved again (124 lines changed acrossgpu/tdr.rsandhle/d3d12x/real.rs, with a new test for a refused event query).Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
All nine pass here, including the new
a_query_windows_refuses_is_told_apartand the test that reads this machine's real System log and TDR registry settings. This is a new report following mine at1949ac11, not an edit.Not tested: a real
0x887a0006/0x887a0007removal on this host, the full workspace suite, a paired 60 s smoke run, AMD and Intel GPUs, Wine, release profile, title data.AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
@Decodere on GitHub · 2026-11-26 12:10 UTC · original
Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2748 at
c20818ac7c6f653561959767ea20b918cf5594b3(exact parentorigin/mainb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7). Measurements and targeted test results only; not a full source review.Setup
7956 MiBreported by D3D12), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200rustc 1.100.0 (0ef1bc386 2026-11-09), DXC1.9.2609.5, release builds, warm DXIL/pipeline caches, quiet machine (zero concurrent builds/tests during timed runs)title: 29640639viascripts/smoke.ps1 -Seconds 60(XCL_NETWORK=0 XCL_ACTIVITY=1, default flags, no input)Targeted Win11 / RTX 4060 release unit tests (
c20818ac)cargo test --release -p xcl --lib gpu::tdr:: -- --test-threads=4 --nocapture: 9 passed, 0 failed, 0 ignored (0.50 s,0skipped, exit0), including live Windows 1126200System Event Log + TDR registry checks (the_system_log_and_the_settings_can_be_read,a_query_windows_refuses_is_told_apart,a_recent_event_is_evidence_not_proof,an_event_written_after_the_removal_is_still_found,the_settings_are_described_as_windows_applies_them,the_query_asks_for_display_4101_in_a_window,only_hung_and_reset_devices_are_timeouts,only_the_end_of_the_query_gives_a_count, andother_removals_get_no_note).cargo test --release -p xcl --lib hle::d3d12x::real:: -- --test-threads=4: 62 passed, 0 failed, 0 ignored (0.74 s,0skipped, exit0).Observations
gpu::tdr::tests(including live native Windows 11 System Event Log query and TDR registry inspection, with0skips) and all 62hle::d3d12x::real::tests passed cleanly in--releaseon exact headc20818ac.exit: 0x0,1558frames shown,60 60 60steady-state presents per 2 s,0device removals,0crashes,14008 MBpeak commit vs parentb49be183's14018 MB/1518frames).Paired 60 s RTX 4060 smoke (
b49be183vsc20818ac)Parent
origin/main(b49be183):PR #2748 head (
c20818ac):Limits of coverage
c20818ac(only targetedgpu::tdr::andhle::d3d12x::real::release tests plus paired quiet 60 s smoke).0device removals, so a real live GPU TDR hang / Display 4101 event emission on removal was not provoked on this host (live Event Log / TDR registry queries and Display 4101 correlation logic are covered bygpu::tdr::tests).26200) / RTX 4060 only; no Wine/Linux run on this host.AI use
Ran the targeted release unit tests and paired quiet 60 s smoke runs with assistance from Google Antigravity (Gemini 4 Neon); all test counts and smoke blocks were taken directly from
cargo testandscripts/smoke.ps1outputs.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.