xcl run: XCL_THREAD_DUMP_AT unwinds a copy of each thread's stack #2923

Open
Prime1997 wants to merge 2 commits from upstream-pr/2923 into main
Prime1997 commented 2026-11-26 23:42:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Prime1997 on 2026-11-26T23:42:02Z.


Requested by Prime

XCL_THREAD_DUMP_AT stops 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, RtlVirtualUnwind follows 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+0x1ff2a or +0x20191, reads at 0x67, 0x107, 0x147, 0x100e8 and 0xa7d06d978. In the last one the title's own minidump names the faulting thread xcl-thread-dump, and the instruction is the unwinder's UWOP_PUSH_NONVOL with 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 (what RtlVirtualUnwind will 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), unwind over the copy (a caller's RSP must lie above its callee's), and dump_threads taking the copy.
  • crates/xcl/src/tls.rs: thread_teb (a thread's TEB from its handle, with the binding already there).
  • Second commit (review notes): in chained unwind data an earlier part's saves are shifted by what the later part pushed and allocated; a code whose slots run past the count, and UWOP_SET_FPREG with no frame register, end the walk. The frame_reach test covers the three.
  • Tests eh::tests::a_walk_over_the_copied_stack_finds_the_callers_windows_finds (the callers RtlCaptureStackBackTrace finds 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) and frame_reach_adds_up_a_frame_and_finds_its_frame_register (synthetic unwind data).

Tested

  • NVIDIA GeForce RTX 3060 Ti 8 GB (driver 32.0.16.1714), Intel Core i5-10400, Windows 11 26200, rustc 1.100.0; debug tests, release smoke.
  • cargo test --locked --workspace --no-fail-fast -- --test-threads=4 with XCL_DXC_DIR set to DXC 1.9.2609.5: 1825 passed, 9 failed, 48 ignored. The 9 failures are the same tests that fail on nvidia-dev eff3bcab itself (1822 passed, 9 failed, 48 ignored 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.
  • SKIPPED on this adapter: 28 (no wave64: 21, per-lane f16 form refused: 3, no dxc.exe: 1, no heap windows (opt-in: XCL_HEAP_WINDOWS=1): 1, cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depend: 1, no heap windows: 1).
  • GitHub's Build and test (Windows, no GPU) has failed on other pull requests against nvidia-dev (#2905, for one) on hle::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 on eff3bcab.

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):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 3060 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 363 (PresentX 363)
presents per 2 s (last 3): 16 17 16
device removals: 0
crashes: 0
peak commit: 15320 MB

The base of this PR, nvidia-dev eff3bcab:

xcl-smoke v1
commit: eff3bcabf1b6f99223796ece166948003a53e0bc
gpu: NVIDIA GeForce RTX 3060 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 1364 (PresentX 1364)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15372 MB

This PR's head:

xcl-smoke v1
commit: 1a061d4ce0d7dd829db497d5d8663c7e50fb9926
gpu: NVIDIA GeForce RTX 3060 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 1357 (PresentX 1357)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15334 MB

Not tested

  • The 60 s regression runs below do not set 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.
  • A thread on a stack its TEB does not name (a fiber switched without the TIB): its RIP alone is listed now. Frames past 256 KiB of a thread's stack are left out of its list.

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/6B4TykyC4W

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5518677134 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2923). Originally posted by [Prime1997](https://github.com/Prime1997) on 2026-11-26T23:42:02Z. --- <!-- claude-projects-attribution: {"github_login":"Prime1997"} --> _Requested by **Prime**_ `XCL_THREAD_DUMP_AT` stops 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, `RtlVirtualUnwind` follows 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+0x1ff2a` or `+0x20191`, reads at 0x67, 0x107, 0x147, 0x100e8 and 0xa7d06d978. In the last one the title's own minidump names the faulting thread `xcl-thread-dump`, and the instruction is the unwinder's `UWOP_PUSH_NONVOL` with 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` (what `RtlVirtualUnwind` will 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), `unwind` over the copy (a caller's RSP must lie above its callee's), and `dump_threads` taking the copy. - `crates/xcl/src/tls.rs`: `thread_teb` (a thread's TEB from its handle, with the binding already there). - Second commit (review notes): in chained unwind data an earlier part's saves are shifted by what the later part pushed and allocated; a code whose slots run past the count, and `UWOP_SET_FPREG` with no frame register, end the walk. The `frame_reach` test covers the three. - Tests `eh::tests::a_walk_over_the_copied_stack_finds_the_callers_windows_finds` (the callers `RtlCaptureStackBackTrace` finds 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) and `frame_reach_adds_up_a_frame_and_finds_its_frame_register` (synthetic unwind data). **Tested** - NVIDIA GeForce RTX 3060 Ti 8 GB (driver 32.0.16.1714), Intel Core i5-10400, Windows 11 26200, rustc 1.100.0; debug tests, release smoke. - `cargo test --locked --workspace --no-fail-fast -- --test-threads=4` with `XCL_DXC_DIR` set to DXC 1.9.2609.5: 1825 passed, 9 failed, 48 ignored. The 9 failures are the same tests that fail on `nvidia-dev` `eff3bcab` itself (`1822` passed, `9` failed, `48` ignored 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`. - SKIPPED on this adapter: 28 (no wave64: 21, per-lane f16 form refused: 3, no dxc.exe: 1, no heap windows (opt-in: XCL_HEAP_WINDOWS=1): 1, cannot disable the driver cache (Windows Developer Mode is required): The application requested an operation that depend: 1, no heap windows: 1). - GitHub's `Build and test (Windows, no GPU)` has failed on other pull requests against `nvidia-dev` (#2905, for one) on `hle::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 on `eff3bcab`. **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): ``` xcl-smoke v1 commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7 gpu: NVIDIA GeForce RTX 3060 Ti title: 419239bf seconds: 60 exit: 0x0 frames shown: 363 (PresentX 363) presents per 2 s (last 3): 16 17 16 device removals: 0 crashes: 0 peak commit: 15320 MB ``` The base of this PR, `nvidia-dev` `eff3bcab`: ``` xcl-smoke v1 commit: eff3bcabf1b6f99223796ece166948003a53e0bc gpu: NVIDIA GeForce RTX 3060 Ti title: 419239bf seconds: 60 exit: 0x0 frames shown: 1364 (PresentX 1364) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15372 MB ``` This PR's head: ``` xcl-smoke v1 commit: 1a061d4ce0d7dd829db497d5d8663c7e50fb9926 gpu: NVIDIA GeForce RTX 3060 Ti title: 419239bf seconds: 60 exit: 0x0 frames shown: 1357 (PresentX 1357) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15334 MB ``` **Not tested** - The 60 s regression runs below do not set `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. - A thread on a stack its TEB does not name (a fiber switched without the TIB): its RIP alone is listed now. Frames past 256 KiB of a thread's stack are left out of its list. **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/6B4TykyC4W 🤖 Generated with [Claude Code](https://claude.com/claude-code)
saintwolf commented 2026-11-27 00:04:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-27T00:04:50Z.


Tested and reviewed commit 143ddb11.

Tested

  • Hardware: NVIDIA GeForce RTX 4070 SUPER (12 GiB, driver 32.0.16.2140), AMD Ryzen 7 7800X3D, Windows 11 build 26300, rustc 1.100.0, debug test build
  • cargo test -p xcl --lib eh::tests:: -- --test-threads=1: 10 passed, 0 failed, 0 ignored, 0 skipped (including a_walk_over_the_copied_stack_finds_the_callers_windows_finds, a_walk_ends_at_a_frame_outside_the_copied_stack, and frame_reach_adds_up_a_frame_and_finds_its_frame_register)

Review notes

  • Clean, well-tested fix with zero new compiler warnings. Pre-allocating StackCopy before suspension and doing plain NT_TIB reads + copy_nonoverlapping while suspended preserves the lock-free suspension window (#106).
  • Minor non-blocking observations in frame_reach:
    • For chained unwind info (depth > 0), UWOP_SAVE_NONVOL / UWOP_SAVE_XMM128 offsets are relative to the parent's post-prologue RSP (current_rsp + child_frame_bytes), whereas saved = saved.max(offset + ...) omits the child's accumulated reach - 8 (small home-space offsets are cushioned by the 64 KiB trailing padding in StackCopy::new(), though adding the prior chain delta makes it exact).
    • Multi-slot unwind codes (slot(i + 1) / slot(i + 2)) assume i + 2 <= count / i + 3 <= count; a bounds check would guard against malformed unwind tables.
    • In UWOP_SET_FPREG, guarding reg & 15 != 0 avoids treating a malformed FrameRegister == 0 as RAX.

Not tested

  • Full workspace test suite or a live retail-title run with XCL_THREAD_DUMP_AT on this commit

AI use

  • Antigravity (exact model name not provided to the agent): reviewed the diff, ran the build/test command, and drafted this report (checked before posting).
<!-- greyfinch-sync:ivall/xcl:comment:7206152392 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2923#issuecomment-7206152392). Originally posted by [saintwolf](https://github.com/saintwolf) on 2026-11-27T00:04:50Z. --- Tested and reviewed commit `143ddb11`. **Tested** - Hardware: NVIDIA GeForce RTX 4070 SUPER (12 GiB, driver `32.0.16.2140`), AMD Ryzen 7 7800X3D, Windows 11 build 26300, `rustc 1.100.0`, debug test build - `cargo test -p xcl --lib eh::tests:: -- --test-threads=1`: **10 passed, 0 failed, 0 ignored, 0 skipped** (including `a_walk_over_the_copied_stack_finds_the_callers_windows_finds`, `a_walk_ends_at_a_frame_outside_the_copied_stack`, and `frame_reach_adds_up_a_frame_and_finds_its_frame_register`) **Review notes** - Clean, well-tested fix with zero new compiler warnings. Pre-allocating `StackCopy` before suspension and doing plain `NT_TIB` reads + `copy_nonoverlapping` while suspended preserves the lock-free suspension window (#106). - Minor non-blocking observations in `frame_reach`: - For chained unwind info (`depth > 0`), `UWOP_SAVE_NONVOL` / `UWOP_SAVE_XMM128` offsets are relative to the parent's post-prologue `RSP` (`current_rsp + child_frame_bytes`), whereas `saved = saved.max(offset + ...)` omits the child's accumulated `reach - 8` (small home-space offsets are cushioned by the 64 KiB trailing padding in `StackCopy::new()`, though adding the prior chain delta makes it exact). - Multi-slot unwind codes (`slot(i + 1)` / `slot(i + 2)`) assume `i + 2 <= count` / `i + 3 <= count`; a bounds check would guard against malformed unwind tables. - In `UWOP_SET_FPREG`, guarding `reg & 15 != 0` avoids treating a malformed `FrameRegister == 0` as `RAX`. **Not tested** - Full workspace test suite or a live retail-title run with `XCL_THREAD_DUMP_AT` on this commit **AI use** - Antigravity (exact model name not provided to the agent): reviewed the diff, ran the build/test command, and drafted this report (checked before posting).
luckyteagirl commented 2026-11-27 05:43:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-27T05:43:03Z.

Review: COMMENTED


frame_reach counts pushes, allocations and register saves that have yet to execute when RIP is in the prologue. Only UWOP_SET_FPREG checks the unwind-code offset against RIP. In an isolated Windows harness using the exact function from 1a061d4c, I put RIP at the start of a supported prologue that subtracts 72 bytes from RSP. frame_reach required 80 bytes. RtlVirtualUnwind recovered 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 procedure

AI 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.

<!-- greyfinch-sync:ivall/xcl:review:6083964018 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2923#pullrequestreview-6083964018). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-27T05:43:03Z. **Review:** COMMENTED --- `frame_reach` counts pushes, allocations and register saves that have yet to execute when RIP is in the prologue. Only `UWOP_SET_FPREG` checks the unwind-code offset against RIP. In an isolated Windows harness using the exact function from `1a061d4c`, I put RIP at the start of a supported prologue that subtracts 72 bytes from RSP. `frame_reach` required 80 bytes. `RtlVirtualUnwind` recovered 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](https://github.com/xcl-dev/xcl/blob/1a061d4ce0d7dd829db497d5d8663c7e50fb9926/crates/xcl/src/eh.rs#L826-L861) · [Windows unwind procedure](https://learn.microsoft.com/en-us/cpp/build/exception-handling-x64#unwind-procedure) AI 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.
Kalmarv commented 2026-11-29 22:38:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T22:38:27Z.


merge-check
base: beeb81be4b (checked against current main: merge conflicts)
head: 1a061d4ce0
merge: conflicts on current main (was clean on 765b2c5b / beeb81be)
build: cargo check -p xcl --all-targets -> ok (on beeb81be)
tests: non-GPU lib tests of touched modules (eh 14 passed, tls 4 passed / 1 ignored). Full workspace suite and GPU tests not run.
review: none blocking. Stack copy is allocated before thread suspension and bounded to [StackLimit, StackBase); unwind codes are bounds-checked and chained infos capped at depth 32. Diagnostic path only.
performance: none by default (runs only during thread dumps). Tested in a combined 600 s retail run on main beeb81be + 13 PRs (warm cache, defaults) vs baseline: presents/2 s 3.27 vs 3.29, peak commit 35,016 vs 35,767 MB, local video memory 14.19-14.76 vs 14.32-14.95 GB, 0 pipeline waits >= 1 s vs 5, 0 device removals, 0 crashes. Combined result across all 13 PRs, not isolated to this PR.
verdict: not yet: needs rebase onto current main; full workspace suite not run on its own merge.
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti, driver 32.0.16.1074, AMD Ryzen 9 9950X, Windows 11 Pro 26200 / Claude Code (claude-opus-5-5)

<!-- greyfinch-sync:ivall/xcl:comment:7263834144 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2923#issuecomment-7263834144). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-29T22:38:27Z. --- merge-check base: beeb81be4b7e96fce26a54615be9ee170474c19e (checked against current main: merge conflicts) head: 1a061d4ce0d7dd829db497d5d8663c7e50fb9926 merge: conflicts on current main (was clean on 765b2c5b / beeb81be) build: cargo check -p xcl --all-targets -> ok (on beeb81be) tests: non-GPU lib tests of touched modules (eh 14 passed, tls 4 passed / 1 ignored). Full workspace suite and GPU tests not run. review: none blocking. Stack copy is allocated before thread suspension and bounded to [StackLimit, StackBase); unwind codes are bounds-checked and chained infos capped at depth 32. Diagnostic path only. performance: none by default (runs only during thread dumps). Tested in a combined 600 s retail run on main beeb81be + 13 PRs (warm cache, defaults) vs baseline: presents/2 s 3.27 vs 3.29, peak commit 35,016 vs 35,767 MB, local video memory 14.19-14.76 vs 14.32-14.95 GB, 0 pipeline waits >= 1 s vs 5, 0 device removals, 0 crashes. Combined result across all 13 PRs, not isolated to this PR. verdict: not yet: needs rebase onto current main; full workspace suite not run on its own merge. hardware / tool and model: NVIDIA GeForce RTX 5070 Ti, driver 32.0.16.1074, AMD Ryzen 9 9950X, Windows 11 Pro 26200 / Claude Code (claude-opus-5-5)
bmjask commented 2026-11-29 22:46:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-11-29T22:46:02Z.

Review: COMMENTED


Critical review of current head 1a061d4c. The copied-stack design addresses the central race: unwinding a running thread's changing stack after suspension ends. The copy is allocated before suspension and the read is bounded by the captured stack range; I found no new code blocker in that diagnostic path. The PR currently conflicts with main, so it needs a rebase and focused unwind tests on the merge result, especially chained unwind info and a thread modifying its stack immediately after resume. This is off the normal frame path. No local Windows run.

<!-- greyfinch-sync:ivall/xcl:review:6105200913 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2923#pullrequestreview-6105200913). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-29T22:46:02Z. **Review:** COMMENTED --- Critical review of current head `1a061d4c`. The copied-stack design addresses the central race: unwinding a running thread's changing stack after suspension ends. The copy is allocated before suspension and the read is bounded by the captured stack range; I found no new code blocker in that diagnostic path. The PR currently conflicts with main, so it needs a rebase and focused unwind tests on the merge result, especially chained unwind info and a thread modifying its stack immediately after resume. This is off the normal frame path. No local Windows run.
Foniass commented 2026-12-01 06:01:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:01:29Z.


Review (head 1a061d4c, diff read, not a merge-check; draft and conflicting, so not built or run):

  • Superseded by main. f67e35ae ("xcl run: thread dumps unwind a copy of each stopped thread's stack", #253) does the same fix on main: it copies each stopped thread's stack and unwinds over the copy, reading it with VirtualQuery + ReadProcessMemory (which can't fault), with 64 KiB of slack and a stress test (thread_dumps_while_threads_run_and_exit). That commit is the conflict.
  • What this PR adds on top (frame_reach, the caller-RSP-above-callee check, stack bounds from the TEB) only matters on main for stacks deeper than 256 KiB, and no crash on main shows it's needed. Two small points about this version: StackCopy::take (eh.rs ~772-782) reads the TEB and the stack with plain reads, less safe than main's ReadProcessMemory if the thread has exited; and a thread on a stack its TEB doesn't name (a fiber) gets only its RIP.

Fine: the copy buffer is allocated before any thread is stopped, the frame_reach bounds checks work, and the tests are good. Recommendation: close as superseded by f67e35ae; if a dump still crashes on main, a small follow-up adding frame_reach to main's unwind would be the place for it.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7302391875 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2923#issuecomment-7302391875). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:01:29Z. --- Review (head 1a061d4c, diff read, not a merge-check; draft and conflicting, so not built or run): - **Superseded by main.** f67e35ae ("xcl run: thread dumps unwind a copy of each stopped thread's stack", #253) does the same fix on main: it copies each stopped thread's stack and unwinds over the copy, reading it with `VirtualQuery` + `ReadProcessMemory` (which can't fault), with 64 KiB of slack and a stress test (`thread_dumps_while_threads_run_and_exit`). That commit is the conflict. - What this PR adds on top (`frame_reach`, the caller-RSP-above-callee check, stack bounds from the TEB) only matters on main for stacks deeper than 256 KiB, and no crash on main shows it's needed. Two small points about this version: `StackCopy::take` (`eh.rs` ~772-782) reads the TEB and the stack with plain reads, less safe than main's `ReadProcessMemory` if the thread has exited; and a thread on a stack its TEB doesn't name (a fiber) gets only its RIP. Fine: the copy buffer is allocated before any thread is stopped, the `frame_reach` bounds checks work, and the tests are good. Recommendation: close as superseded by f67e35ae; if a dump still crashes on main, a small follow-up adding `frame_reach` to main's `unwind` would be the place for it. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2923:upstream-pr/2923'
git switch 'upstream-pr/2923'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2923'
git switch 'upstream-pr/2923'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2923'
git switch 'upstream-pr/2923'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2923'
git switch 'main'
git merge --squash 'upstream-pr/2923'
git switch 'main'
git merge --ff-only 'upstream-pr/2923'
git switch 'main'
git merge 'upstream-pr/2923'
git push origin 'main'
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!2923
No description provided.