Crash diagnostics: thread dump at the unhandled exception; XCL_TRACE_ALLOC commit tracer #164

Open
github-bot wants to merge 2 commits from github-bot/gh-164 into main AGit
Owner

@⁠Sr-0w on GitHub · 2026-11-23 18:04 UTC · original
Sr-0w:crash-diagnostics → main · +164 −2 · 5 files · 2 commits · open

Summary

Two diagnostics that found the retail title issues fixed in #162 and #163:

  • Thread dump right at the unhandled exception (eh.rs). The retail title's Breakpad keeps the process alive after the crash, so the dump at process exit came late or never. Now the other threads are dumped once, right after report::write_final; that showed which thread the game's watchdog was waiting for.
  • XCL_TRACE_ALLOC=1 (new alloc_trace.rs): detours ntdll!NtAllocateVirtualMemory and counts every commit ≥ XCL_TRACE_ALLOC_MIN bytes (default 1 MiB) under its call stack. Every 15 s it logs the total, the bytes per owning module (first frame outside ntdll / CRT / kernel32 / d3d12), and the top 8 stacks. The detour runs inside heap allocations with the heap lock held, so it takes no lock and allocates nothing (a fixed 4096-slot table of atomics). A first version with a Mutex deadlocked the game. It is off by default and installs nothing then.

On the retail title before #162 it put 20+ GB of commit on amdxc64.dll pipeline compiles.

Test plan

  • cargo build --release
  • Retail title with XCL_TRACE_ALLOC=1: reports every 15 s, no deadlock, game unaffected
  • Retail title crash: thread dump (104 threads) logged right after the unhandled exception

🤖 Generated with Claude Code

**@⁠Sr-0w** on GitHub · 2026-11-23 18:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/164) `Sr-0w:crash-diagnostics` → `main` · +164 −2 · 5 files · 2 commits · open ## Summary Two diagnostics that found the retail title issues fixed in #162 and #163: - **Thread dump right at the unhandled exception** (`eh.rs`). The retail title's Breakpad keeps the process alive after the crash, so the dump at process exit came late or never. Now the other threads are dumped once, right after `report::write_final`; that showed which thread the game's watchdog was waiting for. - **`XCL_TRACE_ALLOC=1`** (new `alloc_trace.rs`): detours `ntdll!NtAllocateVirtualMemory` and counts every commit ≥ `XCL_TRACE_ALLOC_MIN` bytes (default 1 MiB) under its call stack. Every 15 s it logs the total, the bytes per owning module (first frame outside ntdll / CRT / kernel32 / d3d12), and the top 8 stacks. The detour runs inside heap allocations with the heap lock held, so it takes **no lock and allocates nothing** (a fixed 4096-slot table of atomics). A first version with a `Mutex` deadlocked the game. It is off by default and installs nothing then. On the retail title before #162 it put 20+ GB of commit on `amdxc64.dll` pipeline compiles. ## Test plan - [x] `cargo build --release` - [x] Retail title with `XCL_TRACE_ALLOC=1`: reports every 15 s, no deadlock, game unaffected - [x] Retail title crash: `thread dump (104 threads)` logged right after the unhandled exception 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A title crash handler (GTA VI's Breakpad) can keep the process alive for minutes after the
unhandled exception, so the thread dump at exit came late or never: the other threads are
now dumped once, right after the final report.

XCL_TRACE_ALLOC=1 detours ntdll!NtAllocateVirtualMemory and counts every commit of
XCL_TRACE_ALLOC_MIN bytes or more (default 1 MiB) under its call stack; every 15 s the stacks
and modules holding the most are logged. The detour runs inside heap allocations with the heap
lock held, so it takes no lock and allocates nothing (a fixed table of atomics). It showed
GTA VI's 20+ GB coming from amdxc64.dll's pipeline compiles.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Hundreds of early warnings used the 200 slots; the error before GTA VI's device removal
(CreateUnorderedAccessView of a resource without unordered access) was never logged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:13:14 +00:00
Author
Owner

@⁠Sr-0w on GitHub · 2026-11-23 19:19 UTC · original

New commit ce0cb0a: the D3D12 debug-layer relay logged only the first 200 messages, warnings included. The error just before GTA VI's device removal came after hundreds of early warnings and was never logged. Now: the first 200 warnings, and the first 20 errors of each message id.

🤖 Generated with Claude Code

