xcl run: XCL_THREAD_DUMP_AT unwinds a copy of each thread's stack #2923
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!2923
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2923"
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?
@Prime1997 on GitHub · 2026-11-26 23:42 UTC · original
Prime1997:contrib/nv-thread-dump-stack-copy→nvidia-dev· +267 −8 · 2 files · 2 commits · draftRequested by Prime · project thread
XCL_THREAD_DUMP_ATstops each thread only to take its context (#106: the unwinder and the module lookup take locks the stopped thread may hold), then unwinds the stack of a thread that is running again. When that thread rewrites the frames being read,RtlVirtualUnwindfollows a stale saved value to a wild RSP and faults on the dump thread, and the title goes with it. The dump now also copies each thread's stack while the thread is stopped (from RSP to the top its TEB names, at most 256 KiB, into a buffer allocated before any thread is stopped) and unwinds over that copy only: a frame whose unwind data would reach outside the copy ends that thread's list instead of being read.Why
In five runs of a retail title on the card below, the dump thread died this way right at a dump (300, 300, 361, 400 and 795 s): unhandled 0xc0000005 at
ntdll.dll+0x1ff2aor+0x20191, reads at 0x67, 0x107, 0x147, 0x100e8 and 0xa7d06d978. In the last one the title's own minidump names the faulting threadxcl-thread-dump, and the instruction is the unwinder'sUWOP_PUSH_NONVOLwith the context's RSP at 0x107. The title itself was running in its world at the time.What is in it
crates/xcl/src/eh.rs:StackCopy(taken while the thread is suspended: plain reads of the TEB's stack bounds and of the stack, no lock, no allocation; RSP and a frame register are moved into it),frame_reach(whatRtlVirtualUnwindwill read for a frame: pushes, allocations, saved registers and the return address, from RSP or from the frame register once the prologue has set it, chained unwind data followed, unknown codes end the walk),unwindover the copy (a caller's RSP must lie above its callee's), anddump_threadstaking the copy.crates/xcl/src/tls.rs:thread_teb(a thread's TEB from its handle, with the binding already there).UWOP_SET_FPREGwith no frame register, end the walk. Theframe_reachtest covers the three.eh::tests::a_walk_over_the_copied_stack_finds_the_callers_windows_finds(the callersRtlCaptureStackBackTracefinds on the live stack),a_walk_ends_at_a_frame_outside_the_copied_stack(RSP and the nonvolatile registers at 0x107: without the checks the test process dies with STATUS_ACCESS_VIOLATION) andframe_reach_adds_up_a_frame_and_finds_its_frame_register(synthetic unwind data).Tested
cargo test --locked --workspace --no-fail-fast -- --test-threads=4withXCL_DXC_DIRset to DXC 1.9.2609.5: 1825 passed, 9 failed, 48 ignored. The 9 failures are the same tests that fail onnvidia-deveff3bcabitself (1822passed,9failed,48ignored there, same command):async_compute_pso_registers_real_pso_and_not_standin,console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly,gpu::recomp::tests::gpu_compute_thread_limits_leave_the_lanes_past_them_out,hle::d3d12x::texture_upload::tests::gpu_parts_of_a_texture_go_up_and_the_rest_stays,hle::d3d12x::texture_upload::tests::pieces_hold_the_texels_of_their_levels,split_compute_prefers_the_offline_whole_pipeline,two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs.Build and test (Windows, no GPU)has failed on other pull requests againstnvidia-dev(#2905, for one) onhle::d3d12x::sparse::tests::a_gpu_write_into_a_gpu_view_lands_in_its_cpu_view(the WARP device is removed, 0x887a0005). That test passes on the card above, on this branch and oneff3bcab.Regression run
A commit of
main(b49be183, the last one before the shader preparation screen of #2555, which prepares every record before the title and so does not fit a 60 s run):The base of this PR,
nvidia-deveff3bcab:This PR's head:
Not tested
XCL_THREAD_DUMP_AT; with this change the dump ran 15 times (every 20 s from 120 s) in a 420 s run of the same retail title in its world on the card above, with no crash; the five crashes above came from runs with 2 to 4 dumps.AI use
Claude Code (Claude Opus 5.5) wrote the code, ran the suite and the regression runs on the hardware above, and wrote this description; Prime asked for it and owns the account. We coordinate the 8 GB work on the XCL Discord too: https://discord.gg/gK3y7WRRY
🤖 Generated with Claude Code
@saintwolf on GitHub · 2026-11-27 00:04 UTC · original
Tested and reviewed commit
143ddb11.Tested
32.0.16.2140), AMD Ryzen 7 7800X3D, Windows 11 build 26300,rustc 1.100.0, debug test buildcargo test -p xcl --lib eh::tests:: -- --test-threads=1: 10 passed, 0 failed, 0 ignored, 0 skipped (includinga_walk_over_the_copied_stack_finds_the_callers_windows_finds,a_walk_ends_at_a_frame_outside_the_copied_stack, andframe_reach_adds_up_a_frame_and_finds_its_frame_register)Review notes
StackCopybefore suspension and doing plainNT_TIBreads +copy_nonoverlappingwhile suspended preserves the lock-free suspension window (#106).frame_reach:depth > 0),UWOP_SAVE_NONVOL/UWOP_SAVE_XMM128offsets are relative to the parent's post-prologueRSP(current_rsp + child_frame_bytes), whereassaved = saved.max(offset + ...)omits the child's accumulatedreach - 8(small home-space offsets are cushioned by the 64 KiB trailing padding inStackCopy::new(), though adding the prior chain delta makes it exact).slot(i + 1)/slot(i + 2)) assumei + 2 <= count/i + 3 <= count; a bounds check would guard against malformed unwind tables.UWOP_SET_FPREG, guardingreg & 15 != 0avoids treating a malformedFrameRegister == 0asRAX.Not tested
XCL_THREAD_DUMP_ATon this commitAI use
@luckyteagirl on GitHub · 2026-11-27 05:43 UTC · original · reviewed
frame_reachcounts pushes, allocations and register saves that have yet to execute when RIP is in the prologue. OnlyUWOP_SET_FPREGchecks the unwind-code offset against RIP. In an isolated Windows harness using the exact function from1a061d4c, I put RIP at the start of a supported prologue that subtracts 72 bytes from RSP.frame_reachrequired 80 bytes.RtlVirtualUnwindrecovered the correct caller and advanced RSP by 8 bytes. With a larger prologue allocation, the 256 KiB snapshot cap can make the walk stop even though all the bytes Windows needs are present. Could the reach calculation skip unwind operations whose prologue offsets are after the current RIP, with the existing early-offset fixture checking the reduced reach? Reach calculation · Windows unwind procedureAI use: OpenAI Codex (GPT-6.2 Sol) reviewed the source, ran the isolated CPU-only harness, and drafted this comment. No title or full suite was run.
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.