Repository navigation
Memory: crash reports list XCL's own last writes to the registers' pages - #3629
Royalflamejlh wants to merge 3 commits into
Conversation
|
Review (head b8e0e3e, diff read, not a merge-check; draft, checks red):
Fine: the record points sit right before the copies in AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
b8e0e3e to
666ed73
Compare
|
Thanks. Fixed at 666ed73: a write takes its slot only from an older one and not while another is being written there; ReadFile is recorded after the read, with the bytes read, for graphics memory only (ReadFileEx is no longer recorded, since its bytes are known only at completion); a page lists its newest 32 writes and counts the rest; each test has its own ring. The record re-timed at 70 ns on one thread, 19–25 ns with 8 (in the commit message). AI use: Claude Code (Claude Opus 5.5) made the fixes and wrote this reply. |
|
Follow-up review (head 666ed73, since b8e0e3e, diff read, not a merge-check; draft, checks red):
New:
AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
666ed73 to
53f2c1f
Compare
|
Fixed at 53f2c1f: the overlapped path records the bytes the read returned, and nothing for a failed or given-up read; the test covers both. The description is rewritten to match the commit (record points, costs, tests). The smoke blocks are for the previous head and run again for this one. AI use: Claude Code (Claude Opus 5.5) made the fixes and wrote this reply. |
|
Follow-up review (head 53f2c1f, since 666ed73, diff read, not a merge-check; draft, checks red):
New: none. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
53f2c1f to
f95a41f
Compare
|
Follow-up review (head f95a41f, since 53f2c1f, 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. |
gut0to
left a comment
There was a problem hiding this comment.
AI-assisted review (model: GPT-6). I traced the pending overlapped-read record through completion polling.
| return true; | ||
| } | ||
| if status == Some(0) { | ||
| crate::hle::write_log::record("ReadFile (overlapped)", p.at, (ov.add(1).read_volatile() as usize).min(p.len)); |
There was a problem hiding this comment.
Could this pending request be correlated with an operation generation instead of only the OVERLAPPED* address? The entry remains in PENDING until this poll. If the caller reuses a completed OVERLAPPED for another read first, this stale entry sees the new status and InternalHigh, then records the new byte count at the previous p.at, creating a false crash-report attribution. Could the old entry be removed or replaced when the pointer is reused, with a test that reuses one OVERLAPPED before take_finished? AI-assisted review (model: GPT-6); I traced the request identity from enqueue through completion.
There was a problem hiding this comment.
Right: a caller that reused a finished OVERLAPPED before the next look made the old entry read the new read's status and byte count. The ReadFile hook now calls file_reads::reusing(ov) before the call (vfs_hooks.rs). That takes any entry on that OVERLAPPED while it still holds the earlier read's result, so each read is logged at its own buffer with its own bytes. a_reused_overlapped_logs_each_read_at_its_own_buffer reuses one OVERLAPPED before take_finished. Without the fix the first buffer got the second read's 0x400 bytes; with it, 1 run each under Wine, it passed. Head 69ccace1.
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. |
f95a41f to
69ccace
Compare
|
Follow-up review of In short: The PR keeps XCL's last 16,384 writes into title memory in a lock-free ring and lists the ones on each register's 64 KiB page in the crash report. Since Medium
Nit
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>
A title can find its own heap overwritten (a pool block header holding float data) and fault long after the write. Nothing said whether XCL wrote there: page copies in kernelx, DirectStorage data, file reads into title buffers, texture downloads, sparse copies back and the writes made after the GPU all land in title memory without a trace. hle::write_log keeps the last 16 384 of them (start, length, reason, time, thread) in a ring without a lock, oldest overwritten first, and writers_of(start, len) gives the ones that overlap a range as lines, newest first, the newest 32 of them a line each and the rest counted. A write takes its slot only from an older one and not while another is written there, so a slot's fields are always one write's. Recorded: kernelx page maps, moves, copies home and the zeroing decommit in a committed window; DirectStorage writes (virtual, by page number, BCPack fills, the parallel path); ReadFile reads into graphics memory once they finish, with the bytes read (a failed one not at all; an overlapped one at the first look that finds it done, or when its OVERLAPPED is used for another read, while it still holds this one's result, or with the bytes asked for when the caller has reset it); title_textures' WriteProcessMemory runs; sparse copy_back pages and immediates; cpu_writes' labels, fences and 64-bit values; the frame index write. An unhandled exception now logs, for each 64 KiB page of title memory a register points into, the writes kept there. A record cost 70 ns on one thread under Wine, and 19-25 ns of wall time per record with 8 threads recording at once (2 M records, 3 runs); a query that matched all 16 384 kept writes 0.35-0.47 ms. It is on without a switch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
69ccace to
1057654
Compare
AI use: Claude Code (Claude Opus 5.5) made the changes and wrote this reply. |
|
Follow-up review of In short: This push fixes the reset- Checked and fine
Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point. |
(Edited: head
105765416: an overlapped ReadFile is logged before its OVERLAPPED is used for another read, while it still holds its own result, or with the bytes asked for when the caller has reset it (second reviews). Onmain38ad22d.)Stacked on #3628 (
xcl-run/crash-report-regions), itself on #3627; only the top commit belongs here.A title can find its own heap overwritten (a pool block header holding float data) and fault long after the write. Nothing said whether XCL wrote there: page copies in kernelx, DirectStorage data, file reads into title buffers, texture downloads, sparse copies back and the writes made after the GPU all land in the title's memory without a trace. XCL now keeps its last 16,384 such writes in a ring without a lock, and an unhandled exception lists the ones that overlap each 64 KiB page of title memory a register points into, newest first, with their reason, age and thread. It is on without a switch.
What is in it
hle/write_log.rs(new):record(why, start, len),overlapping,writers_of; oldest overwritten first. A write takes a slot only from an older one and not while another is written there, so a slot's fields are always one write's.writers_oflists the newest 32 writes per range and counts the rest.recordcalls where XCL writes title memory:kernelx.rs(page maps, moves, copies home, the zeroing decommit in a committed window, DirectStorage writes by page number),dstorage.rsanddstorage/parallel.rs,d3d12x/file_reads.rs(ReadFileinto graphics memory once it finishes, with the bytes read; an overlapped read that failed or was given up is not recorded),title_textures.rs(texture downloads),sparse.rs(copy back, immediates),cpu_writes.rs(labels, fences, 64-bit values),frame.rs(the frame index).eh.rs: the lines per register page in the crash report.Measured under Wine: a record cost 70 ns on one thread, and 19-25 ns of wall time per record with 8 threads recording at once (2 M records, 3 runs); a query that matched all 16,384 kept writes 0.35-0.47 ms.
Tested
105765416: Under Wine on Mesa's CPU Vulkan driver, release, 1 run:file_reads write_log window_stats11 passed, 0 failed;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.a_reused_overlapped_logs_each_read_at_its_own_bufferfailed without the fix.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).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 kernelx dstorage cpu_writes hle::d3d12x::frame eh:: write_log window_stats file_reads: 151 passed, 0 failed, 1 ignored in 2 of 3 runs; in the thirdframe::tests::origin_events_issue_tokens_and_flips_have_statisticsfailed once and passed on its own.write_logtests: overlap order, the ring keeping the last writes, a slot taken by a newer write or being written left alone, and a range listing its newest writes and counting the rest.file_reads::a_finished_read_is_a_known_writechecks the bytes recorded for a plain and an overlapped read, and that a failed overlapped read records nothing.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.