Repository navigation
xcl run: the crash report places every register in the title's memory - #3628
Royalflamejlh wants to merge 2 commits into
Conversation
|
Review (head 0a876d2, diff read, not a merge-check; draft, checks red): No problems found in the diff. Read the top commit AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
0a876d2 to
bc55ba1
Compare
|
Follow-up review (head bc55ba1, since 0a876d2, diff read, not a merge-check):
New: none. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
bc55ba1 to
67ac04a
Compare
|
Follow-up review (head 67ac04a, since bc55ba1, diff read, not a merge-check; checks red):
New: none. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
bmjask
left a comment
There was a problem hiding this comment.
Review of 67ac04a2: 2 finding(s) (2 medium), most severe first.
- Medium
crates/xcl/src/hle/d3d12x/window_stats.rs:216:log()(andon()at ~56) callcrate::gpu::uma::get(), which creates the UMA region on first call, instead ofuma::existing(), whose comment says "Observability must not allocate it."window_stats::start()runs inhost_mainbef.... (inline) - Medium
crates/xcl/src/hle/d3d12x/window_stats.rs:114: Not certain about this one:crash_partruns from the unhandled-exception filter and callsenabled()->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 }; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any. |
67ac04a to
371b0fe
Compare
|
Follow-up review of In short: Since Checked and fine
Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point. |
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>
371b0fe to
095fdc6
Compare
|
Follow-up review of In short: This push only rebases onto #3627's new commit. This PR's own commit is the same apart from context ( Checked and fine
Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point. |
(Edited: head
095fdc694:crash_partreadsXCL_WINDOW_STATSwithout a first read that could wait (second review), on #3627's fixes. Onmain38ad22d.)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_STATScounted 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) andmirrors::view_of(which view of a pair), both withtry_lock.hle/d3d12x/window_stats.rs:crash_part, the window's counters so far.Tested
095fdc694:cargo checkwith 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.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; 28SKIPPEDlines (wave64 tests: no wave64 on this card; heap-window tests withoutXCL_HEAP_WINDOWS=1; no D3D12 debug layer). The stack's GPU tests (gpu_mem_stats_*, the writer and geometry-pass tests) ran and passed.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 threekernelxtests 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 touchkernelx. 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.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:this PR's head:
Not tested
AI use
main.