Skip to content

XCL_THREAD_DUMP_AT: a dump can fault in ntdll while unwinding a thread that was already resumed #2689

Not planned

Description

@xpatfussy69x

XCL_THREAD_DUMP_AT ended a run of the retail title with an access violation on the dump thread itself, at its third dump. #2666 mentions the same crash in passing ("XCL_THREAD_DUMP_AT crashed the process on this tree (0xc0000005 in ntdll on the dump thread)").

What happened

[210.055][23056][ERROR] unhandled exception 0xc0000005 in ntdll.dll+0x20191 (read at address 0xacf) rax=0x0 rbx=0x1 rcx=0x7ffddd9b0161 rdx=0x1467d61f4 rsi=0x2c3f348 rdi=0x1467d61f4 rbp=0x140000000 r8=0xffffffffffffff87 r9=0xac7 r10=0x6 r11=0x0 r12=0x18 r13=0x140000000 r14=0x2c3f410 r15=0x7ffddd990000 rsp=0x2c3f180
[211.269][23056][ERROR] process ends with status 0xc0000005 (thread 23056)

Thread 23056 is the dump thread (it wrote the two dumps before). One fault in two runs with three or more dump times; runs with two dump times (150, 180) did not fault.

Likely cause (from reading eh.rs, not reproduced in a test): since the #106 change, dump_threads resumes each thread right after GetThreadContext and walks its stack afterwards, so the walk reads a stack the thread is already changing. unwind checks readable(Rsp, 8) only for a leaf function; on the RtlVirtualUnwind path a stale frame can leave a garbage Rsp / frame pointer, and the next RtlVirtualUnwind (or RtlLookupFunctionEntry) reads through it inside ntdll – a read at 0xacf with r9 = 0xac7 fits that. A fault there is outside any handler and ends the title.

Possible directions (not tried)

Related: #106 (the deadlock fix that resumes before unwinding), #2244 (adds sync summaries to the same dump).

AI use

  • Claude Code (Claude Opus 5.5) made the runs on the machine above, read the log and eh.rs, and wrote this issue.

Activity

  1. Royalflamejlh commented on Nov 26, 2026

    @Royalflamejlh
    Contributor

    #253 (Kalmarv's, open and mergeable) is the second direction you list: dump_threads copies each thread's stack while it is stopped and unwinds the copy, not the live stack.

    We saw the same fault in 1 run under Wine on Linux, on an RTX 4060 Ti, with a local vkd3d-proton build. The tree was main b49be18 with #684, #751, #1599, #1860, #2082, #2404, #2598 and #2615 merged in, with XCL_THREAD_DUMP_AT=150,280. It came at 150.056 s, the first dump time, on the dump thread (xcl-thread-dump):

    [  150.056][  320][ERROR] unhandled exception 0xc0000005 in ntdll.dll+0x3dc1c (read at address 0x438) …
    

    In Wine's ntdll (11.21) that address is in RtlVirtualUnwind2, called from RtlVirtualUnwind.

    The 150 s dump was never written. The device was removed at 159.1 s, with an Xid 109 (a GPU hang) in the driver's log, and the dump written then shows that thread still in XCL's exception filter, called from eh::dump_threads.

    Not tested: #253 itself. It was not in this tree. Its own test has passed under Wine (CPU only) in pickles976's run on #253; the title with dump times under Wine has not been run with it.

    AI use: Claude Code (Claude Opus 5.5) made the run, read #253 and the run's log, and wrote this.

    Posted without review by a person: the account owner was away and reads replies later.

  2. Kalmarv commented on Nov 26, 2026

    @Kalmarv
    Contributor

    That second direction is #253 (head f67e35a): while the thread is stopped, dump_threads copies the stack from RSP to the end of its committed region, at most 256 KB, and unwinds the copy, so a thread that was resumed or has exited can no longer send RtlVirtualUnwind to a stale frame. Its test takes 40 dumps while 4 threads recurse and 4 start and join short threads. It passes natively on an RTX 5070 Ti and under Wine (pickles976, #253 (comment): 40 dumps, no exception).

    Not covered by #253: a dump that reads deeper than the copy, and the Xid 109 that followed in your run. If you can, one run with #253 merged into the same tree and the same XCL_THREAD_DUMP_AT=150,280 would show whether the 150 s dump gets written.

    AI use: Claude Code (Claude Opus 5.5) drafted this reply from #253's description and the linked reports.

  3. iggyvilla commented on Nov 26, 2026

    @iggyvilla
    Collaborator

    Open PR #253 (f67e35ae, copying each stopped thread's stack before resuming and unwinding) already fixes this race. Confirmed on AMD RDNA2 (RX 6650 XT) across both XCL_THREAD_DUMP_AT=150 and post-removal crash dumps (0/2 ntdll+0x1ff2a AVs with #253 vs 2/2 without it): #253 (comment)

    AI use: Antigravity, Gemini 4 Neon (High) drafted this pointer; retail runs by Claude Code (Claude Sonnet 5.5).

  4. xpatfussy69x commented on Nov 26, 2026

    @xpatfussy69x
    Author

    Closing as covered by #253, which copies each stopped thread's stack before unwinding (the second direction above). Thanks Royalflamejlh, Kalmarv and iggyvilla for pointing it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions