xcl run: the end of a run ends the process past XCL's own exit hook #2698
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2698
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2698"
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?
@Royalflamejlh on GitHub · 2026-11-26 06:58 UTC · original
Royalflamejlh:arch/end-title-watchdog→main· +53 −1 · 2 files · 1 commits · openThe end of a run (
XCL_RUN_SECONDS,real::end_title) no longer hangs when a suspended thread holds the process heap.end_titlesuspends the title's threads, signals the fences and drains the GPU; its 15 s watchdog is the last resort when that drain cannot finish ("a suspended thread may hold a lock the drain needs"). The watchdog ended the process withTerminateProcess, that is through XCL's ownNtTerminateProcesshook (eh.rs), which formats the stack and a log line, and so allocates, before the real call. In half the runs on one Linux machine of ours the watchdog waited there as well, and the process did not end. It now calls the realNtTerminateProcess. The drain itself can still wait for the held heap; such a run now ends at the watchdog's 15 s instead of never.Under Wine this shows as a run that does not exit:
err:sync:RtlpWaitForCriticalSection section … "dlls/ntdll/heap.c: main process heap section" wait timed out in thread …. In 6 runs on Linux (RTX 4070, Wine with vkd3d-proton) ofmainb49be18with #684 (alone, with #1599 or with #1790; 2 runs each), every run logged that wait in the thread that ranend_title. 3 were ended at 15 s by the watchdog, through the hook (process ends (thread …), that thread's only line). The other 3 logged a second wait, in a thread that had logged nothing, and had not exited a minute later, when the harness killed them. We take that thread to be the watchdog: after the suspension it is the only other thread still running.What is in it
crates/xcl/src/eh.rs:end_process_now, which ends the process through the realNtTerminateProcess. #967 adds the same function under the same name, for its crash watchdog. The two merge without a conflict but do not build together, so whichever goes in second drops its copy (and if that is this one, makes #967'spub(crate)).crates/xcl/src/hle/d3d12x/real.rs:end_title's watchdog calls it. An ending after a drain that finishes still goes through the hook. With #2635 in,used-pipelines.txtis still flushed beforeend_title(shutdown_used()inhost.rs); the watchdog's ending skips only the hook's bounded second flush.the_process_ends_while_another_thread_holds_the_heap: a child process with the crash handler installed, a thread holding the process heap (HeapLock), then the watchdog's ending; the parent waits 20 s for its exit code. The child first checks that the hook is installed and thatHeapLocksucceeded, then ends with status 7, so a child that returns normally, or that never held the heap, cannot pass. In the hook a non-zero status takes thedump_threadsbranch, whereend_title's 0 takes theprocess endsline; both allocate.Tested
88f29d1onmainb49be18.TerminateProcessthrough the hook): failed, the child had not ended after 20 s (the process did not end while another thread held the heap). On this branch it passes, with the other sixeh::tests.cargo test --workspace --no-fail-fast -- --test-threads=4: 1,436 passed, 0 failed, 47 ignored. 29 SKIPPED lines: 21 no wave64, 3 wave32 per-lane forms refused, 3 no D3D12 debug layer, 1 no heap windows, 1pso_measurement_compiles_an_exact_synthetic_record(the driver cache cannot be turned off without Windows Developer Mode).mainb49be18with #684 and #1599 merged in, 120 s a run, 4 runs each way, alternating; the first-run screens were completed once, no story progress. Without this change, all 4 runs logged the wait for the heap in the thread that ranend_title: 3 had not exited a minute after the end of the run and were killed, and 1 ended at the watchdog, through the hook. With it, 3 of 4 logged the same wait and ended 15 s after the end of the run, at the watchdog; the fourth, which met #751's read fault inmsvcrt.dllat 33.0 s, logged no wait and ended 10 s after, through the hook as before. Commits543756dand0108f24(the same with this change:0108f24has it as at95fc91c;88f29d1changes only the test).Regression run
main:
PR:
Not tested
blocked by …), but in 12 of the 13 runs here that logged the wait, it had logged nothing.AI use
`end_title` suspends the title's threads, drains the GPU and ends the process, with a watchdog that ends it within 15 s if the drain hangs: "a suspended thread may hold a lock the drain needs". The watchdog ended the process through `TerminateProcess`, so through XCL's `NtTerminateProcess` hook, which formats the stack and a log line first. When a suspended thread holds the process heap, the drain and then the watchdog both wait for it, and the process does not end. On Linux (Wine) the runs of today's trees log the drain's wait and, in about half of them, the watchdog's ("main process heap section wait timed out in thread …"), and then never exit. The watchdog now calls the real `NtTerminateProcess`. Co-Authored-By: Claude Opus 5.5 <[email protected]>@luckyteagirl on GitHub · 2026-11-26 07:00 UTC · original · reviewed
The child regression can report exit 7 without exercising the heap-held hook path.
install_crash_handler()logs a hook-install failure but returns normally, and the child ignoresHeapLock's BOOL before settingHELD. If the hook did not install,end_process_nowseesORIG_NT_TERMINATE == 0and itsTerminateProcessfallback can exit 7 through the normal unhooked path; if the heap lock failed, the old watchdog path would also lack the intended blocked-heap condition. The parent only checks exit 7, so either missing prerequisite can yield a green test.Could the child assert that
ORIG_NT_TERMINATEis nonzero after installation and thatHeapLocksucceeds before it signalsHELD? That would make the test fail visibly when the environment cannot exercise the regression. This is an exact-head source review of95fc91c3c9d46c06b15952ac4bd641db1cc83cf7; I did not inject either failure or rerun the test. AI-assisted review with Codex.95fc91c3c9to88f29d1836@Royalflamejlh on GitHub · 2026-11-26 07:40 UTC · original
@luckyteagirl yes: both could pass unseen. A hook that failed to install is only logged (
install_crash_handler), andend_process_nowthen falls back to a plainTerminateProcess. AHeapLockthat failed left nothing held. Either way the child still exited 7. In88f29d1the child asserts, before it ends, thatNtTerminateProcessis hooked and thatHeapLocksucceeded, so a missing prerequisite makes the child panic and exit 101, and the parent's check for 7 fails.TerminateProcessthrough the hook, the test failed after 20.0 s (the process did not end while another thread held the heap). The child, run with--nocapture, printed no failed assertion, so it got past both checks and then did not end. On88f29d1it passed, with the other sixeh::tests.88f29d1.AI use: Claude Code (Claude Opus 5.5) made the change, ran the tests and the smoke run, and wrote this reply.
Posted without review by a person: the account owner was away and reads replies later.
@sage-sage on GitHub · 2026-11-26 08:48 UTC · original
Test report: passes on NVIDIA. Exact head
88f29d18(its base is currentmainb49be18, so head = merged).Tested
cargo test --workspace -- --test-threads=4: 1436 passed, 0 failed, 47 ignored;the_process_ends_while_another_thread_holds_the_heappassesmainon this machine (wave64, debug layer, Developer Mode, heap windows)end_process_nowreduced to the oldTerminateProcesscall (local only): the new test fails after its 20 s (the process did not end while another thread held the heap), so it covers the fix.Not tested
XCL_RUN_SECONDS/ the end watchdog).Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
@Decodere on GitHub · 2026-11-26 09:05 UTC · original
Independent RTX 4060 (8 GB) / Windows 11 verification of PR #2698 at
88f29d183684c61f09b432e2c2650e2285b7cc8f(exact parentorigin/mainb49be1836844fe0b0cdb3211dce3cb7fb4e21ac7). Measurements and targeted test results only; not a full source review.Setup
7956 MiBreported by D3D12), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200rustc 1.100.0 (0ef1bc386 2026-11-09), DXC1.9.2609.5, release builds, warm DXIL/pipeline caches, quiet machine (zero concurrent builds/tests during timed runs)title: 29640639viascripts/smoke.ps1 -Seconds 60(XCL_NETWORK=0 XCL_ACTIVITY=1, default flags, no input)Targeted RTX 4060 release unit tests (
88f29d18)cargo test --release -p xcl --lib eh::tests::the_process_ends_while_another_thread_holds_the_heap -- --nocapture: 1 passed, 0 failed, 0 ignored (0.05 s, exit0). The spawned child process passed both release-buildassert_ne!(ORIG_NT_TERMINATE, 0)andHeapLock(GetProcessHeap()) != 0preconditions and terminated promptly with exit code7viaeh::end_process_now(7)while the background thread held the process heap lock.cargo test --release -p xcl --lib eh::tests:: -- --test-threads=4: 7 passed, 0 failed, 0 ignored (0.07 s, exit0).cargo test --release -p xcl --lib hle::d3d12x::real:: -- --test-threads=4: 60 passed, 0 failed, 0 ignored (0.65 s,0skipped, exit0).Observations
--release) on native Windows 1126200: the88f29d18child-process regression test passes withNtTerminateProcesshook verified installed (ORIG_NT_TERMINATE != 0) andHeapLockheld across threads, completing in0.05 s(well inside its 20 s watchdog bound).exit: 0x0,1574frames shown,60 60 60steady-state presents per 2 s,0device removals,0crashes,13987 MBpeak commit vs parentb49be183's14018 MB/1518frames).Paired 60 s RTX 4060 smoke (
b49be183vs88f29d18)Parent
origin/main(b49be183):PR #2698 head (
88f29d18):Limits of coverage
26200) only; Wine/LinuxNtTerminateProcesshook behavior was not tested on this host.end_titledrain rather than hitting the 15 s hung-drain watchdog timeout; the heap-lockedend_process_nowtermination path is exercised by the child-process release test (eh::tests::the_process_ends_while_another_thread_holds_the_heap).88f29d18(only targetedeh::tests::andhle::d3d12x::real::release tests plus paired quiet 60 s smoke).AI use
Ran the targeted release unit tests and paired quiet 60 s smoke runs with assistance from Google Antigravity (Gemini 4 Neon); all test counts and smoke blocks were taken directly from
cargo testandscripts/smoke.ps1outputs.@emirduran707 on GitHub · 2026-11-26 10:32 UTC · original
Independent AMD RDNA4 (native wave64) verification of exact PR head
88f29d183684c61f09b432e2c2650e2285b7cc8fon Windows 11 Pro 26300 (AMD Radeon RX 9060 XT 16 GB, driver32.0.31044.16, Ryzen 5 5600, Rust 1.100.0 MSVC, DXC1.9.2602.17).Tested
cargo build --workspace(debug): passed (0errors).cargo test --workspace --no-fail-fast -- --test-threads=4:1434 passed, 2 failed, 47 ignored(8 SKIPPED: 6 per-lane DXIL forms refused by host adapter/driver, 1heap_window_out_of_memory_falls_back_to_the_switch_formno heap windows, 1pso_measurement_compiles_an_exact_synthetic_recordWindows Developer Mode off).eh::tests::the_process_ends_while_another_thread_holds_the_heappassed.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1andfuzz_validate_and_gpu_3) are pre-existing on unmodifiedmainon this RX 9060 XT / driver32.0.31044.16.cargo build --release -p xcl+ 60 s retail-title smoke test (scripts/smoke.ps1, offline):(Compare against
mainb49be183on this machine:1603 frames, 18576 MB peak, 0 device removals, 0 crashes.)Not tested
AI use
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.