Memory: crash reports list XCL's own last writes to the registers' pages #3629

Open
Royalflamejlh wants to merge 3 commits from upstream-pr/3629 into main
Royalflamejlh commented 2026-12-02 01:06:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T01:06:09Z.


(Edited: head 1890e2bf1, rebased with #3627's commit on main 395405e4c; this commit unchanged.)

(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). On main 38ad22da.)

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_of lists the newest 32 writes per range and counts the rest.
  • record calls 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.rs and dstorage/parallel.rs, d3d12x/file_reads.rs (ReadFile into 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

  • At 105765416: Under Wine on Mesa's CPU Vulkan driver, release, 1 run: file_reads write_log window_stats 11 passed, 0 failed; cargo test --lib -- window_stats file_reads write_log shader_mem console_heap eh:: at the top of the stack (#3642, f1ae90ebb): 62 passed, 0 failed. a_reused_overlapped_logs_each_read_at_its_own_buffer failed without the fix.
  • RTX 5070 Ti 16 GB (driver 621.24), Ryzen 7 9800X3D, Windows 11 Pro 26300, debug, at the top of this stack (#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).
  • 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 third frame::tests::origin_events_issue_tokens_and_flips_have_statistics failed once and passed on its own.
  • The four write_log tests: 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_write checks the bytes recorded for a plain and an overlapped read, and that a failed overlapped read records nothing.
  • 2 title runs on our development tree with an earlier version of this in (705 s and 1,501 s) had no unhandled exception, so the 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: 395405e4c0ed814afde0610a724dc96a3af329de
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 5330474d
seconds: 60
exit: 0x0
frames shown: 1522 (PresentX 1522)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 16017 MB

this PR's head:

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

Not tested

  • AMD, a real crash with the new lines, the record's cost on Windows.

AI use

  • Claude Code (Claude Opus 5.5): wrote the change, its tests and this description, measured the record's cost, and ported it to main.
<!-- greyfinch-sync:ivall/xcl:issue:5597694429 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3629). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-02T01:06:09Z. --- (Edited: head `1890e2bf1`, rebased with #3627's commit on `main` 395405e4c; this commit unchanged.) (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). On `main` 38ad22da.) 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_of` lists the newest 32 writes per range and counts the rest. - `record` calls 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.rs` and `dstorage/parallel.rs`, `d3d12x/file_reads.rs` (`ReadFile` into 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** - At `105765416`: Under Wine on Mesa's CPU Vulkan driver, release, 1 run: `file_reads write_log window_stats` 11 passed, 0 failed; `cargo test --lib -- window_stats file_reads write_log shader_mem console_heap eh::` at the top of the stack (#3642, `f1ae90ebb`): 62 passed, 0 failed. `a_reused_overlapped_logs_each_read_at_its_own_buffer` failed without the fix. - RTX 5070 Ti 16 GB (driver 621.24), Ryzen 7 9800X3D, Windows 11 Pro 26300, debug, at the top of this stack (#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). - `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 third `frame::tests::origin_events_issue_tokens_and_flips_have_statistics` failed once and passed on its own. - The four `write_log` tests: 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_write` checks the bytes recorded for a plain and an overlapped read, and that a failed overlapped read records nothing. - 2 title runs on our development tree with an earlier version of this in (705 s and 1,501 s) had no unhandled exception, so the 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: 395405e4c0ed814afde0610a724dc96a3af329de gpu: NVIDIA GeForce RTX 2070 SUPER title: 5330474d seconds: 60 exit: 0x0 frames shown: 1522 (PresentX 1522) presents per 2 s (last 3): 60 60 61 device removals: 0 crashes: 0 peak commit: 16017 MB ``` this PR's head: ``` xcl-smoke v1 commit: 1890e2bf19979a27f0361c86a7ab77996efa27b5 gpu: NVIDIA GeForce RTX 2070 SUPER title: 5330474d seconds: 60 exit: 0x0 frames shown: 1475 (PresentX 1475) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15348 MB ``` **Not tested** - AMD, a real crash with the new lines, the record's cost on Windows. **AI use** - Claude Code (Claude Opus 5.5): wrote the change, its tests and this description, measured the record's cost, and ported it to `main`.
Foniass commented 2026-12-02 01:12:23 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T01:12:23Z.


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

  • Two writers on one slot can tear why. record (hle/write_log.rs ~49-57) writes why and why_len as two relaxed stores guarded only by seq. If a writer is preempted after its fetch_add while 16,384 more records arrive, the writer that wraps onto the same slot publishes its seq, and the stalled writer's field stores land after it. A reader in overlapping (~86) can then see a matching seq with why from one write and why_len from the other and pass them to from_raw_parts + from_utf8_unchecked: UB inside the crash handler. Storing the reason as one word (an index into a reason table, or a &'static str pointer) removes the tear, and the writer should give up the slot if seq changed under it.
  • ReadFile is logged for every caller and before the read. The kernelbase ReadFile / ReadFileEx hooks (vfs_hooks.rs ~558, ~574) record every read in the process with the requested size before the call, so failed or short reads are logged as full writes, and reads into memory the report never queries (title_region covers only windows, pair views and graphics reservations) push out the title-memory writes the report is for. Recording after the read, with the bytes read and only for a title-region destination, avoids both.
  • No per-page limit in the crash report. eh.rs ~123 logs every kept write overlapping each register's 64 KiB page; labels, fences and the frame index are rewritten to the same few addresses, so one register can print up to 16,384 lines. A cap of a few dozen newest lines per page plus a count of the rest keeps it readable.
  • The two tests share the global ring. the_ring_keeps_the_last_writes (~124) records KEEP + 5 entries into the same static RING that writes_are_found_by_overlap_newest_first uses; run in parallel, it can push out first / second / beside before the other test asserts. Other tests that reach map_pages, write_physical_pages and the dstorage paths now record into it too.

Fine: the record points sit right before the copies in kernelx, dstorage, sparse, cpu_writes, frame and title_textures with the right addresses and lengths; the reader's seq / fence pattern is right with one writer per slot; the stack is declared. The xcl-smoke blocks are still owed (the reason PR description is red).

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

<!-- greyfinch-sync:ivall/xcl:comment:7331434048 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3629#issuecomment-7331434048). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T01:12:23Z. --- Review (head b8e0e3e6, diff read, not a merge-check; draft, checks red): - **Two writers on one slot can tear `why`.** `record` (`hle/write_log.rs` ~49-57) writes `why` and `why_len` as two relaxed stores guarded only by `seq`. If a writer is preempted after its `fetch_add` while 16,384 more records arrive, the writer that wraps onto the same slot publishes its `seq`, and the stalled writer's field stores land after it. A reader in `overlapping` (~86) can then see a matching `seq` with `why` from one write and `why_len` from the other and pass them to `from_raw_parts` + `from_utf8_unchecked`: UB inside the crash handler. Storing the reason as one word (an index into a reason table, or a `&'static str` pointer) removes the tear, and the writer should give up the slot if `seq` changed under it. - **`ReadFile` is logged for every caller and before the read.** The kernelbase `ReadFile` / `ReadFileEx` hooks (`vfs_hooks.rs` ~558, ~574) record every read in the process with the requested size before the call, so failed or short reads are logged as full writes, and reads into memory the report never queries (`title_region` covers only windows, pair views and graphics reservations) push out the title-memory writes the report is for. Recording after the read, with the bytes read and only for a title-region destination, avoids both. - **No per-page limit in the crash report.** `eh.rs` ~123 logs every kept write overlapping each register's 64 KiB page; labels, fences and the frame index are rewritten to the same few addresses, so one register can print up to 16,384 lines. A cap of a few dozen newest lines per page plus a count of the rest keeps it readable. - **The two tests share the global ring.** `the_ring_keeps_the_last_writes` (~124) records `KEEP + 5` entries into the same static `RING` that `writes_are_found_by_overlap_newest_first` uses; run in parallel, it can push out `first` / `second` / `beside` before the other test asserts. Other tests that reach `map_pages`, `write_physical_pages` and the `dstorage` paths now record into it too. Fine: the record points sit right before the copies in `kernelx`, `dstorage`, `sparse`, `cpu_writes`, `frame` and `title_textures` with the right addresses and lengths; the reader's `seq` / fence pattern is right with one writer per slot; the stack is declared. The `xcl-smoke` blocks are still owed (the reason `PR description` is red). AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Royalflamejlh commented 2026-12-02 02:55:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T02:55:49Z.


Thanks. Fixed at 666ed738e: 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.

<!-- greyfinch-sync:ivall/xcl:comment:7333345918 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3629#issuecomment-7333345918). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-02T02:55:49Z. --- Thanks. Fixed at 666ed738e: 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.
Foniass commented 2026-12-02 03:00:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T03:00:50Z.


Follow-up review (head 666ed738, since b8e0e3e6, diff read, not a merge-check; draft, checks red):

  • Torn why / why_len in the crash handler: fixed. Ring::write (hle/write_log.rs ~75-87) claims a slot with a compare_exchange to BUSY only if its seq is not newer than this write, so a stalled writer fails the exchange; the reader skips BUSY slots and rechecks seq after the acquire fence (~93-103). a_slot_taken_by_a_newer_write_or_being_written_is_left_alone covers both cases.
  • ReadFile logged for every caller and before the read: mostly fixed. The record moved to file_reads::returned (hle/d3d12x/file_reads.rs ~41): after the call, only for a destination in graphics memory, with the bytes read. The overlapped path (~60) still records the requested p.len, including a read that completed with an error or was dropped after GIVE_UP, and only at the next look that calls take_finished, so a crash before that look misses it. ReadFileEx is no longer recorded.
  • No per-page limit in the crash report: fixed. writers_of (~115) lists the newest 32 writes per page and then and N older writes, with a test.
  • Tests sharing the global ring: fixed; the write_log tests build their own Ring.

New:

  • The description no longer matches the commit. It still lists vfs_hooks.rs (ReadFile, ReadFileEx) as record points, gives the old costs (66 ns, 18 ns, 11 µs) where the commit message now says 70 ns, 19-25 ns and 0.35-0.47 ms, and says "the two new tests" (now four plus the file_reads assertion). The xcl-smoke blocks are still owed (the reason PR description is red).

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

<!-- greyfinch-sync:ivall/xcl:comment:7333433619 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3629#issuecomment-7333433619). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T03:00:50Z. --- Follow-up review (head 666ed738, since b8e0e3e6, diff read, not a merge-check; draft, checks red): - **Torn `why` / `why_len` in the crash handler:** fixed. `Ring::write` (`hle/write_log.rs` ~75-87) claims a slot with a `compare_exchange` to `BUSY` only if its `seq` is not newer than this write, so a stalled writer fails the exchange; the reader skips `BUSY` slots and rechecks `seq` after the acquire fence (~93-103). `a_slot_taken_by_a_newer_write_or_being_written_is_left_alone` covers both cases. - **`ReadFile` logged for every caller and before the read:** mostly fixed. The record moved to `file_reads::returned` (`hle/d3d12x/file_reads.rs` ~41): after the call, only for a destination in graphics memory, with the bytes read. The overlapped path (~60) still records the requested `p.len`, including a read that completed with an error or was dropped after `GIVE_UP`, and only at the next look that calls `take_finished`, so a crash before that look misses it. `ReadFileEx` is no longer recorded. - **No per-page limit in the crash report:** fixed. `writers_of` (~115) lists the newest 32 writes per page and then `and N older writes`, with a test. - **Tests sharing the global ring:** fixed; the `write_log` tests build their own `Ring`. New: - **The description no longer matches the commit.** It still lists `vfs_hooks.rs` (`ReadFile`, `ReadFileEx`) as record points, gives the old costs (66 ns, 18 ns, 11 µs) where the commit message now says 70 ns, 19-25 ns and 0.35-0.47 ms, and says "the two new tests" (now four plus the `file_reads` assertion). The `xcl-smoke` blocks are still owed (the reason `PR description` is red). AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Royalflamejlh commented 2026-12-02 03:36:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T03:36:41Z.


Fixed at 53f2c1fd: 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.

<!-- greyfinch-sync:ivall/xcl:comment:7334058681 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3629#issuecomment-7334058681). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-02T03:36:41Z. --- Fixed at 53f2c1fd: 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.
Foniass commented 2026-12-02 03:39:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T03:39:58Z.


Follow-up review (head 53f2c1fd, since 666ed738, diff read, not a merge-check; draft, checks red):

  • ReadFile (overlapped) recorded with the requested length, even on failure: fixed. take_finished (file_reads.rs ~56-62) now records only a read whose status is 0, with the bytes from InternalHigh capped at the request, and records nothing for a failed read or one dropped after GIVE_UP; the test covers a failed read and a short one (0x1800 of 0x2000).
  • Description out of date: unchanged; it still lists vfs_hooks.rs (ReadFile, ReadFileEx) and the old costs.

New: none.

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

<!-- greyfinch-sync:ivall/xcl:comment:7334114893 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3629#issuecomment-7334114893). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T03:39:58Z. --- Follow-up review (head 53f2c1fd, since 666ed738, diff read, not a merge-check; draft, checks red): - **`ReadFile` (overlapped) recorded with the requested length, even on failure:** fixed. `take_finished` (`file_reads.rs` ~56-62) now records only a read whose status is 0, with the bytes from `InternalHigh` capped at the request, and records nothing for a failed read or one dropped after `GIVE_UP`; the test covers a failed read and a short one (0x1800 of 0x2000). - **Description out of date:** unchanged; it still lists `vfs_hooks.rs` (`ReadFile`, `ReadFileEx`) and the old costs. New: none. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Foniass commented 2026-12-02 13:47:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T13:47:25Z.


Follow-up review (head f95a41f5, since 53f2c1fd, 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.

<!-- greyfinch-sync:ivall/xcl:comment:7347462737 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3629#issuecomment-7347462737). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T13:47:25Z. --- Follow-up review (head f95a41f5, since 53f2c1fd, 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.
gut0to commented 2026-12-02 16:34:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gut0to on 2026-12-02T16:34:47Z.

Code review location: crates/xcl/src/hle/d3d12x/file_reads.rs; line 62

@@ -52,10 +53,14 @@ pub unsafe fn take_finished() {
     }
     let mut g = PENDING.lock().unwrap();
     g.retain(|p| {
-        let pending = crate::gpu::shader::readable(p.overlapped, 8) && (p.overlapped as *const u64).read_volatile() == STATUS_PENDING;
-        if pending && p.since.elapsed() < GIVE_UP {
+        let ov = p.overlapped as *const u64;
+        let status = crate::gpu::shader::readable(p.overlapped, 16).then(|| ov.read_volatile());
+        if status == Some(STATUS_PENDING) && p.since.elapsed() < GIVE_UP {
             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));

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.

<!-- greyfinch-sync:ivall/xcl:review-comment:4772857225 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3629#discussion_r4772857225). Originally posted by [gut0to](https://github.com/gut0to) on 2026-12-02T16:34:47Z. **Code review location:** `crates/xcl/src/hle/d3d12x/file_reads.rs`; line 62 ~~~~diff @@ -52,10 +53,14 @@ pub unsafe fn take_finished() { } let mut g = PENDING.lock().unwrap(); g.retain(|p| { - let pending = crate::gpu::shader::readable(p.overlapped, 8) && (p.overlapped as *const u64).read_volatile() == STATUS_PENDING; - if pending && p.since.elapsed() < GIVE_UP { + let ov = p.overlapped as *const u64; + let status = crate::gpu::shader::readable(p.overlapped, 16).then(|| ov.read_volatile()); + if status == Some(STATUS_PENDING) && p.since.elapsed() < GIVE_UP { 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)); ~~~~ --- 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.
gut0to commented 2026-12-02 16:34:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gut0to on 2026-12-02T16:34:47Z.

Review: COMMENTED


AI-assisted review (model: GPT-6). I traced the pending overlapped-read record through completion polling.

<!-- greyfinch-sync:ivall/xcl:review:6155004513 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3629#pullrequestreview-6155004513). Originally posted by [gut0to](https://github.com/gut0to) on 2026-12-02T16:34:47Z. **Review:** COMMENTED --- AI-assisted review (model: GPT-6). I traced the pending overlapped-read record through completion polling.
bmjask commented 2026-12-02 16:46:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T16:46:58Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7352448555 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3629#issuecomment-7352448555). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T16:46:58Z. --- @Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
Royalflamejlh commented 2026-12-02 20:47:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T20:47:08Z.

Code review location: crates/xcl/src/hle/d3d12x/file_reads.rs; line 62

@@ -52,10 +53,14 @@ pub unsafe fn take_finished() {
     }
     let mut g = PENDING.lock().unwrap();
     g.retain(|p| {
-        let pending = crate::gpu::shader::readable(p.overlapped, 8) && (p.overlapped as *const u64).read_volatile() == STATUS_PENDING;
-        if pending && p.since.elapsed() < GIVE_UP {
+        let ov = p.overlapped as *const u64;
+        let status = crate::gpu::shader::readable(p.overlapped, 16).then(|| ov.read_volatile());
+        if status == Some(STATUS_PENDING) && p.since.elapsed() < GIVE_UP {
             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));

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.

<!-- greyfinch-sync:ivall/xcl:review-comment:4775812966 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3629#discussion_r4775812966). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-02T20:47:08Z. **Code review location:** `crates/xcl/src/hle/d3d12x/file_reads.rs`; line 62 ~~~~diff @@ -52,10 +53,14 @@ pub unsafe fn take_finished() { } let mut g = PENDING.lock().unwrap(); g.retain(|p| { - let pending = crate::gpu::shader::readable(p.overlapped, 8) && (p.overlapped as *const u64).read_volatile() == STATUS_PENDING; - if pending && p.since.elapsed() < GIVE_UP { + let ov = p.overlapped as *const u64; + let status = crate::gpu::shader::readable(p.overlapped, 16).then(|| ov.read_volatile()); + if status == Some(STATUS_PENDING) && p.since.elapsed() < GIVE_UP { 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)); ~~~~ --- 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.
Foniass commented 2026-12-02 20:56:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T20:56:33Z.


Follow-up review of 69ccace1, since f95a41f5 (code reading only, not a merge-check; PR description red) · 1 medium, 1 nit

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 f95a41f5 the only change to the PR's own commit is the overlapped ReadFile path: hk_read_file now calls file_reads::reusing before each ReadFile, so a pending read on the same OVERLAPPED is logged before the next one overwrites its result. Nothing blocks on correctness, but the new path drops the record when the caller has reset the OVERLAPPED. The xcl-smoke block still names f95a41f5, which is why PR description is red.

Medium

  1. A reset OVERLAPPED drops the earlier read from the log.

    • reusing (file_reads.rs ~49-58, called from vfs_hooks.rs ~559 before orig) reads Internal / InternalHigh after the caller has prepared the struct for the next read.
    • Many callers zero the whole OVERLAPPED before each request. finish (~77-78) then sees status 0 with InternalHigh 0 and records length 0, and Ring::record returns early. A read that landed in graphics memory is missing from the crash report.
    • The new test only covers a caller that leaves those fields alone.

    Fix: on the reuse path, record the requested p.len when the struct no longer holds a result, with a reason saying the length is not known, and add that case to a_reused_overlapped_logs_each_read_at_its_own_buffer. ReadFileEx and WriteFile on the same OVERLAPPED still log the other call's byte count through take_finished; at least say so in the module doc.

Nit

  1. Tested names an older commit. Tested says the full-suite run at #3642's 5653fd69 "carries this PR's commit unchanged". That head has no file_reads::reusing, so it carries the previous version.
Checked and fine
  • Earlier finding fixed: torn why / why_len in the crash handler. A slot is claimed with compare_exchange to BUSY, and the reader skips BUSY and rechecks seq (write_log.rs ~74-103).
  • Earlier finding fixed: ReadFile was logged for every caller and before the read. It is now recorded after the call, only for graphics memory, with the bytes read.
  • Earlier finding fixed: no per-page limit. writers_of lists the newest 32 and counts the rest, with a test.
  • Earlier finding fixed: tests shared the global ring. They now build their own Ring.
  • Earlier finding fixed: the description was out of date.
  • reusing takes only PENDING, in the same lock order as take_finished, and costs one atomic load when nothing is pending.
  • a_reused_overlapped_logs_each_read_at_its_own_buffer fails against the previous take_finished.
  • The PR's own commit is +285/-11, under the target; the rest of the 769 lines belongs to the stacked #3628 / #3627.

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

<!-- greyfinch-sync:ivall/xcl:comment:7358559480 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3629#issuecomment-7358559480). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T20:56:33Z. --- **Follow-up review** of `69ccace1`, since `f95a41f5` (code reading only, not a merge-check; `PR description` red) · 1 medium, 1 nit **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 `f95a41f5` the only change to the PR's own commit is the overlapped `ReadFile` path: `hk_read_file` now calls `file_reads::reusing` before each `ReadFile`, so a pending read on the same `OVERLAPPED` is logged before the next one overwrites its result. Nothing blocks on correctness, but the new path drops the record when the caller has reset the `OVERLAPPED`. The `xcl-smoke` block still names `f95a41f5`, which is why `PR description` is red. #### Medium 1. **A reset `OVERLAPPED` drops the earlier read from the log.** - `reusing` (`file_reads.rs` ~49-58, called from `vfs_hooks.rs` ~559 before `orig`) reads `Internal` / `InternalHigh` after the caller has prepared the struct for the next read. - Many callers zero the whole `OVERLAPPED` before each request. `finish` (~77-78) then sees status 0 with `InternalHigh` 0 and records length 0, and `Ring::record` returns early. A read that landed in graphics memory is missing from the crash report. - The new test only covers a caller that leaves those fields alone. Fix: on the reuse path, record the requested `p.len` when the struct no longer holds a result, with a reason saying the length is not known, and add that case to `a_reused_overlapped_logs_each_read_at_its_own_buffer`. `ReadFileEx` and `WriteFile` on the same `OVERLAPPED` still log the other call's byte count through `take_finished`; at least say so in the module doc. #### Nit 2. **Tested names an older commit.** **Tested** says the full-suite run at #3642's `5653fd69` "carries this PR's commit unchanged". That head has no `file_reads::reusing`, so it carries the previous version. <details><summary>Checked and fine</summary> - Earlier finding fixed: torn `why` / `why_len` in the crash handler. A slot is claimed with `compare_exchange` to `BUSY`, and the reader skips `BUSY` and rechecks `seq` (`write_log.rs` ~74-103). - Earlier finding fixed: `ReadFile` was logged for every caller and before the read. It is now recorded after the call, only for graphics memory, with the bytes read. - Earlier finding fixed: no per-page limit. `writers_of` lists the newest 32 and counts the rest, with a test. - Earlier finding fixed: tests shared the global ring. They now build their own `Ring`. - Earlier finding fixed: the description was out of date. - `reusing` takes only `PENDING`, in the same lock order as `take_finished`, and costs one atomic load when nothing is pending. - `a_reused_overlapped_logs_each_read_at_its_own_buffer` fails against the previous `take_finished`. - The PR's own commit is +285/-11, under the target; the rest of the 769 lines belongs to the stacked #3628 / #3627. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
Royalflamejlh commented 2026-12-02 21:32:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-12-02T21:32:29Z.


  1. Right: a caller that zeroes the OVERLAPPED before reusing it left status 0 and 0 bytes, so the read was dropped. Fixed at 10576541: on the reuse path, 0 bytes logs the length asked for, as ReadFile (overlapped; its OVERLAPPED was reset: the bytes asked for). a_reused_overlapped_logs_each_read_at_its_own_buffer now covers a reset OVERLAPPED too, and failed without the fix. The module doc says only ReadFile is followed, so a ReadFileEx or WriteFile on the same OVERLAPPED before the look gives the read its result.
  2. Tested now says that the run at 5653fd69 had an earlier version of this commit. A whole-suite run at the stack's new top is queued on Windows, and its counts go in when it ends.

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

<!-- greyfinch-sync:ivall/xcl:comment:7359425288 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3629#issuecomment-7359425288). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-12-02T21:32:29Z. --- 1. Right: a caller that zeroes the OVERLAPPED before reusing it left status 0 and 0 bytes, so the read was dropped. Fixed at `10576541`: on the reuse path, 0 bytes logs the length asked for, as `ReadFile (overlapped; its OVERLAPPED was reset: the bytes asked for)`. `a_reused_overlapped_logs_each_read_at_its_own_buffer` now covers a reset OVERLAPPED too, and failed without the fix. The module doc says only ReadFile is followed, so a ReadFileEx or WriteFile on the same OVERLAPPED before the look gives the read its result. 2. **Tested** now says that the run at `5653fd69` had an earlier version of this commit. A whole-suite run at the stack's new top is queued on Windows, and its counts go in when it ends. AI use: Claude Code (Claude Opus 5.5) made the changes and wrote this reply.
Foniass commented 2026-12-02 21:34:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T21:34:05Z.


Follow-up review of 10576541, since 69ccace1 (code reading only, not a merge-check; PR description red) · no new findings

In short: This push fixes the reset-OVERLAPPED point from my last review. When the earlier read's struct was reset before reuse (status 0, no byte count), the read is now logged with the bytes it asked for, under a reason that says so. The module doc now says that only ReadFile is followed. Tested now says which earlier version the GPU run was made on. The smoke block names f95a41f5 (PR description is red).

Checked and fine
  • Earlier finding fixed: a reset OVERLAPPED dropped the read from the log. finish now records p.len as "ReadFile (overlapped; its OVERLAPPED was reset: the bytes asked for)" when the read is done but the struct holds 0 bytes. a_reused_overlapped_logs_each_read_at_its_own_buffer covers it with a struct zeroed before reuse.
  • Earlier finding fixed: ReadFileEx / WriteFile on the same OVERLAPPED are now named in the module doc.
  • Earlier finding fixed: Tested said the GPU run carried this commit unchanged. It now says the run was on an earlier version.
  • The rest of the push is #3627 / #3628 underneath.

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

<!-- greyfinch-sync:ivall/xcl:comment:7359463459 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3629#issuecomment-7359463459). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T21:34:05Z. --- **Follow-up review** of `10576541`, since `69ccace1` (code reading only, not a merge-check; `PR description` red) · no new findings **In short:** This push fixes the reset-`OVERLAPPED` point from my last review. When the earlier read's struct was reset before reuse (status 0, no byte count), the read is now logged with the bytes it asked for, under a reason that says so. The module doc now says that only `ReadFile` is followed. **Tested** now says which earlier version the GPU run was made on. The smoke block names `f95a41f5` (`PR description` is red). <details><summary>Checked and fine</summary> - Earlier finding fixed: a reset `OVERLAPPED` dropped the read from the log. `finish` now records `p.len` as "ReadFile (overlapped; its OVERLAPPED was reset: the bytes asked for)" when the read is done but the struct holds 0 bytes. `a_reused_overlapped_logs_each_read_at_its_own_buffer` covers it with a struct zeroed before reuse. - Earlier finding fixed: `ReadFileEx` / `WriteFile` on the same `OVERLAPPED` are now named in the module doc. - Earlier finding fixed: **Tested** said the GPU run carried this commit unchanged. It now says the run was on an earlier version. - The rest of the push is #3627 / #3628 underneath. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
Foniass commented 2026-12-03 02:34:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T02:34:31Z.


Follow-up review of 1890e2bf, since 10576541 (code reading only, not a merge-check) · no new findings

In short: This push only rebases the stack onto main. This PR's own commit is identical (git range-diff); the only change underneath is #3627 following main's new UploadCopy jobs. Nothing new, and nothing blocks it.

Checked and fine
  • The own commit is unchanged since the last review.

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

<!-- greyfinch-sync:ivall/xcl:comment:7365618040 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3629#issuecomment-7365618040). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T02:34:31Z. --- **Follow-up review** of `1890e2bf`, since `10576541` (code reading only, not a merge-check) · no new findings **In short:** This push only rebases the stack onto `main`. This PR's own commit is identical (`git range-diff`); the only change underneath is #3627 following `main`'s new `UploadCopy` jobs. Nothing new, and nothing blocks it. <details><summary>Checked and fine</summary> - The own commit is unchanged since the last review. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3629:upstream-pr/3629'
git switch 'upstream-pr/3629'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3629'
git switch 'upstream-pr/3629'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3629'
git switch 'upstream-pr/3629'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3629'
git switch 'main'
git merge --squash 'upstream-pr/3629'
git switch 'main'
git merge --ff-only 'upstream-pr/3629'
git switch 'main'
git merge 'upstream-pr/3629'
git push origin 'main'
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!3629
No description provided.