**@⁠Sr-0w** on GitHub · 2026-11-23 19:19 UTC · [original](https://github.com/xcl-dev/xcl/pull/164#issuecomment-7111438450) New commit ce0cb0a: the D3D12 debug-layer relay logged only the first 200 messages, warnings included. The error just before GTA VI's device removal came after hundreds of early warnings and was never logged. Now: the first 200 warnings, and the first 20 errors **of each message id**. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

@⁠einfachama on GitHub · 2026-11-24 11:46 UTC · original

Test report for the commit tracer in #164 at my retail title's first menu, on NVIDIA Ada with 8 GB.

What I tested: 99db9be (thread dump + XCL_TRACE_ALLOC) merged onto main 64b3f35. The PR's second commit ce0cb0a conflicts with main in real.rs, and main already has its own per-id debug-layer cap there, so I kept main's side and did not test ce0cb0a. Local merge commit c5dc444.

Tested

  • NVIDIA GeForce RTX 4060 8 GB (Ada, 32-lane waves), driver 621.24; Ryzen 7 5800X; 32 GB RAM; Windows 11 Pro 26300; Rust 1.100.0 MSVC; DXC 1.9.2602.17; debug for the tests, release for the title runs.
  • cargo test --workspace -- --test-threads=4: 701 passed, 0 failed, 41 ignored, the same as main 64b3f35. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware. The PR adds no test.
  • My retail title, scripts/smoke.ps1 -Seconds 60, unattended (XCL_NETWORK=0), the learned window in both runs:
    • without XCL_TRACE_ALLOC: 1 607 frames, peak commit 14 447 MB, 0 crashes;
    • with XCL_TRACE_ALLOC=1: 1 610 frames, peak commit 14 580 MB, 0 crashes;
    • main 64b3f35 on the same machine: 1 609 and 1 614 frames, 14 575–14 578 MB.
      So the detour costs no frames here, and there was no deadlock.
  • What the tracer reports at the menu (identical at 15, 30, 45 and 60 s): 8.81 GB committed in blocks of 1024 KB or more, 42 call stacks; by module xcl.exe 8.72 GB, nvwgf2umx.dll 0.08 GB, MSTTSEngine_OneCore.dll 0.01 GB. The largest stack is one 4.00 GB block, the size of the coherent window; the next is 2.16 GB in 1 081 blocks.
  • What it does not see: the memory: line puts the process's commit at 14 580 MB at the same moment, so ~5.6 GB is not in the trace. That is about the size of local video memory then (6 142 MB: target pages 3 578, sparse pools 896, arenas 465). uma.rs notes that WDDM charges commit for each video-memory allocation; those charges don't go through NtAllocateVirtualMemory, so I'd expect the tracer to miss them. If that's right, the world-loading growth in #542 / #646, much of which is target pages and sparse pools, would show up only partly in the trace. I didn't check this past the menu.

Not tested

  • The thread dump at an unhandled exception (no crash happened at the menu).
  • ce0cb0a (see above). World loading: it runs this 32 GB machine out of memory, so I stopped at the menu.
  • AMD / Intel GPUs.

AI use

  • Claude Code with Claude Opus 5.5 ran the builds, tests and title runs in an unattended session and wrote this report from the logs; I checked it before posting.
**@⁠einfachama** on GitHub · 2026-11-24 11:46 UTC · [original](https://github.com/xcl-dev/xcl/pull/164#issuecomment-7130521020) Test report for the commit tracer in #164 at my retail title's first menu, on NVIDIA Ada with 8 GB. **What I tested:** `99db9be` (thread dump + `XCL_TRACE_ALLOC`) merged onto `main` `64b3f35`. The PR's second commit `ce0cb0a` conflicts with `main` in `real.rs`, and `main` already has its own per-id debug-layer cap there, so I kept `main`'s side and did not test `ce0cb0a`. Local merge commit `c5dc444`. **Tested** - NVIDIA GeForce RTX 4060 8 GB (Ada, 32-lane waves), driver 621.24; Ryzen 7 5800X; 32 GB RAM; Windows 11 Pro 26300; Rust 1.100.0 MSVC; DXC 1.9.2602.17; debug for the tests, release for the title runs. - `cargo test --workspace -- --test-threads=4`: **701 passed, 0 failed, 41 ignored**, the same as `main` `64b3f35`. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. The PR adds no test. - My retail title, `scripts/smoke.ps1 -Seconds 60`, unattended (`XCL_NETWORK=0`), the learned window in both runs: - without `XCL_TRACE_ALLOC`: 1 607 frames, peak commit 14 447 MB, 0 crashes; - with `XCL_TRACE_ALLOC=1`: 1 610 frames, peak commit 14 580 MB, 0 crashes; - `main` `64b3f35` on the same machine: 1 609 and 1 614 frames, 14 575–14 578 MB. So the detour costs no frames here, and there was no deadlock. - **What the tracer reports at the menu** (identical at 15, 30, 45 and 60 s): `8.81 GB committed in blocks of 1024 KB or more, 42 call stacks`; by module `xcl.exe 8.72 GB, nvwgf2umx.dll 0.08 GB, MSTTSEngine_OneCore.dll 0.01 GB`. The largest stack is one 4.00 GB block, the size of the coherent window; the next is 2.16 GB in 1 081 blocks. - **What it does not see:** the `memory:` line puts the process's commit at 14 580 MB at the same moment, so ~5.6 GB is not in the trace. That is about the size of local video memory then (6 142 MB: target pages 3 578, sparse pools 896, arenas 465). `uma.rs` notes that WDDM charges commit for each video-memory allocation; those charges don't go through `NtAllocateVirtualMemory`, so I'd expect the tracer to miss them. If that's right, the world-loading growth in #542 / #646, much of which is target pages and sparse pools, would show up only partly in the trace. I didn't check this past the menu. **Not tested** - The thread dump at an unhandled exception (no crash happened at the menu). - `ce0cb0a` (see above). World loading: it runs this 32 GB machine out of memory, so I stopped at the menu. - AMD / Intel GPUs. **AI use** - Claude Code with Claude Opus 5.5 ran the builds, tests and title runs in an unattended session and wrote this report from the logs; I checked it before posting.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 15:22 UTC · original

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-25 15:22 UTC · [original](https://github.com/xcl-dev/xcl/pull/164#issuecomment-7166738500) Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 02:46 UTC · original

Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-26 02:46 UTC · [original](https://github.com/xcl-dev/xcl/pull/164#issuecomment-7181100197) Re-verification on RTX 3060 Ti (Windows 11): still a **merge conflict with current `main`** on the new head — needs another rebase before it can be tested.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/hle/d3d12x/real.rs
  • crates/xcl/src/lib.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/164/head:github-bot/gh-164'
git switch 'github-bot/gh-164'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-164'
git switch 'github-bot/gh-164'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-164'
git switch 'github-bot/gh-164'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-164'
git switch 'main'
git merge --squash 'github-bot/gh-164'
git switch 'main'
git merge --ff-only 'github-bot/gh-164'
git switch 'main'
git merge 'github-bot/gh-164'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.