Repository navigation
D3D12.X: end the title past the NtTerminateProcess hook - #3172
Closed
tiagonleal wants to merge 1 commit into
Closed
tiagonleal wants to merge 1 commit into
tiagonleal wants to merge 1 commit into
Conversation
end_title's 15 s watchdog promised that the process ends "whatever happens", but it called TerminateProcess, which runs XCL's own NtTerminateProcess hook with every other thread suspended. The hook formats and writes a "process ends" line (heap allocation, the log file mutex, then an echo to stderr through std's stderr lock), flushes the log and the two used-pipeline journals. A suspended thread holding the stderr lock, the log mutex or the heap lock blocks the watchdog forever. end_title's own final TerminateProcess had the same exposure. Observed once (release build, retail title, XCL_RUN_SECONDS=60): the title ended at 60.4 s, the hook's "process ends" line came from the watchdog exactly 15.0 s later (so the drain was stuck), and 20 minutes on the process was still alive with 145 threads Suspended: the kernel had never been asked to terminate. The file write had succeeded, so the block was after it (stderr echo, heap, or a flush). Both terminate calls now go through eh::terminate_unhooked, which calls the original NtTerminateProcess (no allocation, no lock). The journal flushes the hook did run before the threads are suspended; under suspension their writer thread could not complete them anyway. The test suspends a thread holding stderr with the hook installed: the child process ends with the code given; through the hook it hangs.
tiagonleal
force-pushed
the
d3d12x/end-watchdog-unhooked-terminate
branch
from
November 28, 2026 18:18
396b9ae to
2cc7279
Compare
5 tasks
Collaborator
|
Two contributors checked independently and found that #2698 solves the same problem in a different way: #1607, group D154. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table. |
Contributor
Author
|
Closing as a duplicate of #2698, which was merged last night. It makes the same change: the end-of-run watchdog now ends the process through
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A title run that ends through
end_title(for exampleXCL_RUN_SECONDS, whichscripts/smoke.ps1uses) can stay alive forever instead of ending. Seen once today in about 85 smoke runs: the title ended at 60.4 s, the log'sprocess endsline came exactly 15.0 s later, and 20 minutes on the process was still there, not responding, with 145 threads suspended.smoke.ps1did not get its block and the queue behind it stood still.end_titlestarts a watchdog that ends the process after 15 s "whatever happens", suspends every other thread, drains the GPU and terminates. Both terminate calls usedTerminateProcess, which runs XCL's ownNtTerminateProcesshook. With the other threads suspended, that hook formats and writes a log line (heap allocation, the log file mutex, an echo to stderr through std's stderr lock) and flushes the log. A suspended thread that holds one of those locks blocks the watchdog for good. The 15.0 s gap shows the watchdog was the caller (the drain was stuck), and 147 live threads show the kernel had not been asked to terminate yet. I found no issue or PR for this (searched "xcl-end-watchdog", "NtTerminateProcess hook", "process does not exit", "smoke.ps1 hangs").What is in it
eh.rs:terminate_unhooked(code)calls the originalNtTerminateProcess(orTerminateProcesswhen the hook is not installed). No allocation, no lock.real.rs:end_title's watchdog and its final terminate use it. The two used-pipeline journal flushes the hook did now run before the threads are suspended, next to the log flush that was already there; with their writer thread suspended they could only time out.process endsline. On theend_titlepath that line is gone.eh::tests::terminate_unhooked_ends_past_a_suspended_stderr_holder: a child process installs the hook, suspends a thread that holds the stderr lock and terminates. It must end with the given code within 20 s.Tested
TerminateProcess: 0 passed, 1 failed ("the process did not end within 20 s"). With the change: passes.cargo test -p xcl --lib eh:: -- --test-threads=2: 11 passed, 0 failed.cargo test -p xcl --test e2e -- --test-threads=1: 5 passed, 0 failed.cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4, one run on head2cc7279e: 2149 passed, 4 failed, 48 ignored (25SKIPPEDlines). The 4 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0to_3, which also fail onmainhere (10d27297: 2148 passed, 4 failed, 48 ignored; Recompiler: LDS ds_sub_u32 hides its negation from the driver (RTX 50 refuses it) #1919 fixes them).Regression run
scripts/smoke.ps1 -Seconds 60 -Title 9cc6a39e(Newer Retail Game), release builds in clean trees,main10d27297first, one run each,XCL_PREPARE=0, same DXIL cache. Both runs end throughend_title, so the PR's run also shows the changed path ending the process normally.main(10d27297):This PR (
2cc7279e):Not tested
used-pipelines.txt, because the journals are flushed slightly earlier.AI use
🤖 Generated with Claude Code