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 (ivall#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) |
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:
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