Tests: fix four CI flakes that fail unrelated pull requests #3743

Merged
Kalmarv merged 4 commits from upstream-pr/3743 into main 2026-12-03 11:16:11 +00:00
Kalmarv commented 2026-12-02 23:49:26 +00:00 (Migrated from github.com)

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 for kernelx. The fifth cross-branch flake of that survey, the list_x fake 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::acquire now creates unified memory first. Jobs 143831052750, 143800498706, 143770726179, 143765485544, 143752311706, 143681858715, 143672906542; each has the UMA: … line just before the panic.
  • crates/xcl/src/eh.rs: the lib binary ended with 0xc0000005 inside thread_dumps_while_threads_run_and_exit, after 3–36 of its 40 dumps, while a D3D12 device test finished. dump_threads resumes 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 with GetModuleHandleExW(FROM_ADDRESS) while it is unwound. The loader refuses that for a DLL it is already unloading, whose unwind data RtlLookupFunctionEntry still 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 for stubs::in_code_arena) are not the loader's and are unwound unpinned as before. New tests: thread_dumps_while_devices_come_and_go, and unwinding_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 and thread_dumps_while_threads_run_and_exit under --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_was freed a 64 KiB reservation to get "an address with nothing reserved". Another thread's next first-fit VirtualAlloc could 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 above lpMaximumApplicationAddress, 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_segment failed (a GPU_UPLOAD segment became CUSTOM: Map gave … or CreateHeap refused), 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 from CreateCommandQueue, seen with --test-threads=1 too, 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

  • RTX 5070 Ti (NVIDIA 610.74), Ryzen 9 9950X, Windows 11 Pro 26200, rustc 1.99.0 MSVC, debug.
  • .\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 four title_textures tests together (a readback mismatch in placed_title_textures_share_vram_and_preserve_pixels, the other three on its poisoned lock); they also fail that way on main here, see Not tested
  • cargo build --release -p xcl: 39 warnings, the same ones as origin/main
  • Before/after, on the same machine:
    • frame_clock: token_on_timeout_and_token_in_origin_refresh alone, with 64 busy processes on 32 cores: 19/30 failed without the fix, 0/30 with it.
    • eh: thread_dumps_while_devices_come_and_go alone, 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 in RtlLookupFunctionEntry on the .pdata of nvgpucomp64.dll as 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_thunk fails without the thunk check ("the unwinding ended at the thunk") and passes with it.
    • eh: 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.
    • eh: the_process_ends_while_another_thread_dumps (a child process calls exit(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.
    • uma_driver (from #3187): on base 54225f58, cargo test -p xcl --lib --no-fail-fast -- --test-threads=4 ended 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 7 uma_driver tests ok.

Regression run
main:

xcl-smoke v1
commit: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1672 (PresentX 1672)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17291 MB

this PR's head:

xcl-smoke v1
commit: 86462821686cc7830f8da54c4a5baf9ad327d3cd
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1678 (PresentX 1678)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 16886 MB

Not tested

  • The smoke runs exit with 0 and set no XCL_THREAD_DUMP_AT, so they never take a thread dump: the eh.rs change is covered by its test only. They do not reach the changed test code either.
  • AMD; the GitHub runner itself (the fixes were checked against its logs; the runs were on this NVIDIA machine).
  • The kernelx collision and the mixed-window address-space interference did not happen in local runs of the old code; those fixes rest on the mechanism and the CI logs.
  • What exhausts memory in the lib binary for the mixed remake: not found.
  • Other failures seen in the survey that recur on one branch only are left alone: title_textures (several tests at once; it also failed once in the runs above, and once on main code here), DXGI device reset on feat/two-tier-texture-budget-l0, the amd-watch-* AVs.

AI use

  • Claude Code with Claude Opus 5.5: surveyed the CI logs, found the causes, wrote the fixes, the test and this description; the runs above were made by it on the hardware named.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5616836775 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3743). Originally posted by [Kalmarv](https://github.com/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 for `kernelx`. The fifth cross-branch flake of that survey, the `list_x` fake 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::acquire` now creates unified memory first. Jobs 143831052750, 143800498706, 143770726179, 143765485544, 143752311706, 143681858715, 143672906542; each has the `UMA: …` line just before the panic. - `crates/xcl/src/eh.rs`: the lib binary ended with 0xc0000005 inside `thread_dumps_while_threads_run_and_exit`, after 3–36 of its 40 dumps, while a D3D12 device test finished. `dump_threads` resumes 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 with `GetModuleHandleExW(FROM_ADDRESS)` while it is unwound. The loader refuses that for a DLL it is already unloading, whose unwind data `RtlLookupFunctionEntry` still 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 for `stubs::in_code_arena`) are not the loader's and are unwound unpinned as before. New tests: `thread_dumps_while_devices_come_and_go`, and `unwinding_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 and `thread_dumps_while_threads_run_and_exit` under `--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_was` freed a 64 KiB reservation to get "an address with nothing reserved". Another thread's next first-fit `VirtualAlloc` could 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 above `lpMaximumApplicationAddress`, 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_segment` failed (a GPU_UPLOAD segment became CUSTOM: `Map gave …` or `CreateHeap` refused), 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 from `CreateCommandQueue`, seen with `--test-threads=1` too, 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** - RTX 5070 Ti (NVIDIA 610.74), Ryzen 9 9950X, Windows 11 Pro 26200, rustc 1.99.0 MSVC, debug. - `.\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 four `title_textures` tests together (a readback mismatch in `placed_title_textures_share_vram_and_preserve_pixels`, the other three on its poisoned lock); they also fail that way on `main` here, see **Not tested** - `cargo build --release -p xcl`: 39 warnings, the same ones as origin/main - Before/after, on the same machine: - frame_clock: `token_on_timeout_and_token_in_origin_refresh` alone, with 64 busy processes on 32 cores: 19/30 failed without the fix, 0/30 with it. - eh: `thread_dumps_while_devices_come_and_go` alone, 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 in `RtlLookupFunctionEntry` on the `.pdata` of `nvgpucomp64.dll` as 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_thunk` fails without the thunk check ("the unwinding ended at the thunk") and passes with it. - eh: `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. - eh: `the_process_ends_while_another_thread_dumps` (a child process calls `exit(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. - uma_driver (from #3187): on base `54225f58`, `cargo test -p xcl --lib --no-fail-fast -- --test-threads=4` ended 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 7 `uma_driver` tests ok. **Regression run** main: ``` xcl-smoke v1 commit: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1672 (PresentX 1672) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 17291 MB ``` this PR's head: ``` xcl-smoke v1 commit: 86462821686cc7830f8da54c4a5baf9ad327d3cd gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1678 (PresentX 1678) presents per 2 s (last 3): 60 60 61 device removals: 0 crashes: 0 peak commit: 16886 MB ``` **Not tested** - The smoke runs exit with 0 and set no `XCL_THREAD_DUMP_AT`, so they never take a thread dump: the `eh.rs` change is covered by its test only. They do not reach the changed test code either. - AMD; the GitHub runner itself (the fixes were checked against its logs; the runs were on this NVIDIA machine). - The kernelx collision and the mixed-window address-space interference did not happen in local runs of the old code; those fixes rest on the mechanism and the CI logs. - What exhausts memory in the lib binary for the mixed remake: not found. - Other failures seen in the survey that recur on one branch only are left alone: title_textures (several tests at once; it also failed once in the runs above, and once on `main` code here), DXGI device reset on `feat/two-tier-texture-budget-l0`, the `amd-watch-*` AVs. **AI use** - Claude Code with Claude Opus 5.5: surveyed the CI logs, found the causes, wrote the fixes, the test and this description; the runs above were made by it on the hardware named. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
vasanex commented 2026-12-03 00:13:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T00:13:24Z.


merge-check
base: 078358a058
head: ec9fba9947
merge: clean (merge commit 4ec011d4, git diff --check clean; 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.

  1. The runtime change is in thread dumps only (eh.rs unwind, and stubs.rs recording the code arena's chunks). I checked the previous head 3fb28e48 first and measured that its unwind ended at XCL's generated thunks (a scratch test, not part of any branch: on base 12 frames, 10 of them after a thunk made by stubs::alloc_code_with_unwind; on that head 2 frames). This head fixes it with stubs::in_code_arena: the same scratch test gives 12 frames, 10 after the thunk, as on base, and the PR's own unwinding_goes_through_a_generated_thunk passes.
  2. in_code_arena only 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 in dump_threads requires.
  3. The three test-only commits: frame_clock.rs only makes unified memory before the timing; the kernelx test's destination above lpMaximumApplicationAddress cannot be reserved by anyone; the uma_driver child reruns one test with --exact, fails when the child fails or ran nothing, and passes on its SKIPPED lines.
  4. Alone on the merge: the two eh tests (thread_dumps_while_devices_come_and_go, unwinding_goes_through_a_generated_thunk) passed 20 of 20 runs; on the previous head's merge the uma_driver tests 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)
<!-- greyfinch-sync:ivall/xcl:comment:7362939193 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3743#issuecomment-7362939193). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T00:13:24Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: ec9fba994725e59c4299e741a4cad3915300d5e8 merge: clean (merge commit 4ec011d4, `git diff --check` clean; 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. 1) The runtime change is in thread dumps only (`eh.rs` `unwind`, and `stubs.rs` recording the code arena's chunks). I checked the previous head `3fb28e48` first and measured that its `unwind` ended at XCL's generated thunks (a scratch test, not part of any branch: on base 12 frames, 10 of them after a thunk made by `stubs::alloc_code_with_unwind`; on that head 2 frames). This head fixes it with `stubs::in_code_arena`: the same scratch test gives 12 frames, 10 after the thunk, as on base, and the PR's own `unwinding_goes_through_a_generated_thunk` passes. 2) `in_code_arena` only 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 in `dump_threads` requires. 3) The three test-only commits: `frame_clock.rs` only makes unified memory before the timing; the `kernelx` test's destination above `lpMaximumApplicationAddress` cannot be reserved by anyone; the `uma_driver` child reruns one test with `--exact`, fails when the child fails or ran nothing, and passes on its SKIPPED lines. 4) Alone on the merge: the two `eh` tests (`thread_dumps_while_devices_come_and_go`, `unwinding_goes_through_a_generated_thunk`) passed 20 of 20 runs; on the previous head's merge the `uma_driver` tests 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)
pvfreis commented 2026-12-03 00:32:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by pvfreis on 2026-12-03T00:32:22Z.

Review: COMMENTED


Read the eh.rs change at 3fb28e48. Two points, both from reading the code (nothing here was run):

  1. When GetModuleHandleExW fails, only addresses in title images keep unwinding, so the walk now also ends at XCL's generated thunks. They live in the stubs arena (private VirtualAlloc memory, stubs.rs:83), which image_base_for_addr does not know, and their unwind data is registered so that eh::unwind walks through them (stubs.rs:101). The XCL_TRACE_IMPORTS tracer (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.

  2. 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 #3586 would 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.

<!-- greyfinch-sync:ivall/xcl:review:6161585748 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3743#pullrequestreview-6161585748). Originally posted by [pvfreis](https://github.com/pvfreis) on 2026-12-03T00:32:22Z. **Review:** COMMENTED --- Read the `eh.rs` change at 3fb28e48. Two points, both from reading the code (nothing here was run): 1. When `GetModuleHandleExW` fails, only addresses in title images keep unwinding, so the walk now also ends at XCL's generated thunks. They live in the stubs arena (private `VirtualAlloc` memory, `stubs.rs:83`), which `image_base_for_addr` does not know, and their unwind data is registered so that `eh::unwind` walks through them (`stubs.rs:101`). The `XCL_TRACE_IMPORTS` tracer (`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. 2. 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 #3586` would 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.
Kalmarv commented 2026-12-03 00:36:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-03T00:36:20Z.


Thanks for checking, @pvfreis:

  1. Fixed in ec9fba994 (ce28e2999): stubs::alloc_code now records its never-freed arena chunks and exposes stubs::in_code_arena, eh::unwind allows modules::image_base_for_addr(rip).is_some() || stubs::in_code_arena(rip), and eh::tests::unwinding_goes_through_a_generated_thunk verifies unwinding through an alloc_code_with_unwind thunk to its caller (eh.rs and stubs.rs are the only RtlAddFunctionTable callers in crates/xcl/src).
  2. Added Fixes #3586 to the PR description so it closes on merge (credit to @fromthemoonx's earlier diagnosis there).
<!-- greyfinch-sync:ivall/xcl:comment:7363381605 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3743#issuecomment-7363381605). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-03T00:36:20Z. --- Thanks for checking, @pvfreis: 1. Fixed in `ec9fba994` (`ce28e2999`): `stubs::alloc_code` now records its never-freed arena chunks and exposes `stubs::in_code_arena`, `eh::unwind` allows `modules::image_base_for_addr(rip).is_some() || stubs::in_code_arena(rip)`, and `eh::tests::unwinding_goes_through_a_generated_thunk` verifies unwinding through an `alloc_code_with_unwind` thunk to its caller (`eh.rs` and `stubs.rs` are the only `RtlAddFunctionTable` callers in `crates/xcl/src`). 2. Added `Fixes #3586` to the PR description so it closes on merge (credit to @fromthemoonx's earlier diagnosis there).
pvfreis commented 2026-12-03 01:36:16 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by pvfreis on 2026-12-03T01:36:16Z.


Both points are resolved at ec9fba994 (read, nothing run): unwind goes on through thunks in the stubs arena, and unwinding_goes_through_a_generated_thunk would end at the thunk on 3fb28e48. 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.

<!-- greyfinch-sync:ivall/xcl:comment:7364529986 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3743#issuecomment-7364529986). Originally posted by [pvfreis](https://github.com/pvfreis) on 2026-12-03T01:36:16Z. --- Both points are resolved at `ec9fba994` (read, nothing run): `unwind` goes on through thunks in the stubs arena, and `unwinding_goes_through_a_generated_thunk` would end at the thunk on `3fb28e48`. 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.
vasanex commented 2026-12-03 02:42:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T02:42:45Z.

Code review location: crates/xcl/src/eh.rs; line 982

@@ -932,15 +954,34 @@ unsafe fn unwind(ctx: &mut windows_sys::Win32::System::Diagnostics::Debug::CONTE
     out
 }
 
+/// One thread dump at a time: two at once could each suspend the other's dumping thread, and
+/// neither went on (the lib tests hung).
+static DUMP_LOCK: Mutex<()> = Mutex::new(());
+/// The thread dumping now (0: none): the process ending on it dumps nothing more.
+static DUMP_OWNER: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0);
+
 /// `XCL_THREAD_DUMP_AT`: every other thread of the process stopped for a moment – where it is
 /// (RIP) and the calls on its stack that lead there, in the log.
 pub fn dump_threads() {
     use windows_sys::Win32::Foundation::{CloseHandle, INVALID_HANDLE_VALUE};
     use windows_sys::Win32::System::Diagnostics::Debug::{GetThreadContext, CONTEXT, CONTEXT_CONTROL_AMD64, CONTEXT_INTEGER_AMD64};
     use windows_sys::Win32::System::Diagnostics::ToolHelp::{CreateToolhelp32Snapshot, Thread32First, Thread32Next, TH32CS_SNAPTHREAD, THREADENTRY32};
     use windows_sys::Win32::System::Threading::{GetCurrentProcessId, GetCurrentThreadId, OpenThread, ResumeThread, SuspendThread, THREAD_GET_CONTEXT, THREAD_QUERY_INFORMATION, THREAD_SUSPEND_RESUME};
+    struct Owner;
+    impl Drop for Owner {
+        fn drop(&mut self) {
+            DUMP_OWNER.store(0, Ordering::Release);
+        }
+    }
     unsafe {
         let (pid, me) = (GetCurrentProcessId(), GetCurrentThreadId());
+        if DUMP_OWNER.load(Ordering::Acquire) == me {
+            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());

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.

<!-- greyfinch-sync:ivall/xcl:review-comment:4779189807 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3743#discussion_r4779189807). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T02:42:45Z. **Code review location:** `crates/xcl/src/eh.rs`; line 982 ~~~~diff @@ -932,15 +954,34 @@ unsafe fn unwind(ctx: &mut windows_sys::Win32::System::Diagnostics::Debug::CONTE out } +/// One thread dump at a time: two at once could each suspend the other's dumping thread, and +/// neither went on (the lib tests hung). +static DUMP_LOCK: Mutex<()> = Mutex::new(()); +/// The thread dumping now (0: none): the process ending on it dumps nothing more. +static DUMP_OWNER: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0); + /// `XCL_THREAD_DUMP_AT`: every other thread of the process stopped for a moment – where it is /// (RIP) and the calls on its stack that lead there, in the log. pub fn dump_threads() { use windows_sys::Win32::Foundation::{CloseHandle, INVALID_HANDLE_VALUE}; use windows_sys::Win32::System::Diagnostics::Debug::{GetThreadContext, CONTEXT, CONTEXT_CONTROL_AMD64, CONTEXT_INTEGER_AMD64}; use windows_sys::Win32::System::Diagnostics::ToolHelp::{CreateToolhelp32Snapshot, Thread32First, Thread32Next, TH32CS_SNAPTHREAD, THREADENTRY32}; use windows_sys::Win32::System::Threading::{GetCurrentProcessId, GetCurrentThreadId, OpenThread, ResumeThread, SuspendThread, THREAD_GET_CONTEXT, THREAD_QUERY_INFORMATION, THREAD_SUSPEND_RESUME}; + struct Owner; + impl Drop for Owner { + fn drop(&mut self) { + DUMP_OWNER.store(0, Ordering::Release); + } + } unsafe { let (pid, me) = (GetCurrentProcessId(), GetCurrentThreadId()); + if DUMP_OWNER.load(Ordering::Acquire) == me { + 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()); ~~~~ --- **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.
vasanex commented 2026-12-03 02:42:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T02:42:45Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:ivall/xcl:review:6162826221 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3743#pullrequestreview-6162826221). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T02:42:45Z. **Review:** COMMENTED --- **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.
Kalmarv commented 2026-12-03 03:16:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-03T03:16:30Z.

Code review location: crates/xcl/src/eh.rs; line 982

@@ -932,15 +954,34 @@ unsafe fn unwind(ctx: &mut windows_sys::Win32::System::Diagnostics::Debug::CONTE
     out
 }
 
+/// One thread dump at a time: two at once could each suspend the other's dumping thread, and
+/// neither went on (the lib tests hung).
+static DUMP_LOCK: Mutex<()> = Mutex::new(());
+/// The thread dumping now (0: none): the process ending on it dumps nothing more.
+static DUMP_OWNER: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0);
+
 /// `XCL_THREAD_DUMP_AT`: every other thread of the process stopped for a moment – where it is
 /// (RIP) and the calls on its stack that lead there, in the log.
 pub fn dump_threads() {
     use windows_sys::Win32::Foundation::{CloseHandle, INVALID_HANDLE_VALUE};
     use windows_sys::Win32::System::Diagnostics::Debug::{GetThreadContext, CONTEXT, CONTEXT_CONTROL_AMD64, CONTEXT_INTEGER_AMD64};
     use windows_sys::Win32::System::Diagnostics::ToolHelp::{CreateToolhelp32Snapshot, Thread32First, Thread32Next, TH32CS_SNAPTHREAD, THREADENTRY32};
     use windows_sys::Win32::System::Threading::{GetCurrentProcessId, GetCurrentThreadId, OpenThread, ResumeThread, SuspendThread, THREAD_GET_CONTEXT, THREAD_QUERY_INFORMATION, THREAD_SUSPEND_RESUME};
+    struct Owner;
+    impl Drop for Owner {
+        fn drop(&mut self) {
+            DUMP_OWNER.store(0, Ordering::Release);
+        }
+    }
     unsafe {
         let (pid, me) = (GetCurrentProcessId(), GetCurrentThreadId());
+        if DUMP_OWNER.load(Ordering::Acquire) == me {
+            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());

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 takes DUMP_LOCK only with try_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 calls dump_threads in a loop, then calls std::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 on 164ff626), 0 of 20 with this commit.
  • At this head: scripts/test.ps1 3010 passed, 0 failed, 52 ignored (the run before it failed only the four title_textures tests together, which also happens on main here), and the 60 s smoke is in the description.

Reply written with Claude Code (Claude Opus 5.5) from those runs.

<!-- greyfinch-sync:ivall/xcl:review-comment:4779435630 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3743#discussion_r4779435630). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-03T03:16:30Z. **Code review location:** `crates/xcl/src/eh.rs`; line 982 ~~~~diff @@ -932,15 +954,34 @@ unsafe fn unwind(ctx: &mut windows_sys::Win32::System::Diagnostics::Debug::CONTE out } +/// One thread dump at a time: two at once could each suspend the other's dumping thread, and +/// neither went on (the lib tests hung). +static DUMP_LOCK: Mutex<()> = Mutex::new(()); +/// The thread dumping now (0: none): the process ending on it dumps nothing more. +static DUMP_OWNER: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0); + /// `XCL_THREAD_DUMP_AT`: every other thread of the process stopped for a moment – where it is /// (RIP) and the calls on its stack that lead there, in the log. pub fn dump_threads() { use windows_sys::Win32::Foundation::{CloseHandle, INVALID_HANDLE_VALUE}; use windows_sys::Win32::System::Diagnostics::Debug::{GetThreadContext, CONTEXT, CONTEXT_CONTROL_AMD64, CONTEXT_INTEGER_AMD64}; use windows_sys::Win32::System::Diagnostics::ToolHelp::{CreateToolhelp32Snapshot, Thread32First, Thread32Next, TH32CS_SNAPTHREAD, THREADENTRY32}; use windows_sys::Win32::System::Threading::{GetCurrentProcessId, GetCurrentThreadId, OpenThread, ResumeThread, SuspendThread, THREAD_GET_CONTEXT, THREAD_QUERY_INFORMATION, THREAD_SUSPEND_RESUME}; + struct Owner; + impl Drop for Owner { + fn drop(&mut self) { + DUMP_OWNER.store(0, Ordering::Release); + } + } unsafe { let (pid, me) = (GetCurrentProcessId(), GetCurrentThreadId()); + if DUMP_OWNER.load(Ordering::Acquire) == me { + 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()); ~~~~ --- 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 takes `DUMP_LOCK` only with `try_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 calls `dump_threads` in a loop, then calls `std::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 on `164ff626`), 0 of 20 with this commit. - At this head: `scripts/test.ps1` 3010 passed, 0 failed, 52 ignored (the run before it failed only the four `title_textures` tests together, which also happens on `main` here), and the 60 s smoke is in the description. Reply written with Claude Code (Claude Opus 5.5) from those runs.
vasanex commented 2026-12-03 03:19:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by vasanex on 2026-12-03T03:19:00Z.

Code review location: crates/xcl/src/eh.rs; line 982

@@ -932,15 +954,34 @@ unsafe fn unwind(ctx: &mut windows_sys::Win32::System::Diagnostics::Debug::CONTE
     out
 }
 
+/// One thread dump at a time: two at once could each suspend the other's dumping thread, and
+/// neither went on (the lib tests hung).
+static DUMP_LOCK: Mutex<()> = Mutex::new(());
+/// The thread dumping now (0: none): the process ending on it dumps nothing more.
+static DUMP_OWNER: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0);
+
 /// `XCL_THREAD_DUMP_AT`: every other thread of the process stopped for a moment – where it is
 /// (RIP) and the calls on its stack that lead there, in the log.
 pub fn dump_threads() {
     use windows_sys::Win32::Foundation::{CloseHandle, INVALID_HANDLE_VALUE};
     use windows_sys::Win32::System::Diagnostics::Debug::{GetThreadContext, CONTEXT, CONTEXT_CONTROL_AMD64, CONTEXT_INTEGER_AMD64};
     use windows_sys::Win32::System::Diagnostics::ToolHelp::{CreateToolhelp32Snapshot, Thread32First, Thread32Next, TH32CS_SNAPTHREAD, THREADENTRY32};
     use windows_sys::Win32::System::Threading::{GetCurrentProcessId, GetCurrentThreadId, OpenThread, ResumeThread, SuspendThread, THREAD_GET_CONTEXT, THREAD_QUERY_INFORMATION, THREAD_SUSPEND_RESUME};
+    struct Owner;
+    impl Drop for Owner {
+        fn drop(&mut self) {
+            DUMP_OWNER.store(0, Ordering::Release);
+        }
+    }
     unsafe {
         let (pid, me) = (GetCurrentProcessId(), GetCurrentThreadId());
+        if DUMP_OWNER.load(Ordering::Acquire) == me {
+            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());

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.

<!-- greyfinch-sync:ivall/xcl:review-comment:4779452160 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3743#discussion_r4779452160). Originally posted by [vasanex](https://github.com/vasanex) on 2026-12-03T03:19:00Z. **Code review location:** `crates/xcl/src/eh.rs`; line 982 ~~~~diff @@ -932,15 +954,34 @@ unsafe fn unwind(ctx: &mut windows_sys::Win32::System::Diagnostics::Debug::CONTE out } +/// One thread dump at a time: two at once could each suspend the other's dumping thread, and +/// neither went on (the lib tests hung). +static DUMP_LOCK: Mutex<()> = Mutex::new(()); +/// The thread dumping now (0: none): the process ending on it dumps nothing more. +static DUMP_OWNER: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0); + /// `XCL_THREAD_DUMP_AT`: every other thread of the process stopped for a moment – where it is /// (RIP) and the calls on its stack that lead there, in the log. pub fn dump_threads() { use windows_sys::Win32::Foundation::{CloseHandle, INVALID_HANDLE_VALUE}; use windows_sys::Win32::System::Diagnostics::Debug::{GetThreadContext, CONTEXT, CONTEXT_CONTROL_AMD64, CONTEXT_INTEGER_AMD64}; use windows_sys::Win32::System::Diagnostics::ToolHelp::{CreateToolhelp32Snapshot, Thread32First, Thread32Next, TH32CS_SNAPTHREAD, THREADENTRY32}; use windows_sys::Win32::System::Threading::{GetCurrentProcessId, GetCurrentThreadId, OpenThread, ResumeThread, SuspendThread, THREAD_GET_CONTEXT, THREAD_QUERY_INFORMATION, THREAD_SUSPEND_RESUME}; + struct Owner; + impl Drop for Owner { + fn drop(&mut self) { + DUMP_OWNER.store(0, Ordering::Release); + } + } unsafe { let (pid, me) = (GetCurrentProcessId(), GetCurrentThreadId()); + if DUMP_OWNER.load(Ordering::Acquire) == me { + 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()); ~~~~ --- 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.
fromthemoonx commented 2026-12-03 03:36:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-03T03:36:02Z.


merge-check
base: 395405e4c0
head: 8646282168
merge: 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.

  1. The #3586 crash: thread_dumps_while_devices_come_and_go passed 22 of 22 runs. With only the DLL pin taken out it crashed in 8 of 24 (access violation).
  2. The process-end fix in this head: the_process_ends_while_another_thread_dumps passed 30 of 30. With the hook waiting for the lock again it failed 3 of 3. Without the in_code_arena check unwinding_goes_through_a_generated_thunk failed 5 of 5; with it, 30 of 30 pass. two_threads_dump_at_once: 30 of 30.
  3. The kernelx flake reproduces here when its tests run on their own (hle::kernelx::tests::, 60 runs per cell, base and merge alternating):
base merge
a_page_whose_move_fails_stays_mapped_where_it_was failed, 4 threads 5 0
the same, 8 threads 12 0
runs that failed for any reason, 4 threads 6 1
runs that failed for any reason, 8 threads 22 9

The 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 but gpu_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 a DllMain is not tested.
5) The uma_driver tests passed 10 of 10 runs and frame_clock 20 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)

<!-- greyfinch-sync:ivall/xcl:comment:7366737413 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3743#issuecomment-7366737413). Originally posted by [fromthemoonx](https://github.com/fromthemoonx) on 2026-12-03T03:36:02Z. --- merge-check base: 395405e4c0ed814afde0610a724dc96a3af329de head: 86462821686cc7830f8da54c4a5baf9ad327d3cd merge: 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. 1) The #3586 crash: `thread_dumps_while_devices_come_and_go` passed 22 of 22 runs. With only the DLL pin taken out it crashed in 8 of 24 (access violation). 2) The process-end fix in this head: `the_process_ends_while_another_thread_dumps` passed 30 of 30. With the hook waiting for the lock again it failed 3 of 3. Without the `in_code_arena` check `unwinding_goes_through_a_generated_thunk` failed 5 of 5; with it, 30 of 30 pass. `two_threads_dump_at_once`: 30 of 30. 3) The `kernelx` flake reproduces here when its tests run on their own (`hle::kernelx::tests::`, 60 runs per cell, base and merge alternating): | | base | merge | |---|---|---| | `a_page_whose_move_fails_stays_mapped_where_it_was` failed, 4 threads | 5 | **0** | | the same, 8 threads | 12 | **0** | | runs that failed for any reason, 4 threads | 6 | 1 | | runs that failed for any reason, 8 threads | 22 | 9 | The 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 but `gpu_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 a `DllMain` is not tested. 5) The `uma_driver` tests passed 10 of 10 runs and `frame_clock` 20 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)
throny commented 2026-12-03 06:07:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-03T06:07:21Z.


Merge check: safe (head 864628216, merged onto main 16c2fd082)

  • RTX 4080 (driver 621.40), i9-12900K, Windows 11 26300, release build
  • cargo test --workspace -- --test-threads=4: 3016 passed, 0 failed, 56 ignored; 25 SKIPPED lines, no test binary ended abnormally
  • retail title, 300 s world run: no device removal, no crash, first frame 7.59 s, 2.66 presents/s (same range as main's 2.88 on the run just before), 0 Aftermath dumps
  • diff read: the dump-time loader-lock risk looks low to me. #1671 appears to fix the same flake (#1487) and could close as superseded once this is in.

Not tested: AMD/Intel cards.

AI use: Claude Code (Claude Opus 5.5) ran the checks and wrote this comment.

<!-- greyfinch-sync:ivall/xcl:comment:7369478044 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3743#issuecomment-7369478044). Originally posted by [throny](https://github.com/throny) on 2026-12-03T06:07:21Z. --- **Merge check: safe** (head 864628216, merged onto main 16c2fd082) - RTX 4080 (driver 621.40), i9-12900K, Windows 11 26300, release build - `cargo test --workspace -- --test-threads=4`: 3016 passed, 0 failed, 56 ignored; 25 SKIPPED lines, no test binary ended abnormally - retail title, 300 s world run: no device removal, no crash, first frame 7.59 s, 2.66 presents/s (same range as main's 2.88 on the run just before), 0 Aftermath dumps - diff read: the dump-time loader-lock risk looks low to me. #1671 appears to fix the same flake (#1487) and could close as superseded once this is in. Not tested: AMD/Intel cards. AI use: Claude Code (Claude Opus 5.5) ran the checks and wrote this comment.
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
xcl-dev/xcl!3743
No description provided.