Repository navigation
Conversation
The thread dump stops a thread only for its context (xcl-dev#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 changes the frames being read, RtlVirtualUnwind follows a stale saved register to a wild RSP and faults. In a retail title deep in its world the dump thread died that way 278 s into the run: unhandled 0xc0000005 in ntdll's unwinder (UWOP_PUSH_NONVOL with the context's RSP at 0x107, read at 0x107), thread 'xcl-thread-dump', and the title went with it. While the thread is stopped the dump now also copies its stack from RSP to the top the TEB names (up to 256 KiB, into a buffer allocated before any thread is stopped: plain reads, no lock, no allocation). The unwind reads only that copy: RSP and a frame's frame register are moved into it, and a frame whose unwind codes would reach outside it (a pushed, saved or allocated byte, or the return address) ends the list instead of being read. A thread whose RSP is outside its TEB's stack shows its RIP alone. Tests: the walk over a copy finds the callers RtlCaptureStackBackTrace finds on the live stack; a frame with RSP and the nonvolatile registers at 0x107 ends the walk (without the checks the test process dies with STATUS_ACCESS_VIOLATION); frame_reach on synthetic unwind data (pushes, small and large allocations, the frame register before and after the prologue sets it, chained data, unknown codes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested and reviewed commit Tested
Review notes
Not tested
AI use
|
…d codes Review notes on xcl-dev#2923: in chained unwind data the earlier part's UWOP_SAVE_NONVOL / SAVE_XMM128 offsets are relative to its own RSP, above what the later part pushed and allocated, so frame_reach adds that to them (the 64 KiB past the copy only cushioned it). A code whose slots run past the info's count, and UWOP_SET_FPREG with no frame register named, are not followed: the frame ends the walk. The frame_reach test covers all three with synthetic unwind data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pedrocalazans05
pushed a commit
to pedrocalazans05/xcl
that referenced
this pull request
Nov 27, 2026
…d codes Review notes on xcl-dev#2923: in chained unwind data the earlier part's UWOP_SAVE_NONVOL / SAVE_XMM128 offsets are relative to its own RSP, above what the later part pushed and allocated, so frame_reach adds that to them (the 64 KiB past the copy only cushioned it). A code whose slots run past the info's count, and UWOP_SET_FPREG with no frame register named, are not followed: the frame ends the walk. The frame_reach test covers all three with synthetic unwind data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Requested 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(kernelx: physical page homes in window 0 first, from the top, keeping 64 MB free (#2867) #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