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

Closed
Sr-0w wants to merge 2 commits from upstream-pr/164 into main
Sr-0w commented 2026-11-23 18:04:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Sr-0w on 2026-11-23T18:04:11Z.


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

<!-- greyfinch-sync:ivall/xcl:issue:5458517613 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/164). Originally posted by [Sr-0w](https://github.com/Sr-0w) on 2026-11-23T18:04:11Z. --- ## 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)
Sr-0w commented 2026-11-24 07:04:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Sr-0w on 2026-11-23T19:19:42Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7111438450 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/164#issuecomment-7111438450). Originally posted by [Sr-0w](https://github.com/Sr-0w) on 2026-11-23T19:19:42Z. --- 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)
einfachama commented 2026-11-24 12:05:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by einfachama on 2026-11-24T11:46:04Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7130521020 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/164#issuecomment-7130521020). Originally posted by [einfachama](https://github.com/einfachama) on 2026-11-24T11:46:04Z. --- 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.
DavidM1911 commented 2026-11-25 16:12:10 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T15:22:20Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7166738500 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/164#issuecomment-7166738500). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T15:22:20Z. --- Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
DavidM1911 commented 2026-11-26 03:06:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T02:46:02Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7181100197 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/164#issuecomment-7181100197). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-26T02:46:02Z. --- 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.

Pull request closed

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!161
No description provided.