xcl run: dump the memory around an unhandled exception's pointers (XCL_FAULT_DUMP) #3027

Open
tiagonleal wants to merge 1 commit from upstream-pr/3027 into main
tiagonleal commented 2026-11-27 14:20:53 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-27T14:20:53Z.


Adds an opt-in switch, XCL_FAULT_DUMP=1. When the title raises an unhandled exception, XCL logs the memory around the faulting address and around each register that holds a readable pointer, after the existing unhandled exception line, its page of lines and the saved crash report. Off by default.

Part of #505

Why

Crash reports on the retail title of #505 and #2867 carry register values only. On my machine a lab version of this dump is what showed that the bad values are not random: in several crashes the faulting field sits inside a run of 64-byte records whose dwords at +0x18, +0x24, +0x30 and +0x3c hold 0x7fffffff triplets, written over live objects. That is not visible from registers. A second pattern it makes visible is a pointer whose upper 32 bits were overwritten: the title faults at the low half, and the dump shows the address it meant.

Rebased onto main 1c8b5514 (no conflicts; the earlier rebase onto d8bd9a38 had these:) Conflicts: the README list of switches, and eh.rs where main added the page of lines; the dump now runs after them.

What is in it

  • crates/xcl/src/eh/fault_dump.rs (new): candidate selection and formatting, both pure and tested through a reader closure.
    • Candidates, in this order: the faulting address; for a fault between 64 KiB and 4 GiB, the same low 32 bits under the upper half of each register that is a readable pointer (at most 4 that are readable); then the 16 general registers.
    • For each: 256 bytes before and after, as little-endian 32-bit words, 8 per line, the line with the pointer marked <==. A line already printed for an earlier pointer is not printed again; when that line holds a later pointer, a <address>: shown above <== line marks it under the later pointer's header, so every pointer has a marked line (review in this thread).
    • Memory is read with ReadProcessMemory on the own process, so a page another thread frees meanwhile gives unreadable, not a second fault.
    • Limits: 300 lines per fault, the first 2 faults of the process, one report at a time (try_lock): a fault while a report is being written gets none and does not count against the 2. The lock and the line sink are passed in (emit_one_at_a_time) so this path has a unit test.
  • crates/xcl/src/eh.rs: calls it after the existing line, the page lines, report::write_final and log::flush, so a dump that hangs on a corrupted heap cannot cost the crash report (review in this thread); the register copy is made only when the switch is on. The dump lines are error level, which flushes on every write.
  • README.md: the switch, next to XCL_DRED, with a note that the dump goes to xcl.log and can hold the title's stack and data.

One commit: the earlier three (first version, safe reads and order, dump after the crash report) are squashed into it, with a message that describes the final code.

Line format (fault dump: prefix, error level; the values here are made up to show the layout):

fault dump: fault under rbp's upper half=0x7a8adefa0
fault dump: 0x0007a8adef80: 00000000 00000000 a8adef98 00000007 a8adef98 00000000 00000000 00000000 <==
...
fault dump: rbp=0x7a8adef98
fault dump: 0x0007a8adef80: shown above <==

Tested

