Repository navigation
Conversation
5c77a39 to
12328ac
Compare
|
Regression run wanted. We have no title on our machine. If you can run 🤖 Claude Opus 5.5 |
12328ac to
4d05d43
Compare
|
Test run of Tested
Review: Copying each stopped thread's stack (from Not tested: no retail title or regression run (I have no unpacked game), no Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code. |
|
@MesshM Thanks for the RDNA4 run. On the question: the unwind already moves those registers to the copy (
So the unwinder reads only the copy, plus a 64 KiB margin after it in the same buffer, never the stopped thread's live stack. What it doesn't fix up is a pointer to the stack that sits in memory outside the stack: an unwind of x64 code doesn't follow one. 🤖 Claude Opus 5.5 |
dump_threads resumed each thread right after GetThreadContext and only then unwound its stack, from the live memory: by then the thread had gone on (its saved registers and return addresses overwritten) or ended (its stack freed). RtlVirtualUnwind followed a stale frame register to a near-null address, or read a freed stack: an access violation in the dump thread (xcl-dev#106). While the thread is stopped, the dump now also copies its stack (from RSP, up to 256 KB, with system calls only); the unwinding reads the copy, with addresses into the stack moved to it, and stops where a frame would leave it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
4d05d43 to
f67e35a
Compare
|
Test report: thread dumps no longer crash the run (RTX 3060) Commit tested: this PR's head 4d05d43, against Tested
Not tested
AI use |
|
Regression run, as asked: this PR's head main this PR: No device removals or crashes; 99 % of main's frames, 111 % of its peak commit. The crash this PR fixes, reproduced on The same run on this PR's head: all 9 dumps were written (70 s to 105 s, 173–176 threads each), no fault in the unwinder. The run ended at 105 s in the title's own hang watchdog during world loading, which Not tested: the whole suite; AMD. Written with Claude Code (Claude Opus 5.5) from runs on this machine. |
|
@Natakout, @Anon64 thank you. These are the first runs of the case from the report: a title with AI use: Claude Code (Claude Opus 5.5) |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
While a thread is stopped the dump takes only its registers and a copy of its stack (system calls only: no heap, no Rust lock a stopped thread may hold). The thread then goes on (or ends) and the unwinding reads the copy, with addresses into the stack moved to it, ending where a frame would leave it. Linux adaptation (no dump_threads / XCL_THREAD_DUMP_AT / unwinder existed): the stop is a targeted SIGUSR2 whose handler parks the thread, the copy is pread from /proc/self/mem bounded by the mapping end in /proc/self/maps, and the unwind is a frame-pointer walk with a leaf fallback, all inside the copy. A short copy (neighbor munmap holes under churn) still unwinds the hottest frames. XCL_THREAD_DUMP_AT wired in host_linux.rs.
|
Independent Windows check of #253 head Tested
Not tested
AI use
|
Tested — Wine CPU-only follow-throughExact production head 1 passed, 0 failed, 0 ignored, 0.46s; fresh build15.81s. Log contains 40 actual dumps, 9–9 threads each, with multi-frame traces including kernel32/ntdll frames. No exception or timeout. Scope MemoryMax9GiB / MemorySwapMax512MiB, 180s timeout. Evidence This fills a focused Wine-test gap, not the title regression requirement. Our earlier title dump had a near-null Not testedRetail title with this PR, dump-at-crash timing, callback function tables, or the already-described deep-stack/large-frame read beyond the copy/slack. That known boundary gap remains; this pass is not a blanket unwind-safety claim. No GPU workload in this fixture, no frame-time/gameplay claim. The shared Wine prefix contains the lab's diagnostic-relaxed vkd3d build, but this test does not create a GPU device. AI use: omp, harness model |
|
Thanks @pickles976 for running this under Wine on AI use: Claude Code (Claude Opus 5.5) drafted this comment from the linked report. |
|
Test report on AMD RDNA2 (RX 6650 XT), including crash/removal-time thread dumps (two items under Not tested). Commit tested: Tested
Not tested
AI use
|
|
Thanks @iggyvilla: two runs with this PR and two without, on the same stack, is the comparison this needed. With it, both runs wrote the 150 s dump and the dump after the device removal (229 and 261 threads), with no access violation; without it, both crashed in AI use: Claude Code (Claude Opus 5.5) drafted this comment and the description update from the linked report. |
Refs #106 (the crash in
eh::dump_threads, withXCL_THREAD_DUMP_AT: an access violation inRtlVirtualUnwind2reading0xf8).dump_threadsresumed each thread right afterGetThreadContext, then unwound its stack from live memory. By that time the thread has either gone on, so the saved registers and return addresses are overwritten, or ended, so its stack is freed. A stale frame register sendsRtlVirtualUnwindto a near-null address: the report's read. The fault is insideRtlVirtualUnwind, so no check after the call can catch it. Now, while the thread is stopped, the dump also copies its stack, and the unwinding reads the copy.Seen in a run: a long run of a retail title on a local diagnostic build (
main'sdump_threadswith other local changes; this PR was not in it) crashed in ntdll's unwinder (ntdll+0x20047, a read at0xfb0, betweenRtlVirtualUnwind2andRtlVirtualUnwind) 75 ms into a thread dump the stalled-heartbeat check took, on the thread taking it. Its registers point into an Opus-decoding thread (MSOpusDecoder.dll), whichdump_threadshad already resumed when it unwound its stack. Two earlier long runs of builds with the samedump_threadstook 11 dumps each without a crash.What is in it
copy_stack: from RSP to the end of its committed region, at most 256 KB. It uses system calls only (VirtualQuery,ReadProcessMemory) into a buffer allocated before any thread is stopped, so it takes no lock the stopped thread may hold. If the copy fails, for example because the thread is exiting, that thread is left out, as whenGetThreadContextfails.unwindreads the copy:UNWIND_INFO), would leave the copy;unwindhas no other caller.Test
eh::tests::thread_dumps_while_threads_run_and_exit: 40 dumps, with 4 threads busy in a recursion whose frames keep changing and 4 threads starting and joining short-lived threads.Overlaps:
dump_threads()on an unhandled exception, so it gets this fix.eh.rsand merge with this without conflicts.Tested
cargo test --workspace -- --test-threads=4onf67e35a(this PR, rebased onto main930e8b4without conflicts; the same patch as4d05d43): 752 passed, 0 failed, 41 ignored (thexcllibrary: 708 passed, 21 ignored),eh::tests::thread_dumps_while_threads_run_and_exitamong them. SKIPPED GPU tests: 2, bothno wave64(gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware).4d05d43, on maindd2ae9a: 691 passed, 0 failed, 41 ignored, the same two SKIPPED.cargo test -p xcl --lib -- --exact eh::tests::thread_dumps_while_threads_run_and_exiton4d05d43, 3 runs: 3 of 3 passed (4.1–4.3 s).--exact, CPU only (no device), under a debugger that passes first-chance exceptions on and catches the second-chance one with its thread and stack. 20 runs each, interleaved:60565c4with the test added: 15 of 20 crashed, all fromeh::unwind←dump_threads. 4 were atntdll+0x1ff2ainRtlVirtualUnwind2, reading a near-null address: the instruction in the report. 11 were atntdll+0x1ff9f, reading other threads' stacks.60565c4; the same code as12328ac): 20 of 20 passed.RtlUserThreadStart.12328ac.scripts/test.ps1: 652 passed, 0 failed, 40 ignored; SKIPPED only the 2no wave64tests; the e2e test title test passed.XCL_THREAD_DUMP_AT, run by @Natakout (xcl run: thread dumps unwind a copy of each stopped thread's stack #253 (comment)): RTX 3060 12 GB (NVIDIA 621.14), Windows 11 25H2, release,4d05d43(the same patch as this head) and main47efa2e, dumps at 140, 170, 200, 230, 250 and 260 s. On main the run dies at 200.13 s on the dumping thread, during the third dump (0xc0000005inntdll.dll+0x79a67, a read at0x376). With this PR all six dumps are written (168–170 threads each).f67e35aand main930e8b4, a dump every 5 s from 70 s. On main the second dump (75.17 s) faults on the dumping thread inntdll.dll+0x20191(a read at0xffffffffffffffff) and the process hangs. With this PR all 9 dumps are written (70–105 s, 173–176 threads each). Their smoke pair of the same two commits: 1571 / 1585 frames (99 %), peak commit 22979 / 20665 MB (111 %), no crash or device removal.Regression run
Our own runs, one after the other on the machine under Tested (RTX 5070 Ti), release builds, no uncommitted changes:
mainat930e8b4(this PR's base), then this PR's head. 98 % ofmain's frames, 99 % of its peak commit.main:
PR:
Tested by others
eh::7 passed on mainb49be183+f67e35a; workspace: the only 2 failures (fuzz seed 783,e2e.rs:249) also fail on unmodified main. A retail title withXCL_THREAD_DUMP_AT=150plus the dump at device removal, on a local stack (08db802+ D3D12.X: a bind never builds a cold pipeline on the title's thread #2615, D3D12.X: ExecuteIndirect skips a stand-in whose build ends during the call #2598, D3D12.X: title texture reads outside the coherent window use the safe copy #751, D3D12.X: an ExecuteIndirect of a split program runs its pieces #2404): with this PR, 2 of 2 runs wrote both dumps (111-112 threads at 150 s, 229 and 261 threads after the removal) with 0 access violations; without it, 2 of 2 runs crashed inntdll+0x1ff2aduring the post-removal dump. Not covered by that run: standalone main, NVIDIA, Wine.eh::tests::thread_dumps_while_threads_run_and_exit1 passed, 40 dumps of 9 threads, no exception or timeout.Not tested
RtlInstallFunctionTableCallback.RtlVirtualUnwindreads that frame's return address before the bound check, so it could read past the buffer and its 64 KB slack.AI use
🤖 Generated with Claude Code