Repository navigation
Conversation
`token_on_timeout_and_token_in_origin_refresh` drains the origin events and expects a 0 ms wait with an ancillary block to time out. Checking the block (`gpu::shader::readable`) makes unified memory on its first use, which on a CI runner takes longer than a 60 Hz frame: when this test ran first in the binary, a frame ticked inside the wait and it returned S_OK (frame_clock.rs line 132, CI jobs 143831052750, 143800498706, 143770726179, 143765485544, 143752311706, 143681858715, 143672906542; each with the "UMA: ..." line just before the panic). `ClockGuard::acquire` now makes it first. With 64 busy processes on 32 cores the test alone failed 19 of 30 runs without this and 0 of 30 with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
merge-check
|
pvfreis
left a comment
There was a problem hiding this comment.
Read the eh.rs change at 3fb28e4. Two points, both from reading the code (nothing here was run):
-
When
GetModuleHandleExWfails, only addresses in title images keep unwinding, so the walk now also ends at XCL's generated thunks. They live in the stubs arena (privateVirtualAllocmemory,stubs.rs:83), whichimage_base_for_addrdoes not know, and their unwind data is registered so thateh::unwindwalks through them (stubs.rs:101). TheXCL_TRACE_IMPORTStracer (make_call_tracer,hle/d3d12x/guard.rs:172) calls the import from its own frame, so with it on, a dump of a thread waiting inside a traced import stops at the tracer and no longer shows the title's callers. -
This commit fixes the crash reported in #3586, where the same cause and a patch were posted before this PR was opened (#3586 (comment)). The description does not link it, so
Fixes #3586would close it on merge.
Review written with Claude Code (Claude Opus 5.5 read the diff, Claude Fable 5.2 checked both points); I checked each point.
3fb28e4 to
ec9fba9
Compare
|
Thanks for checking, @pvfreis:
|
|
Both points are resolved at Checked with Claude Code (Claude Opus 5.5 read the code, Claude Fable 5.2 rechecked); I checked each point. |
ec9fba9 to
164ff62
Compare
vasanex
left a comment
There was a problem hiding this comment.
Review of 164ff626 (the change since ec9fba99: the dump lock in eh.rs; code reading and the scratch test below, not a merge-check) · 1 finding
In short: serialising thread dumps fixes two dumps suspending each other, and two_threads_dump_at_once covers that. It also makes the process-end hook wait: hk_nt_terminate_process calls dump_threads for a non-zero status, and with the lock a process that ends while another thread is dumping no longer ends. Details inline. My merge check further up was for ec9fba99 and does not cover this head.
Measured (RTX 3080, Ryzen 9 7950X, debug, scratch test in eh.rs' test module, not pushed: a child process installs the crash handler, runs four busy threads and one thread that calls dump_threads in a loop, and calls std::process::exit(3) after 300 ms; the parent waits for it)
164ff626: 20 of 20 children still running after 20 s (killed by the parent). With a 25 ms sleep between the dumps: 12 of 12 still running after 10 s.ec9fba99: 0 of 20; every child ended with status 3.
Not checked: the whole suite and a title run on this head; the other commits of the PR, which are unchanged since ec9fba99.
Review by Claude Code (Claude Fable 5.2), posted without a human check of each point. An automated PR review workflow is running at the request of the user.
| return; | ||
| } | ||
| // (declared in this order, the owner is cleared before the lock is let go) | ||
| let _serial = DUMP_LOCK.lock().unwrap_or_else(|e| e.into_inner()); |
There was a problem hiding this comment.
Finding (medium, measured): a process that ends with a non-zero status while another thread is dumping does not end.
hk_nt_terminate_process runs on the thread that ends the process and, for a status other than 0, calls dump_threads, which now waits here for DUMP_LOCK. The scratch test in the review body shows the result: 20 of 20 child processes hang on this head, 0 of 20 on ec9fba99.
From reading, not confirmed with a debugger: the ending thread is inside ExitProcess and holds the loader lock when the hook runs; the thread that owns DUMP_LOCK needs the loader lock for the per-frame GetModuleHandleExW pin this PR added, so each waits for the other. (The run with a 25 ms pause between dumps rules out plain starvation of the waiting thread.) DUMP_OWNER only covers the same thread ending inside its own dump.
Where it matters: a dump is in flight (XCL_THREAD_DUMP_AT, or the dump another exit path started) at the moment the title aborts or exits with an error. Before this commit that process ended; now it stays until it is killed, and smoke.ps1 or a test harness waits on it.
Suggested: the process-end hook should not wait for the lock. try_lock there and skip the other threads' stacks when a dump is in flight (the log line with the status and the ending thread's own stack is already written before it), or give dump_threads a non-blocking variant for that one caller. A test like the scratch one (exit while a second thread dumps, in a child process with a time limit) would pin it.
There was a problem hiding this comment.
Thanks @vasanex, good catch, and the repro made it quick to confirm. Fixed in 86462821 (the eh.rs commit, now 94367b45):
- The process-end hook calls
dump_threads_inner(false): it takesDUMP_LOCKonly withtry_lock(a poisoned lock is taken over). When another thread is dumping, it logs that and leaves the other threads out; the ending thread's own line and stack are already written by then.dump_threads()(XCL_THREAD_DUMP_AT, tests) still waits for the lock. Those are the only two callers in the repo. - New regression test
eh::tests::the_process_ends_while_another_thread_dumps, built from your scratch test: a child process installs the crash handler, runs four busy threads and one thread that callsdump_threadsin a loop, then callsstd::process::exit(3)once two dumps are done. The parent fails the test if the child is not gone with status 3 within 30 s. On an RTX 5070 Ti (debug): 20 of 20 runs hung with the hook waiting for the lock (as on164ff626), 0 of 20 with this commit. - At this head:
scripts/test.ps13010 passed, 0 failed, 52 ignored (the run before it failed only the fourtitle_texturestests together, which also happens onmainhere), and the 60 s smoke is in the description.
Reply written with Claude Code (Claude Opus 5.5) from those runs.
There was a problem hiding this comment.
Fixed in 86462821: the process-end hook no longer waits for the dump lock. Measured here (RTX 3080, Ryzen 9 7950X, debug, this head): eh::tests::the_process_ends_while_another_thread_dumps passed 20 of 20 runs, and cargo test -p xcl --lib -- eh::tests: 18 passed, 0 failed. The whole suite and a title run on this head were not rerun here. (I cannot mark the thread resolved from this account.)
Follow-up by Claude Code (Claude Fable 5.2), posted without a human check; an automated PR review workflow is running at the request of the user.
`dump_threads` resumes each thread before unwinding the copy of its stack; the unwinding still reads the function's unwind data and code in its DLL, which can be unloaded meanwhile. CI's lib test binary ended with 0xc0000005 inside `thread_dumps_while_threads_run_and_exit` (after 3 to 36 of its 40 dumps; 14 of the last 60 failed runs) while a D3D12 device test released its device, a thread in D3DSCache.dll in the last dumps written. Each frame's DLL is now held with GetModuleHandleExW(FROM_ADDRESS) while it is unwound and let go after. The loader refuses that for a DLL it is already unloading, whose unwind data RtlLookupFunctionEntry still finds until it is unmapped (caught under cdb: the AV was in RtlLookupFunctionEntry, reading the .pdata of nvgpucomp64.dll as the driver unloaded it): the stack ends at such a frame. Addresses in the title's images and in XCL's generated thunks (`stubs::alloc_code`, whose chunks are never freed and are now listed for `stubs::in_code_arena`) are not the loader's and are unwound unpinned as before; `unwinding_goes_through_a_generated_thunk` checks that a dump goes on through a thunk to its caller (without the arena check it ended at the thunk). `thread_dumps_while_devices_come_and_go` dumps 200 times while another thread makes and releases D3D12 devices (RTX 5070 Ti, driver 610.74): without the change it crashed 6 of 30 runs mid-dump, with the hold alone 7 of 30, with this change 0 of 60. Thread dumps are taken one at a time (`DUMP_LOCK`): two at once could each suspend the other's dumping thread, and neither went on. On CI the new device test and `thread_dumps_while_threads_run_and_exit` hung that way under --test-threads=4 (job 143904819616, cancelled after 45 min). A dump asked for on the thread that is dumping (the process ending there) returns at once. `two_threads_dump_at_once` runs two dumpers of 50 dumps each: without the lock 1 of 15 runs hung under 64 busy processes, with it 0 of 15. The process-end hook never waits for that lock: ExitProcess holds the loader lock there, and a dump going on in another thread waits for the loader lock in the per-frame GetModuleHandleExW, so each waited for the other (found in review). It takes the lock only when it is free and otherwise leaves the other threads out, after its own line and stack are logged. `the_process_ends_while_another_thread_dumps` ends a child process with exit(3) while a second thread dumps in a loop: 20 of 20 runs hung with the hook waiting, 0 of 20 with this commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`a_page_whose_move_fails_stays_mapped_where_it_was` reserved 64 KiB and released it to have "an address with nothing reserved". The next `VirtualAlloc(NULL, ...)` of any other test thread is placed first-fit, in that freshly freed hole: the commit in `move_away` then succeeded, the assertion failed (CI job 143772436418), and the page's 64 KiB were copied into the other test's memory and its old address released. The destination is now the first 64 KiB above `lpMaximumApplicationAddress`: committing there fails and nobody can reserve it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`a_refused_gpu_upload_segment_becomes_custom` and `mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment` remade a window inside the lib test binary. After the lib's earlier tests the remake's CreateCommandQueue returns E_OUTOFMEMORY (here and on throny's RTX 4080), also with --test-threads=1, so it is something earlier tests leave in the process, not the tests running beside it. The queue is made after a segment was mapped, so the remake cannot restore the window and stops the process with 0x7C10003. That ended the lib test binary after ~1,390 tests on NVIDIA (reported on xcl-dev#3041). Making the stop panic in tests instead is not enough: the binary then died later with an access violation, after the failed remake left the window to the driver. Each of the two tests now runs again on its own in a child process, as `failed_restore_stops_before_importing_an_unbacked_window` already does; the parent fails when the child does and passes the child's SKIPPED lines on. A failing child's exit code (decimal and hex) heads the parent's failure message: a stop without a panic, such as 0x7C10003, leaves only a partial transcript. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
164ff62 to
8646282
Compare
|
merge-check
The failures left are other tests of that module ( |
|
Merge check: safe (head 8646282, merged onto main 16c2fd0)
Not tested: AMD/Intel cards. AI use: Claude Code (Claude Opus 5.5) ran the checks and wrote this comment. |
Four flakes made
Build and test (Windows, no GPU)fail on pull requests that did not touch the code involved: 30 of the 60 most recent failed CI runs (2026-12-02). One commit per flake. This takes over #3187 (its commit, unchanged) and does the same as the draft #1671 forkernelx. The fifth cross-branch flake of that survey, thelist_xfake allocator, is left to #3472.Fixes #3586 (the thread-dump crash; @fromthemoonx diagnosed the same cause there first).
What is in it
crates/xcl/tests/frame_clock.rs:token_on_timeout_and_token_in_origin_refresh(line 132) expected a 0 ms wait to time out. Its ancillary-block check created unified memory on first use, inside the wait. On a CI runner that took longer than a 60 Hz frame, so a frame ticked during the wait.ClockGuard::acquirenow creates unified memory first. Jobs 143831052750, 143800498706, 143770726179, 143765485544, 143752311706, 143681858715, 143672906542; each has theUMA: …line just before the panic.crates/xcl/src/eh.rs: the lib binary ended with 0xc0000005 insidethread_dumps_while_threads_run_and_exit, after 3–36 of its 40 dumps, while a D3D12 device test finished.dump_threadsresumes a thread before it unwinds the copy of its stack, and that unwinding reads the unwind data and code of the frame's DLL, which could be unloaded by then. Each frame's DLL is now held withGetModuleHandleExW(FROM_ADDRESS)while it is unwound. The loader refuses that for a DLL it is already unloading, whose unwind dataRtlLookupFunctionEntrystill finds until it is unmapped, so the stack ends at such a frame. Addresses in the title's images and in XCL's generated thunks (stubs::alloc_code, whose chunks are never freed and are now listed forstubs::in_code_arena) are not the loader's and are unwound unpinned as before. New tests:thread_dumps_while_devices_come_and_go, andunwinding_goes_through_a_generated_thunk(a dump goes on through a thunk to its caller). Thread dumps are now taken one at a time (DUMP_LOCK): two at once could each suspend the other's dumping thread and neither went on. That is how an earlier push of this PR hung CI (job 143904819616: the new device test andthread_dumps_while_threads_run_and_exitunder--test-threads=4). A dump asked for on the thread already dumping (the process ending there) returns at once. Test:two_threads_dump_at_once. The process-end hook never waits for that lock: ExitProcess holds the loader lock there, and a dump going on in another thread waits for the loader lock (GetModuleHandleExW), so each waited for the other (found by @vasanex). It dumps the other threads only when no dump is going on. Test:the_process_ends_while_another_thread_dumps. 14 jobs, e.g. 143199589350, 143759900214, 143838507638, 143202141589.crates/xcl/src/hle/kernelx.rs:a_page_whose_move_fails_stays_mapped_where_it_wasfreed a 64 KiB reservation to get "an address with nothing reserved". Another thread's next first-fitVirtualAlloccould take it, the commit then succeeded, and the page was copied into that test's memory (assertion failed: move_away(…).is_err()). The destination is now the first 64 KiB abovelpMaximumApplicationAddress, which nobody can reserve. Job 143772436418.crates/xcl/src/hle/d3d12x/uma_driver.rs(the commit of Tests: the mixed-window remake tests run in a child process #3187):mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segmentfailed (a GPU_UPLOAD segment became CUSTOM:Map gave …orCreateHeaprefused), and the remake's stop ended the whole binary with exit code 0x7C10003. The remake runs inside the shared test binary, where what earlier tests leave behind (out-of-memory fromCreateCommandQueue, seen with--test-threads=1too, and E_OUTOFMEMORY lines in the CI logs) and other test threads' use of the address space get in its way. The two mixed-remake tests now run again in a child process of their own; the parent fails when the child fails or ran no test, and passes the child's SKIPPED lines on. Jobs 143828732230, 143718961344, 143562397058, 143175559324 (test failures) and 143794881256, 143742411497, 143252746541, 143175576386 (0x7C10003).Tested
.\scripts\test.ps1(cargo test --workspace -- --test-threads=4): 3010 passed, 0 failed, 52 ignored; SKIPPED 24 (22 no wave64, 2 no heap windows). The run before it on the same head failed the fourtitle_texturestests together (a readback mismatch inplaced_title_textures_share_vram_and_preserve_pixels, the other three on its poisoned lock); they also fail that way onmainhere, see Not testedcargo build --release -p xcl: 39 warnings, the same ones as origin/maintoken_on_timeout_and_token_in_origin_refreshalone, with 64 busy processes on 32 cores: 19/30 failed without the fix, 0/30 with it.thread_dumps_while_devices_come_and_goalone, one or four processes at a time: 6/30 crashed without the change (AV mid-dump), 7/30 with the module hold alone (cdb: AV inRtlLookupFunctionEntryon the.pdataofnvgpucomp64.dllas the driver unloaded it), 0/60 with the hold and the stop at an unloading DLL (measured before the thunk check below was added; it changes nothing for DLL frames).unwinding_goes_through_a_generated_thunkfails without the thunk check ("the unwinding ended at the thunk") and passes with it.two_threads_dump_at_once(two threads, 50 dumps each) under 64 busy processes: 1/15 runs hung without the lock (the test's 120 s check fired), 0/15 with it. The three dump tests run together under--test-threads=4: 5/5 passed in 8–12 s.the_process_ends_while_another_thread_dumps(a child process callsexit(3)while a second thread dumps in a loop): 20/20 hung with the hook waiting for the lock, 0/20 with it taking the lock only when free.54225f58,cargo test -p xcl --lib --no-fail-fast -- --test-threads=4ended with exit code 0x7C10003 after 1,386 tests, at "coherent window could not be restored … after CreateCommandQueue: … (0x8007000E)"; with the commit, three runs of the same command had all 7uma_drivertests ok.Regression run
main:
this PR's head:
Not tested
XCL_THREAD_DUMP_AT, so they never take a thread dump: theeh.rschange is covered by its test only. They do not reach the changed test code either.maincode here), DXGI device reset onfeat/two-tier-texture-budget-l0, theamd-watch-*AVs.AI use
🤖 Generated with Claude Code