Skip to content

xcl run: the crash report places every register in the title's memory - #3628

Open
Royalflamejlh wants to merge 2 commits into
xcl-dev:mainfrom
Royalflamejlh:xcl-run/crash-report-regions
Open

Royalflamejlh wants to merge 2 commits into
xcl-dev:mainfrom
Royalflamejlh:xcl-run/crash-report-regions

Conversation

@Royalflamejlh

@Royalflamejlh Royalflamejlh commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

(Edited: head 095fdc694: crash_part reads XCL_WINDOW_STATS without a first read that could wait (second review), on #3627's fixes. On main 38ad22d.)

Stacked on #3627 (d3d12x/window-stats); only the top commit belongs here.

An unhandled exception logged the page events at the pages the registers point into, and only where there were some. A crash where a register held an address in a memory window with no page events (memory the title corrupted in a coherent window, say) said nothing about where that address lay. Now each register that points into a memory window (sparse, coherent, view), a view of a pair or a graphics reservation gets one line: the region, the 64 KiB page, its page events, and what XCL_WINDOW_STATS counted for its window when that is on. Other registers keep the line they had. Locks are only tried on this path, never waited for.

Related, not the same: #1186 names the Windows memory state and UMA window of the faulting address; #3027 dumps the memory around readable pointers. This one places every register in XCL's own regions.

What is in it

  • eh.rs: register_lines, the lines for the registers, with the region, page events and counters passed in, so it is tested without a crash; title_region.
  • hle/kernelx.rs: crash_region (graphics reservations) and mirrors::view_of (which view of a pair), both with try_lock.
  • hle/d3d12x/window_stats.rs: crash_part, the window's counters so far.

Tested

  • At 095fdc694: cargo check with and without --tests, no errors; Under Wine on Mesa's CPU Vulkan driver, release, 1 run: cargo test --lib -- window_stats file_reads write_log shader_mem console_heap eh:: at the top of the stack (D3D12.X: XCL_SHADER_MEM_STATS writes a placement table per allocation #3642, f1ae90ebb): 62 passed, 0 failed.
  • RTX 5070 Ti 16 GB (driver 621.24), Ryzen 7 9800X3D, Windows 11 Pro 26300, debug, at the top of this stack (D3D12.X: XCL_SHADER_MEM_STATS writes a placement table per allocation #3642, head 5653fd69, with an earlier version of this PR's commit, before the second review's fixes): cargo test --workspace -- --test-threads=4, 2,931 passed, 0 failed, 51 ignored, 1 run; 28 SKIPPED lines (wave64 tests: no wave64 on this card; heap-window tests without XCL_HEAP_WINDOWS=1; no D3D12 debug layer). The stack's GPU tests (gpu_mem_stats_*, the writer and geometry-pass tests) ran and passed.
  • RTX 4060 Ti 16 GB, NVIDIA 615.71.09, AMD Ryzen 9 9950X3D, Linux, Wine 11.21 Staging, Rust 1.98.0, x86_64-pc-windows-gnu, release. Tests under Wine on Mesa's CPU Vulkan driver (no card: the card was running a title).
  • cargo check -p xcl --release --target x86_64-pc-windows-gnu, with and without --tests: no errors, no new warnings.
  • cargo test -p xcl --release --target x86_64-pc-windows-gnu --lib -- --test-threads=8 window_stats eh:: kernelx: 89 passed, 0 failed, 1 ignored in 1 of 3 runs; 88 passed and 1 failed in the other 2. Over all runs here, one of three kernelx tests that share process-wide state (an_address_keeps_the_page_the_title_mapped_there_last, a_page_whose_move_fails_stays_mapped_where_it_was, gpu_visible_fallback_memory_is_write_watched) failed in some runs and passed in others; the same tests failed the same way on the branch below this one, which does not touch kernelx. The new test, registers_into_title_memory_get_a_line_each_page, checks the lines for registers in a window, in a view of a pair, outside with page events, and repeated or small values.
  • 2 title runs on our development tree with this in (705 s and 1,501 s) had no unhandled exception, so the new lines have not yet been seen at a real crash.

Regression run
RTX 2070 SUPER 8 GB (driver 621.01), Ryzen 7 5700X3D, Windows 11 Pro 26200, release builds by scripts/smoke.ps1, the same retail title for 60 s each.

main:

xcl-smoke v1
commit: 5eaadb54c14e0fc29597b2a1689d7dbd83491303
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 5330474d
seconds: 60
exit: 0x0
frames shown: 1575 (PresentX 1575)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15670 MB

this PR's head:

xcl-smoke v1
commit: 67ac04a23a28dc35c24bee96d696dedc9d295b22
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 5330474d
seconds: 60
exit: 0x0
frames shown: 1628 (PresentX 1628)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15221 MB

Not tested

  • AMD, a real crash with the new lines.

AI use

  • Claude Code, Claude Opus 5.5: wrote the change, its test and this description, and ported it to main.

@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:docs-ci Documentation, scripts, workflows, repo governance area:hle kernelx, XGameRuntime, XAudio2, VFS, PE loader, TLS, EH area:memory Virtual/physical memory, arenas, VRAM budget, UMA gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs-pr-check Failing the PR description check (CONTRIBUTING.md) labels Dec 2, 2026
@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Review (head 0a876d2, diff read, not a merge-check; draft, checks red):

No problems found in the diff. Read the top commit 0a876d26 only (register_lines, title_region in eh.rs, kernelx::crash_region, mirrors::view_of, window_stats::crash_part / totals_part) against gpu::uma's window lookup, the mirrors state layout and pagelog; the exception-filter path takes no blocking lock (try_lock only, window_of / window / kind are lock-free), view_of reads the (size, cpu) tuple the way source does, and the old page of line stays for registers outside title memory. The stack on #3627 is declared. Still owed: the xcl-smoke blocks (the reason PR description is red) and a whole-suite run on a GPU; the tests ran filtered under Wine only.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Follow-up review (head bc55ba1, since 0a876d2, diff read, not a merge-check):

  • No problems found earlier: still holds; the commit's own lines are unchanged in bc55ba1f, only the hunk context in window_stats.rs moved with D3D12.X: XCL_WINDOW_STATS logs each memory window's traffic #3627's given_in. The xcl-smoke blocks are now in (1669 vs 1620 frames, peak commit 110 %) and PR description passes; the whole suite has still not run on a GPU.

New: none.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Follow-up review (head 67ac04a, since bc55ba1, diff read, not a merge-check; checks red):

  • Earlier points: unchanged. git range-diff shows the own commit identical to the previous one; this push only rebases the stack onto the current main.

New: none.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of 67ac04a2: 2 finding(s) (2 medium), most severe first.

  1. Medium crates/xcl/src/hle/d3d12x/window_stats.rs:216: log() (and on() at ~56) call crate::gpu::uma::get(), which creates the UMA region on first call, instead of uma::existing(), whose comment says "Observability must not allocate it." window_stats::start() runs in host_main bef.... (inline)
  2. Medium crates/xcl/src/hle/d3d12x/window_stats.rs:114: Not certain about this one: crash_part runs from the unhandled-exception filter and calls enabled() -> seconds() -> OnceLock::get_or_init. (inline)

These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

}

fn log(now: &Totals, before: &Totals) {
let Some(u) = crate::gpu::uma::get() else { return };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: log() (and on() at ~56) call crate::gpu::uma::get(), which creates the UMA region on first call, instead of uma::existing(), whose comment says "Observability must not allocate it." window_stats::start() runs in host_main before preparation::before_guest, so with XCL_WINDOW_STATS=1 the stats thread wakes after 1 s while shader preparation is still running (which can take minutes) and calls uma::get(). That reserves the aperture and commits the coherent window (up to GBs of resident memory) on the stats thread long before the title would have, so a debug switch changes when and on which thread the title's memory is made. This comes from the stacked XCL_WINDOW_STATS commit. Note also that XCL_WINDOW_STATS=0 turns it on at 1 s (.max(1)) rather than off. Using existing() in log() and on() would fix it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right on both. log() and on() now take uma::existing(), so the stats thread never makes the UMA region, and XCL_WINDOW_STATS=0 is off (every in window_stats.rs; zero_seconds_is_off failed without it). The code is #3627's, so the fix is in its commit, 2580976a; this PR's head is 371b0fe2. The existing() change has no test: whether the region exists is process-wide, and the test process has already made it.

AI use: Claude Code (Claude Opus 5.5) made the fix and wrote this reply.

}

/// What the counters know of the window of `va`, for a crash report (empty: nothing counted).
pub fn crash_part(va: usize) -> String {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: Not certain about this one: crash_part runs from the unhandled-exception filter and calls enabled() -> seconds() -> OnceLock::get_or_init. If that OnceLock was never set, it reads the environment and calls xlog_info! inside the crash path, and it can block on a concurrent initializer, against the PR's "locks are only tried, never waited for". In an early crash, or a process that installed the filter but skips host_main's start(), the first enabled() runs inside the filter, and if another thread is inside get_or_init at that moment the crashing thread waits on it, so the report may never be written. Using OnceLock::get() there would avoid it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right: nothing made sure seconds() had been read before the filter ran. crash_part now reads the OnceLock with get() (SECONDS in window_stats.rs), so it neither initialises it nor waits on it; head 371b0fe2. In #3630, crash_part also no longer calls shader_mem::enabled() (another OnceLock): page_part already returns nothing while the buffer pointer is null. No test: one test cannot arrange a OnceLock that no other test has read.

AI use: Claude Code (Claude Opus 5.5) made the fix and wrote this reply.

@bmjask

bmjask commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.

@Royalflamejlh
Royalflamejlh force-pushed the xcl-run/crash-report-regions branch from 67ac04a to 371b0fe Compare December 2, 2026 20:46
@github-actions github-actions Bot added needs-pr-check Failing the PR description check (CONTRIBUTING.md) and removed needs-pr-check Failing the PR description check (CONTRIBUTING.md) labels Dec 2, 2026
@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Follow-up review of 371b0fe2, since 67ac04a2 (code reading only, not a merge-check; PR description red) · no new findings

In short: Since 67ac04a2 the PR's own commit has one change: crash_part reads XCL_WINDOW_STATS through SECONDS.get() and no longer calls enabled(), which could run the OnceLock initialiser inside the exception filter, wait on it and log from it. The rest of the push is #3627's commit underneath. The earlier reviews found nothing, and the new code adds no problem. The xcl-smoke block still names 67ac04a2, not this head (PR description is red), and the whole-suite GPU run is from an earlier head.

Checked and fine
  • The earlier reviews had no findings to fix.
  • crash_part (window_stats.rs ~123): SECONDS.get().is_some_and(Option::is_some) never starts the first read of the variable. If nothing has read it yet, the line gets no counters, which is right, since nothing was counted.
  • SECONDS moved from a local static to a module static. seconds() still sets it once and logs once.
  • The filter's path takes no lock it has to wait for. uma::existing() is GLOBAL.get(). mirrors::view_of, kernelx::crash_region and pagelog::describe use try_lock.
  • register_lines keeps the old page of line for registers outside title memory, and skips values below 0x1_0000 and repeated 64 KiB pages. registers_into_title_memory_get_a_line_each_page covers each case.
  • The stack on D3D12.X: XCL_WINDOW_STATS logs each memory window's traffic #3627 is declared, and this PR's first commit is D3D12.X: XCL_WINDOW_STATS logs each memory window's traffic #3627's head.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

Royalflamejlh and others added 2 commits December 2, 2026 14:26
An address the title gives the GPU outside every memory window is no GPU
memory, and nothing said so: with 4 windows the title's GPU views lay
outside them and the world's mesh programs read empty meshlet lists
(xcl-dev#3565). With XCL_WINDOW_STATS=<seconds>, every that many seconds:

- a line for each window: kind, range, bytes with memory on the GPU
  (tiles of a sparse or view window, the committed bytes of a coherent
  one), and since the line before the bytes uploaded into it, the pages
  the write watch found written, the bytes read back and the GPU-view
  tiles filled;
- a line with the addresses given outside every window, by
  view_want::Path, and the pages written outside them.

The first 8 addresses of each path outside every window are logged with
their size and what lies there (a GPU view of the title's memory, a
graphics reservation, plain memory, nothing committed). The counters are
relaxed atomics where the uploads, read-backs, write-watch looks, mirror
fills and view_want asks already happen; off, each is one load. Nothing
is remapped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An unhandled exception logged the page events at the pages the registers
point into, and only where there were some. A crash where a register held
an address in a memory window with no page events, the case of memory the
title corrupted in a coherent window, said nothing about where that
address lay.

Each register that points into a memory window (sparse, coherent, view), a
view of a pair or a graphics reservation now gets one line: the region, the
64 KiB page, its page events, and what XCL_WINDOW_STATS counted for its
window when it is on. Other registers keep the line they had. Locks are
only tried on this path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Royalflamejlh
Royalflamejlh force-pushed the xcl-run/crash-report-regions branch from 371b0fe to 095fdc6 Compare December 2, 2026 21:30
@github-actions github-actions Bot added needs-pr-check Failing the PR description check (CONTRIBUTING.md) and removed needs-pr-check Failing the PR description check (CONTRIBUTING.md) labels Dec 2, 2026
@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Follow-up review of 095fdc69, since 371b0fe2 (code reading only, not a merge-check; PR description red) · no new findings

In short: This push only rebases onto #3627's new commit. This PR's own commit is the same apart from context (git range-diff). Nothing new. The smoke block names 371b0fe2 (PR description is red).

Checked and fine
  • The earlier reviews found no problems, and the own commit is unchanged.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

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

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:docs-ci Documentation, scripts, workflows, repo governance area:hle kernelx, XGameRuntime, XAudio2, VFS, PE loader, TLS, EH area:memory Virtual/physical memory, arenas, VRAM budget, UMA gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs-pr-check Failing the PR description check (CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants