Tests: fix four CI flakes that fail unrelated pull requests #3743
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3743"
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?
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T23:49:26Z.
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 #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
Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T00:13:24Z.
merge-check
base:
078358a058head:
ec9fba9947merge: clean (merge commit 4ec011d4,
git diff --checkclean; 5 files, +142/-3)build: cargo build --workspace -> ok; cargo build --release -p xcl -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3008 passed, 0 failed, 52 ignored (base: 3006 passed, 0 failed, 52 ignored); SKIPPED: 25 on both, the same tests (22 no wave64, 2 no heap windows, 1 cannot disable the driver cache); failing: none
review: no open finding; whole diff read.
eh.rsunwind, andstubs.rsrecording the code arena's chunks). I checked the previous head3fb28e48first and measured that itsunwindended at XCL's generated thunks (a scratch test, not part of any branch: on base 12 frames, 10 of them after a thunk made bystubs::alloc_code_with_unwind; on that head 2 frames). This head fixes it withstubs::in_code_arena: the same scratch test gives 12 frames, 10 after the thunk, as on base, and the PR's ownunwinding_goes_through_a_generated_thunkpasses.in_code_arenaonly tries its lock and answers false while the list is written, so a dump cannot wait on it; the list is written under the arena's mutex, which no dump takes. The pin takes the loader lock (GetModuleHandleExW) once per frame, after the thread was resumed, as the comment indump_threadsrequires.frame_clock.rsonly makes unified memory before the timing; thekernelxtest's destination abovelpMaximumApplicationAddresscannot be reserved by anyone; theuma_driverchild reruns one test with--exact, fails when the child fails or ran nothing, and passes on its SKIPPED lines.ehtests (thread_dumps_while_devices_come_and_go,unwinding_goes_through_a_generated_thunk) passed 20 of 20 runs; on the previous head's merge theuma_drivertests passed 10 of 10 (not repeated on this one, that commit's diff is unchanged). I did not reproduce the "before" failures here: base passed the suite too.performance: none expected by default: the runtime change runs in thread dumps only. Smoke, 60 s, release, offline: base 1677 frames, 17992 MB peak commit; merge 1693 frames, 18194 MB; no device removal or crash on either.
title run: RTX 3080, 60 s of the retail title on the merge's release build with
XCL_THREAD_DUMP_AT=30,45, start screen only (not past the loading screen): 0 device removals, 0 crashes, 1701 frames (about 28 presents/s). Both dumps were written: 332 thread stacks, 326 of them end at one and the same address in ntdll (read as the thread's start; the log has no symbol names) and 6 are cut at the 14-frame limit; 293 of the 1461 frames are outside the loader's modules (title images and XCL's thunks) and the stacks go on through them.verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 3080 10 GB (driver 621.40), AMD Ryzen 9 7950X, Windows 11 Pro 26200, rustc 1.100.0 / Claude Code, Claude Fable 5.2 (ran the builds, tests and title runs, read the whole diff, wrote this check)
Imported from ivall/xcl. Originally posted by pvfreis on 2026-12-03T00:32:22Z.
Review: COMMENTED
Read the
eh.rschange at3fb28e48. 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 (https://github.com/xcl-dev/xcl/issues/3586#issuecomment-7355894281). 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.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-03T00:36:20Z.
Thanks for checking, @pvfreis:
ec9fba994(ce28e2999):stubs::alloc_codenow records its never-freed arena chunks and exposesstubs::in_code_arena,eh::unwindallowsmodules::image_base_for_addr(rip).is_some() || stubs::in_code_arena(rip), andeh::tests::unwinding_goes_through_a_generated_thunkverifies unwinding through analloc_code_with_unwindthunk to its caller (eh.rsandstubs.rsare the onlyRtlAddFunctionTablecallers incrates/xcl/src).Fixes #3586to the PR description so it closes on merge (credit to @fromthemoonx's earlier diagnosis there).Imported from ivall/xcl. Originally posted by pvfreis on 2026-12-03T01:36:16Z.
Both points are resolved at
ec9fba994(read, nothing run):unwindgoes on through thunks in the stubs arena, andunwinding_goes_through_a_generated_thunkwould end at the thunk on3fb28e48. The description now closes #3586. Nothing open from my side.Checked with Claude Code (Claude Opus 5.5 read the code, Claude Fable 5.2 rechecked); I checked each point.
Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T02:42:45Z.
Code review location:
crates/xcl/src/eh.rs; line 982Finding (medium, measured): a process that ends with a non-zero status while another thread is dumping does not end.
hk_nt_terminate_processruns on the thread that ends the process and, for a status other than 0, callsdump_threads, which now waits here forDUMP_LOCK. The scratch test in the review body shows the result: 20 of 20 child processes hang on this head, 0 of 20 onec9fba99.From reading, not confirmed with a debugger: the ending thread is inside
ExitProcessand holds the loader lock when the hook runs; the thread that ownsDUMP_LOCKneeds the loader lock for the per-frameGetModuleHandleExWpin 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_OWNERonly 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, andsmoke.ps1or a test harness waits on it.Suggested: the process-end hook should not wait for the lock.
try_lockthere 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 givedump_threadsa 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.Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T02:42:45Z.
Review: COMMENTED
Review of
164ff626(the change sinceec9fba99: the dump lock ineh.rs; code reading and the scratch test below, not a merge-check) · 1 findingIn short: serialising thread dumps fixes two dumps suspending each other, and
two_threads_dump_at_oncecovers that. It also makes the process-end hook wait:hk_nt_terminate_processcallsdump_threadsfor 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 forec9fba99and 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 callsdump_threadsin a loop, and callsstd::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.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-03T03:16:30Z.
Code review location:
crates/xcl/src/eh.rs; line 982Thanks @vasanex, good catch, and the repro made it quick to confirm. Fixed in
86462821(theeh.rscommit, now94367b45):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.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.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.
Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T03:19:00Z.
Code review location:
crates/xcl/src/eh.rs; line 982Fixed 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_dumpspassed 20 of 20 runs, andcargo 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.
Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-03T03:36:02Z.
merge-check
base:
395405e4c0head:
8646282168merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3016 passed, 0 failed, 56 ignored, the same in 3 runs of 3 (base: 3012 passed, 0 failed, 56 ignored; its first run ended in the #3586 crash after 8 dumps, the rerun gave these counts); SKIPPED: 25, the same as base (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps); failing: none
review: read the whole diff (5 files, +235 -4). No open finding.
thread_dumps_while_devices_come_and_gopassed 22 of 22 runs. With only the DLL pin taken out it crashed in 8 of 24 (access violation).the_process_ends_while_another_thread_dumpspassed 30 of 30. With the hook waiting for the lock again it failed 3 of 3. Without thein_code_arenacheckunwinding_goes_through_a_generated_thunkfailed 5 of 5; with it, 30 of 30 pass.two_threads_dump_at_once: 30 of 30.kernelxflake reproduces here when its tests run on their own (hle::kernelx::tests::, 60 runs per cell, base and merge alternating):a_page_whose_move_fails_stays_mapped_where_it_wasfailed, 4 threadsThe failures left are other tests of that module (
an_address_keeps_the_page_the_title_mapped_there_last,changed_gpu_view_pages_are_told_once_in_order,a_gpu_view_page_follows_its_physical_page,gpu_visible_fallback_memory_is_write_watched,a_page_leaving_plain_memory_has_the_tiles_over_it_linked_again) and, at 8 threads, a crash with no test named (4 on base, 2 on the merge). All butgpu_visible_fallback_memory_is_write_watched(1 run) also failed on base. I did not look for their cause; #1487 tracks these parallel failures; they are not for this PR.4) The pin makes a dump call the loader, so I checked a dump taken while another thread holds the loader lock (
LdrLockLoaderLock, scratch test): it ends in about 25 ms on base and on the merge. A thread stuck inside aDllMainis not tested.5) The
uma_drivertests passed 10 of 10 runs andframe_clock20 of 20. I did not reproduce their old failures.6) Not tested: a retail title (none on this machine), AMD.
performance: none expected: the runtime change runs only in thread dumps and when a process ends with an error. Reasoned, not measured.
verdict: safe to merge
hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)
Imported from ivall/xcl. Originally posted by throny on 2026-12-03T06:07:21Z.
Merge check: safe (head
864628216, merged onto main16c2fd082)cargo test --workspace -- --test-threads=4: 3016 passed, 0 failed, 56 ignored; 25 SKIPPED lines, no test binary ended abnormallyNot tested: AMD/Intel cards.
AI use: Claude Code (Claude Opus 5.5) ran the checks and wrote this comment.