RTX 5070 Ti 16 GB (driver 617.42), Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro 26300, branch on main 06f90c19.

  • Head 9d86cd4f (one commit on main 1c8b5514, markers and lock test from this review), Rust 1.100.0, debug: cargo test -j 8 -p xcl --lib fault_dump: 12 passed, 0 failed (new: a_dump_while_another_is_written_is_skipped_and_not_counted; format_says_unreadable_and_skips_lines_already_shown now checks the shown above <== line). cargo test -p xcl --lib eh::: 26 passed.
  • Head 9d86cd4f, cargo test -j 8 --workspace --no-fail-fast -- --test-threads=4: 2921 passed, 0 failed, 51 ignored, 24 SKIPPED tests (22 no wave64, 2 no heap windows). A first run had 3 e2e failures because another job on this machine killed processes named xcl.exe; cargo test -p xcl --test e2e alone then passed 5 of 5, and the full rerun above is clean.
  • cargo test -j 6 -p xcl --lib fault_dump: 11 passed, 0 failed.
  • cargo test -j 6 --workspace --no-fail-fast -- --test-threads=4: 1465 passed, 4 failed, 47 ignored, 25 SKIPPED lines (no wave64 on this card; some f16/f32 per-lane forms refused).
  • The 4 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 (CreateComputePipelineState 0x8007000E). They fail the same way on main without this change.
  • After the rebase onto main d8bd9a38 (head dd6ea919): cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4, one run: 2625 passed, 4 failed, 49 ignored (26 SKIPPED lines). The 4 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3. The 4 are the fuzz_validate_and_gpu_* tests, which fail on main here too (#1919 fixes them); main's run had a fifth failure, the intermittent e2e check reported in #3382. On main d8bd9a38 on this machine the same command gave 2613 passed, 5 failed, 49 ignored (26 SKIPPED lines). The other results in this section are from the earlier heads named in them.
  • Head a5ac179b (rebased onto main 1c8b5514, dump moved after the crash report), Rust 1.100.0, debug: cargo test --workspace --no-fail-fast -- --test-threads=4: 2920 passed, 0 failed, 51 ignored, 24 SKIPPED tests (20 of them no wave64). The fuzz_validate_and_gpu_* failures above came from the old base and are gone with #1919 in main.

Regression run
scripts/smoke.ps1 -Seconds 60 -Title 9cc6a39e (Newer Retail Game), release builds of both commits in clean trees, main 1c8b5514 first, then this PR's head, one after the other. Both runs had XCL_PREPARE=0 and the same warm DXIL cache. On the head before this rebase, one run stopped after about 7 s with exit 0 and no crash or device removal; the head below ran its full 60 s on the first try.

main (1c8b5514):

xcl-smoke v1
commit: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1563 (PresentX 1563)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14842 MB

This PR (9d86cd4f):

xcl-smoke v1
commit: 9d86cd4fb0db5e318f16db1096a21220cc54fe98
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1684 (PresentX 1684)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 16816 MB

Not tested

  • The dump firing on a real crash with this exact code. The lab version that did fire on the retail title differs: it read registers inside one memory window only and had no rebasing rule.
  • AMD, Linux/Wine.
  • A fault while another thread is already inside the dump (the try_lock path) on a real crash; the unit test drives it with a lock held by another thread.

AI use

Claude Code with Claude Fable 5.2 and Anthropic subagents (Claude Opus 5.5, Claude Sonnet 5.5) helped developing with the supervision of @tiagonleal.

<!-- greyfinch-sync:ivall/xcl:issue:5528180784 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3027). Originally posted by [tiagonleal](https://github.com/tiagonleal) on 2026-11-27T14:20:53Z. --- Adds an opt-in switch, `XCL_FAULT_DUMP=1`. When the title raises an unhandled exception, XCL logs the memory around the faulting address and around each register that holds a readable pointer, after the existing `unhandled exception` line, its `page of` lines and the saved crash report. Off by default. Part of #505 **Why** Crash reports on the retail title of #505 and #2867 carry register values only. On my machine a lab version of this dump is what showed that the bad values are not random: in several crashes the faulting field sits inside a run of 64-byte records whose dwords at +0x18, +0x24, +0x30 and +0x3c hold `0x7fffffff` triplets, written over live objects. That is not visible from registers. A second pattern it makes visible is a pointer whose upper 32 bits were overwritten: the title faults at the low half, and the dump shows the address it meant. *Rebased onto `main` `1c8b5514`* (no conflicts; the earlier rebase onto `d8bd9a38` had these:) Conflicts: the README list of switches, and `eh.rs` where `main` added the `page of` lines; the dump now runs after them. **What is in it** - `crates/xcl/src/eh/fault_dump.rs` (new): candidate selection and formatting, both pure and tested through a reader closure. - Candidates, in this order: the faulting address; for a fault between 64 KiB and 4 GiB, the same low 32 bits under the upper half of each register that is a readable pointer (at most 4 that are readable); then the 16 general registers. - For each: 256 bytes before and after, as little-endian 32-bit words, 8 per line, the line with the pointer marked `<==`. A line already printed for an earlier pointer is not printed again; when that line holds a later pointer, a `<address>: shown above <==` line marks it under the later pointer's header, so every pointer has a marked line (review in this thread). - Memory is read with `ReadProcessMemory` on the own process, so a page another thread frees meanwhile gives `unreadable`, not a second fault. - Limits: 300 lines per fault, the first 2 faults of the process, one report at a time (`try_lock`): a fault while a report is being written gets none and does not count against the 2. The lock and the line sink are passed in (`emit_one_at_a_time`) so this path has a unit test. - `crates/xcl/src/eh.rs`: calls it after the existing line, the page lines, `report::write_final` and `log::flush`, so a dump that hangs on a corrupted heap cannot cost the crash report (review in this thread); the register copy is made only when the switch is on. The dump lines are error level, which flushes on every write. - `README.md`: the switch, next to `XCL_DRED`, with a note that the dump goes to `xcl.log` and can hold the title's stack and data. One commit: the earlier three (first version, safe reads and order, dump after the crash report) are squashed into it, with a message that describes the final code. Line format (`fault dump:` prefix, error level; the values here are made up to show the layout): ``` fault dump: fault under rbp's upper half=0x7a8adefa0 fault dump: 0x0007a8adef80: 00000000 00000000 a8adef98 00000007 a8adef98 00000000 00000000 00000000 <== ... fault dump: rbp=0x7a8adef98 fault dump: 0x0007a8adef80: shown above <== ``` **Tested** RTX 5070 Ti 16 GB (driver 617.42), Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro 26300, branch on `main` `06f90c19`. - Head `9d86cd4f` (one commit on `main` `1c8b5514`, markers and lock test from this review), Rust 1.100.0, debug: `cargo test -j 8 -p xcl --lib fault_dump`: 12 passed, 0 failed (new: `a_dump_while_another_is_written_is_skipped_and_not_counted`; `format_says_unreadable_and_skips_lines_already_shown` now checks the `shown above <==` line). `cargo test -p xcl --lib eh::`: 26 passed. - Head `9d86cd4f`, `cargo test -j 8 --workspace --no-fail-fast -- --test-threads=4`: 2921 passed, 0 failed, 51 ignored, 24 `SKIPPED` tests (22 no wave64, 2 no heap windows). A first run had 3 `e2e` failures because another job on this machine killed processes named `xcl.exe`; `cargo test -p xcl --test e2e` alone then passed 5 of 5, and the full rerun above is clean. - `cargo test -j 6 -p xcl --lib fault_dump`: 11 passed, 0 failed. - `cargo test -j 6 --workspace --no-fail-fast -- --test-threads=4`: 1465 passed, 4 failed, 47 ignored, 25 `SKIPPED` lines (no wave64 on this card; some f16/f32 per-lane forms refused). - The 4 failures are `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3` (`CreateComputePipelineState` `0x8007000E`). They fail the same way on `main` without this change. - After the rebase onto `main` `d8bd9a38` (head `dd6ea919`): `cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4`, one run: 2625 passed, 4 failed, 49 ignored (26 `SKIPPED` lines). The 4 failures are `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3`. The 4 are the `fuzz_validate_and_gpu_*` tests, which fail on `main` here too (#1919 fixes them); `main`'s run had a fifth failure, the intermittent e2e check reported in #3382. On `main` `d8bd9a38` on this machine the same command gave 2613 passed, 5 failed, 49 ignored (26 `SKIPPED` lines). The other results in this section are from the earlier heads named in them. - Head `a5ac179b` (rebased onto `main` `1c8b5514`, dump moved after the crash report), Rust 1.100.0, debug: `cargo test --workspace --no-fail-fast -- --test-threads=4`: 2920 passed, 0 failed, 51 ignored, 24 `SKIPPED` tests (20 of them no wave64). The `fuzz_validate_and_gpu_*` failures above came from the old base and are gone with #1919 in `main`. **Regression run** `scripts/smoke.ps1 -Seconds 60 -Title 9cc6a39e` (Newer Retail Game), release builds of both commits in clean trees, `main` `1c8b5514` first, then this PR's head, one after the other. Both runs had `XCL_PREPARE=0` and the same warm DXIL cache. On the head before this rebase, one run stopped after about 7 s with exit 0 and no crash or device removal; the head below ran its full 60 s on the first try. `main` (`1c8b5514`): ``` xcl-smoke v1 commit: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f gpu: NVIDIA GeForce RTX 5070 Ti title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1563 (PresentX 1563) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14842 MB ``` This PR (`9d86cd4f`): ``` xcl-smoke v1 commit: 9d86cd4fb0db5e318f16db1096a21220cc54fe98 gpu: NVIDIA GeForce RTX 5070 Ti title: 9cc6a39e seconds: 60 exit: 0x0 frames shown: 1684 (PresentX 1684) presents per 2 s (last 3): 60 60 61 device removals: 0 crashes: 0 peak commit: 16816 MB ``` **Not tested** - The dump firing on a real crash with this exact code. The lab version that did fire on the retail title differs: it read registers inside one memory window only and had no rebasing rule. - AMD, Linux/Wine. - A fault while another thread is already inside the dump (the `try_lock` path) on a real crash; the unit test drives it with a lock held by another thread. **AI use** Claude Code with Claude Fable 5.2 and Anthropic subagents (Claude Opus 5.5, Claude Sonnet 5.5) helped developing with the supervision of @tiagonleal.
Foniass commented 2026-12-01 09:22:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:22:18Z.


Triage (#1607) – head dd6ea91

No open or merged PR makes the same change (#1186 names the faulting address's memory state, not its contents). No problems found in the diff: the dump is opt-in, reads through ReadProcessMemory, is capped at 300 lines for the first 2 faults, and has unit tests for the candidate and format logic.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7306602725 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3027#issuecomment-7306602725). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T09:22:18Z. --- **Triage (#1607)** – head dd6ea91 No open or merged PR makes the same change (#1186 names the faulting address's memory state, not its contents). No problems found in the diff: the dump is opt-in, reads through ReadProcessMemory, is capped at 300 lines for the first 2 faults, and has unit tests for the candidate and format logic. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Foniass commented 2026-12-01 12:15:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T12:15:39Z.


merge-check
base: 493dbd3dd0
head: dd6ea9199a
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2911 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (+300). With XCL_FAULT_DUMP=1, the last-chance crash handler writes the memory around each register that points into readable memory. Findings: (1) The dump runs before the crash report is saved. eh.rs ~137 calls it ahead of report::write_final and log::flush (~138-139). If the crash came from heap corruption, the dump's allocations can hang on the broken heap and the main crash report is lost. Calling it after the flush avoids that. (2) It writes the stack and title memory into xcl.log, which people attach to issues; a line in the README saying the dump can contain the title's data would be fair. (3) When two registers point close together, the second one's <== marker is missing (fault_dump.rs format). Fine: off unless exactly 1, reads go through ReadProcessMemory so a bad pointer can't fault again inside the handler, and it runs from SetUnhandledExceptionFilter, not the early handlers that also see faults the title handles. It writes at most 300 lines for each of the first two faults (about 30 KB each), and the pure logic is tested. No smoke run: it only acts on a crash.
performance: no smoke run (the default path doesn't reach this change); not measured. Only runs on a crash with XCL_FAULT_DUMP=1.
verdict: safe to merge (off by default; calling the dump after report::write_final / log::flush would keep the crash report safe if the dump hangs on a corrupted heap)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7310878848 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3027#issuecomment-7310878848). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T12:15:39Z. --- merge-check base: 493dbd3dd0cd50b4c3e8d28f73ab9b504fcd8158 head: dd6ea9199a0568ea9e5be9afeb7495e272183fda merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2911 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none review: read the whole diff (+300). With `XCL_FAULT_DUMP=1`, the last-chance crash handler writes the memory around each register that points into readable memory. Findings: (1) **The dump runs before the crash report is saved.** `eh.rs` ~137 calls it ahead of `report::write_final` and `log::flush` (~138-139). If the crash came from heap corruption, the dump's allocations can hang on the broken heap and the main crash report is lost. Calling it after the flush avoids that. (2) It writes the stack and title memory into `xcl.log`, which people attach to issues; a line in the README saying the dump can contain the title's data would be fair. (3) When two registers point close together, the second one's `<==` marker is missing (`fault_dump.rs` `format`). Fine: off unless exactly `1`, reads go through `ReadProcessMemory` so a bad pointer can't fault again inside the handler, and it runs from `SetUnhandledExceptionFilter`, not the early handlers that also see faults the title handles. It writes at most 300 lines for each of the first two faults (about 30 KB each), and the pure logic is tested. No smoke run: it only acts on a crash. performance: no smoke run (the default path doesn't reach this change); not measured. Only runs on a crash with `XCL_FAULT_DUMP=1`. verdict: safe to merge (off by default; calling the dump after `report::write_final` / `log::flush` would keep the crash report safe if the dump hangs on a corrupted heap) hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 AI-written and posted by Foniass without a human check of each point.
tiagonleal commented 2026-12-02 10:13:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tiagonleal on 2026-12-02T10:13:07Z.


Moved the dump after write_final and the flush, so a dump that hangs cannot cost the crash report, and added a README sentence saying the dump goes to xcl.log with the title's stack and data. Rebased onto main 1c8b5514; the suite and both smoke runs are in the description.

  • Tiago
<!-- greyfinch-sync:ivall/xcl:comment:7342140702 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3027#issuecomment-7342140702). Originally posted by [tiagonleal](https://github.com/tiagonleal) on 2026-12-02T10:13:07Z. --- Moved the dump after `write_final` and the flush, so a dump that hangs cannot cost the crash report, and added a README sentence saying the dump goes to `xcl.log` with the title's stack and data. Rebased onto `main` 1c8b5514; the suite and both smoke runs are in the description. - Tiago
Foniass commented 2026-12-02 10:17:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T10:17:37Z.


Follow-up review (head a5ac179b, since dd6ea91, diff read, not a merge-check):

  • The dump ran before the crash report was saved: fixed. fault_dump::log now runs after report::write_final and log::flush (eh.rs ~137-140), so a dump that hangs on a broken heap no longer loses the report.
  • README should say the dump can hold the title's data: fixed (README.md ~405-406).
  • Second pointer's <== marker missing when two pointers are close: still open. A line already printed for an earlier pointer is skipped (eh/fault_dump.rs ~86-92), so the later pointer gets a header and no marked line, and the test (~264) now asserts that. Since the rebased fault comes first, the register that supplied its upper half usually loses its marker.
  • Triage (keep open): still holds; #3628 places registers in XCL's regions but dumps no memory (it touches the same eh.rs filter block, so whichever lands second rebases).

New:

  • Commits 2 and 3 are fixups of the first. 1f08d409 and a5ac179b rework code 6d51758b added: on its own 6d51758b checks memory with readable and then copies it with copy_nonoverlapping (a page freed in between faults inside the filter) and waits on LOCK.lock(), and its message still describes that. git bisect can land there; the three should be squashed with the final wording.
  • The try_lock path is untested. Not tested says the concurrent-fault path is untested "outside unit tests", but no test calls log (~135-150), the only place try_lock is used.

Fine: off unless XCL_FAULT_DUMP is exactly 1; reads go through ReadProcessMemory on the own process, so a bad pointer gives unreadable instead of a second fault; the dump's lock is a try_lock and the only blocking lock is the log file's, which the crash line already takes; capped at 300 lines for the first 2 faults; the selection and formatting are unit-tested.

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

<!-- greyfinch-sync:ivall/xcl:comment:7342253498 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3027#issuecomment-7342253498). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T10:17:37Z. --- Follow-up review (head a5ac179b, since dd6ea91, diff read, not a merge-check): - **The dump ran before the crash report was saved:** fixed. `fault_dump::log` now runs after `report::write_final` and `log::flush` (`eh.rs` ~137-140), so a dump that hangs on a broken heap no longer loses the report. - **README should say the dump can hold the title's data:** fixed (`README.md` ~405-406). - **Second pointer's `<==` marker missing when two pointers are close:** still open. A line already printed for an earlier pointer is skipped (`eh/fault_dump.rs` ~86-92), so the later pointer gets a header and no marked line, and the test (~264) now asserts that. Since the rebased fault comes first, the register that supplied its upper half usually loses its marker. - **Triage (keep open):** still holds; #3628 places registers in XCL's regions but dumps no memory (it touches the same `eh.rs` filter block, so whichever lands second rebases). New: - **Commits 2 and 3 are fixups of the first.** `1f08d409` and `a5ac179b` rework code `6d51758b` added: on its own `6d51758b` checks memory with `readable` and then copies it with `copy_nonoverlapping` (a page freed in between faults inside the filter) and waits on `LOCK.lock()`, and its message still describes that. `git bisect` can land there; the three should be squashed with the final wording. - **The `try_lock` path is untested.** **Not tested** says the concurrent-fault path is untested "outside unit tests", but no test calls `log` (~135-150), the only place `try_lock` is used. Fine: off unless `XCL_FAULT_DUMP` is exactly `1`; reads go through `ReadProcessMemory` on the own process, so a bad pointer gives `unreadable` instead of a second fault; the dump's lock is a `try_lock` and the only blocking lock is the log file's, which the crash line already takes; capped at 300 lines for the first 2 faults; the selection and formatting are unit-tested. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
tiagonleal commented 2026-12-02 15:23:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tiagonleal on 2026-12-02T15:23:20Z.


Thanks for the follow-up. All three are in the new head (9d86cd4f):

  • Missing <== for a close second pointer: when a pointer's own line was already printed for an earlier pointer, its header is now followed by one <address>: shown above <== line, so every pointer has a marked line and no memory is printed twice. The test now checks rbx gets that line and that there are two markers.

  • try_lock untested: log now hands its lock and a line sink to emit_one_at_a_time, and a_dump_while_another_is_written_is_skipped_and_not_counted holds the lock on one thread, calls it from another, and checks nothing is written and the fault is not counted. Once the lock is free the same call writes the dump.

  • Fixup commits: squashed into one commit whose message describes the final code (ReadProcessMemory reads, try_lock, dump after the crash report, the markers).

  • Tiago

<!-- greyfinch-sync:ivall/xcl:comment:7350238507 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3027#issuecomment-7350238507). Originally posted by [tiagonleal](https://github.com/tiagonleal) on 2026-12-02T15:23:20Z. --- Thanks for the follow-up. All three are in the new head (`9d86cd4f`): - **Missing `<==` for a close second pointer:** when a pointer's own line was already printed for an earlier pointer, its header is now followed by one `<address>: shown above <==` line, so every pointer has a marked line and no memory is printed twice. The test now checks rbx gets that line and that there are two markers. - **`try_lock` untested:** `log` now hands its lock and a line sink to `emit_one_at_a_time`, and `a_dump_while_another_is_written_is_skipped_and_not_counted` holds the lock on one thread, calls it from another, and checks nothing is written and the fault is not counted. Once the lock is free the same call writes the dump. - **Fixup commits:** squashed into one commit whose message describes the final code (ReadProcessMemory reads, `try_lock`, dump after the crash report, the markers). - Tiago
Foniass commented 2026-12-02 15:29:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T15:29:14Z.


Follow-up review (head 9d86cd4f, since a5ac179b, diff read, not a merge-check):

  • Commits 2 and 3 were fixups of the first: fixed; the PR is one commit with the final wording.
  • Second pointer's <== marker missing when two pointers are close: fixed. When a pointer's own line was already printed for an earlier one, a shown above <== line now marks it (eh/fault_dump.rs ~89-97).
  • The try_lock path untested: fixed by the commit's own account: the cap and the try_lock path take a reader and a lock and are unit-tested.

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:7350406817 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3027#issuecomment-7350406817). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T15:29:14Z. --- Follow-up review (head 9d86cd4f, since a5ac179b, diff read, not a merge-check): - **Commits 2 and 3 were fixups of the first:** fixed; the PR is one commit with the final wording. - **Second pointer's `<==` marker missing when two pointers are close:** fixed. When a pointer's own line was already printed for an earlier one, a `shown above <==` line now marks it (`eh/fault_dump.rs` ~89-97). - **The `try_lock` path untested:** fixed by the commit's own account: the cap and the `try_lock` path take a reader and a lock and are unit-tested. New: none. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
fromthemoonx commented 2026-12-03 12:42:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-03T12:42:58Z.


merge-check
base: a815de932c
head: 9d86cd4fb0
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3030 passed, 0 failed, 56 ignored; SKIPPED: 25, the same list as on main 395405e4 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps); failing: none. The 12 fault_dump tests are among the passed.
review: read the whole diff (3 files, +336). No blocking finding.

  1. The dump on a real crash, which the description lists as not tested. I gave the repository's test title a temporary fault (not part of this PR): it fills memory at 0x3554321000 with a known pattern, then reads through the pointer with its upper half lost (0x54321000). I ran it with xcl run, debug build of the merge onto 0c725d5d (main has only gained #3707 since, in gpu/dxil):
    • XCL_FAULT_DUMP=1: the crash line, then fault under rcx's upper half=0x3554321000 as the first entry with the right words and the <== mark, then the registers. 164 lines, written within about 10 ms of the crash line. report.json has the crash.
    • XCL_FAULT_DUMP=0: the same crash line and report, no dump line.
    • Four threads with the same fault at once: 4 crash lines, 2 dumps one after the other (the limit of 2), the crash in report.json, and the process ended by itself.
  2. The dump runs after write_final and the log flush, so a dump that fails cannot cost the report. Reads go through ReadProcessMemory, so memory freed meanwhile gives unreadable and no second fault.
  3. #3628 edits the same block of eh.rs (Foniass noted it too), so whichever lands second needs a rebase.
  4. Not tested: a crash in a retail title (none on this machine), a crash with a corrupted heap, AMD.
    performance: none by default (reasoned): the code runs only in the unhandled-exception filter, and without the switch it stops at one check.
    verdict: safe to merge
    hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)
<!-- greyfinch-sync:ivall/xcl:comment:7378727645 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3027#issuecomment-7378727645). Originally posted by [fromthemoonx](https://github.com/fromthemoonx) on 2026-12-03T12:42:58Z. --- merge-check base: a815de932c4dc8da3b383ca44f4b094aa406fec9 head: 9d86cd4fb0db5e318f16db1096a21220cc54fe98 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3030 passed, 0 failed, 56 ignored; SKIPPED: 25, the same list as on main 395405e4 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps); failing: none. The 12 `fault_dump` tests are among the passed. review: read the whole diff (3 files, +336). No blocking finding. 1) **The dump on a real crash**, which the description lists as not tested. I gave the repository's test title a temporary fault (not part of this PR): it fills memory at 0x3554321000 with a known pattern, then reads through the pointer with its upper half lost (0x54321000). I ran it with `xcl run`, debug build of the merge onto 0c725d5d (main has only gained #3707 since, in `gpu/dxil`): - `XCL_FAULT_DUMP=1`: the crash line, then `fault under rcx's upper half=0x3554321000` as the first entry with the right words and the `<==` mark, then the registers. 164 lines, written within about 10 ms of the crash line. `report.json` has the crash. - `XCL_FAULT_DUMP=0`: the same crash line and report, no dump line. - Four threads with the same fault at once: 4 crash lines, 2 dumps one after the other (the limit of 2), the crash in `report.json`, and the process ended by itself. 2) The dump runs after `write_final` and the log flush, so a dump that fails cannot cost the report. Reads go through `ReadProcessMemory`, so memory freed meanwhile gives `unreadable` and no second fault. 3) #3628 edits the same block of `eh.rs` (Foniass noted it too), so whichever lands second needs a rebase. 4) Not tested: a crash in a retail title (none on this machine), a crash with a corrupted heap, AMD. performance: none by default (reasoned): the code runs only in the unhandled-exception filter, and without the switch it stops at one check. verdict: safe to merge hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)
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/3027:upstream-pr/3027'
git switch 'upstream-pr/3027'

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