kernelx: a lazy physical page whose commit fails leaves the lazy set, silently #467

Open
opened 2026-11-26 04:22:40 +00:00 by github-bot · 4 comments
Owner

@⁠requiemsnkrp on GitHub · 2026-11-24 00:42 UTC · original

On main (2997c9a), lazy::commit (crates/xcl/src/hle/kernelx/lazy.rs:39-45) removes the page from LAZY (l. 41) before VirtualAlloc(MEM_COMMIT) (l. 44). When that commit fails – ERROR_COMMITMENT_LIMIT near the system's commit limit, which the retail title reaches on 16 GB machines (#333: 0.44–0.98 GiB of headroom left in three runs) – then:

  • the page is no longer lazy, so the next fault on it is not retried, and the handler (l. 47-58) returns EXCEPTION_CONTINUE_SEARCH: the title dies with 0xc0000005 on a page that stays MEM_RESERVE;
  • lazy::ensure (l. 87-101, used for DirectStorage destinations, dstorage.rs:726) has the same path. The request then fails with 0x89240009 (#333, run 2);
  • nothing is logged, so the crash line looks like a wild write and not an out-of-memory.

This is not the race #244 fixed: there the page ends up committed, here it never is.

Proposed (small, one PR):

  1. Remove the page from LAZY only once the commit succeeded.
  2. Count failed commits and keep the last failing page and GetLastError() in atomics (no logging or allocation inside the vectored handler). The unhandled-exception filter (eh.rs) adds them to the crash line: lazy commit failed N times, last 0x… (1455 ERROR_COMMITMENT_LIMIT).
  3. Test: a child test process in a job object with a process memory limit marks lazy pages past the limit. The touch must fail with the new crash line instead of a bare 0xc0000005, and a page under the limit must still commit.

Not a fix for running out of commit (#333 / #194 / #345), only an honest failure. Before I write it: does this fit, or would you rather have it folded into #194's memory line?

AI use: found while analysing #333 with Claude Code (Claude Opus 5.5).

**@⁠requiemsnkrp** on GitHub · 2026-11-24 00:42 UTC · [original](https://github.com/xcl-dev/xcl/issues/467) On `main` (2997c9a), `lazy::commit` (`crates/xcl/src/hle/kernelx/lazy.rs:39-45`) removes the page from `LAZY` (l. 41) before `VirtualAlloc(MEM_COMMIT)` (l. 44). When that commit fails – `ERROR_COMMITMENT_LIMIT` near the system's commit limit, which the retail title reaches on 16 GB machines (#333: 0.44–0.98 GiB of headroom left in three runs) – then: - the page is no longer lazy, so the next fault on it is not retried, and the handler (l. 47-58) returns `EXCEPTION_CONTINUE_SEARCH`: the title dies with `0xc0000005` on a page that stays `MEM_RESERVE`; - `lazy::ensure` (l. 87-101, used for DirectStorage destinations, `dstorage.rs:726`) has the same path. The request then fails with `0x89240009` (#333, run 2); - nothing is logged, so the crash line looks like a wild write and not an out-of-memory. This is not the race #244 fixed: there the page ends up committed, here it never is. **Proposed (small, one PR):** 1. Remove the page from `LAZY` only once the commit succeeded. 2. Count failed commits and keep the last failing page and `GetLastError()` in atomics (no logging or allocation inside the vectored handler). The unhandled-exception filter (`eh.rs`) adds them to the crash line: `lazy commit failed N times, last 0x… (1455 ERROR_COMMITMENT_LIMIT)`. 3. Test: a child test process in a job object with a process memory limit marks lazy pages past the limit. The touch must fail with the new crash line instead of a bare `0xc0000005`, and a page under the limit must still commit. Not a fix for running out of commit (#333 / #194 / #345), only an honest failure. Before I write it: does this fit, or would you rather have it folded into #194's memory line? AI use: found while analysing #333 with Claude Code (Claude Opus 5.5).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:22:40 +00:00
Author
Owner

@⁠Grimkaaah on GitHub · 2026-11-24 00:58 UTC · original

PR opened: leave the page in LAZY until MEM_COMMIT succeeds, record failures for the crash line, and make DirectStorage refuse destinations that could not be committed.

Made with Cursor

**@⁠Grimkaaah** on GitHub · 2026-11-24 00:58 UTC · [original](https://github.com/xcl-dev/xcl/issues/467#issuecomment-7118627759) PR opened: leave the page in LAZY until MEM_COMMIT succeeds, record failures for the crash line, and make DirectStorage refuse destinations that could not be committed. Made with [Cursor](https://cursor.com)
Author
Owner

@⁠requiemsnkrp on GitHub · 2026-11-24 01:17 UTC · original

Three PRs now implement this issue: #487, #488 and #502. As the issue's author, here is a side-by-side check to help pick one. All three are based on main 2997c9a and merge into it cleanly. I built each head and ran its tests on an RTX 3060 / Ryzen 5 5600X / Windows 11 26200 machine, Rust 1.100.0, debug.

#487 (bf21bcb) #488 (bd7b9e4) #502 (be9423c)
page stays in LAZY until MEM_COMMIT succeeds yes yes yes
failure recorded without logging or allocating in the vectored handler yes (atomics) yes (atomics) no: xlog_warn! in commit_with, which the handler calls
failure named in the crash line (eh.rs) yes, AV only, error as a number yes, error named (1455 ERROR_COMMITMENT_LIMIT) no
test hits a real commit limit no (commits at a released address) yes (child process in a job with JOB_OBJECT_LIMIT_PROCESS_MEMORY) no (injected failing allocator)
new test here 3 of 3 passed failed 6 of 9 runs (below) 3 of 3 passed
hle::kernelx + hle::dstorage tests 38 passed 38 passed in that run 38 passed
PR checks failing failing failing

What I checked, per PR:

  • #488 is the closest to the plan in the issue, but its test is not stable here. Run alone (--exact) it failed 4 of 4 times: missing 0xc0000005 in stderr, and the child had ended with 0xc00000fd, "has overflowed its stack". With the job limit at PagefileUsage + 4 * PAGE, the crash path cannot grow its stack, so the child dies before the filter writes the line. Within hle::kernelx::lazy it failed 2 of 3 runs. The 64 KiB stack warm-up looks too small for that margin. The PR's own regression run reports frames shown: none logged, which pr_check.py reads as fewer frames than main.
  • #487: the dstorage.rs hunk does not change behaviour. writable() already checks every page with VirtualQuery after ensure, so a page that stayed reserved already failed the request. The new test releases a reservation and then commits at that address. In a test process running other tests in parallel, another allocation can take that address in between, and the commit would then succeed into foreign memory (unlikely, but possible). The description has no Tested / Not tested / AI use sections and no regression run, both of which pr_check.py asks for.
  • #502 logs from inside the vectored exception handler (format! plus the log file's mutex). It does so exactly when the system is out of commit, where that allocation can itself fail. It also leaves out the crash-line part. The author already says the diff was written with a model that CONTRIBUTING does not accept.

My suggestion, the maintainer's call: #488's approach with its test made reliable (more commit headroom in the job, or more stack committed before assigning it), and the atomics-only recording that #487 and #488 share.

AI use: comparison, builds and test runs done with Claude Code (Claude Opus 5.5) on the machine above; each point was checked against the diffs and the runs before posting.

**@⁠requiemsnkrp** on GitHub · 2026-11-24 01:17 UTC · [original](https://github.com/xcl-dev/xcl/issues/467#issuecomment-7118952283) Three PRs now implement this issue: #487, #488 and #502. As the issue's author, here is a side-by-side check to help pick one. All three are based on `main` 2997c9a and merge into it cleanly. I built each head and ran its tests on an RTX 3060 / Ryzen 5 5600X / Windows 11 26200 machine, Rust 1.100.0, debug. | | #487 (`bf21bcb`) | #488 (`bd7b9e4`) | #502 (`be9423c`) | |---|---|---|---| | page stays in `LAZY` until `MEM_COMMIT` succeeds | yes | yes | yes | | failure recorded without logging or allocating in the vectored handler | yes (atomics) | yes (atomics) | **no**: `xlog_warn!` in `commit_with`, which the handler calls | | failure named in the crash line (`eh.rs`) | yes, AV only, error as a number | yes, error named (`1455 ERROR_COMMITMENT_LIMIT`) | no | | test hits a real commit limit | no (commits at a released address) | yes (child process in a job with `JOB_OBJECT_LIMIT_PROCESS_MEMORY`) | no (injected failing allocator) | | new test here | 3 of 3 passed | **failed 6 of 9 runs** (below) | 3 of 3 passed | | `hle::kernelx` + `hle::dstorage` tests | 38 passed | 38 passed in that run | 38 passed | | `PR checks` | failing | failing | failing | What I checked, per PR: - **#488** is the closest to the plan in the issue, but its test is not stable here. Run alone (`--exact`) it failed 4 of 4 times: `missing 0xc0000005 in stderr`, and the child had ended with `0xc00000fd`, "has overflowed its stack". With the job limit at `PagefileUsage + 4 * PAGE`, the crash path cannot grow its stack, so the child dies before the filter writes the line. Within `hle::kernelx::lazy` it failed 2 of 3 runs. The 64 KiB stack warm-up looks too small for that margin. The PR's own regression run reports `frames shown: none logged`, which `pr_check.py` reads as fewer frames than main. - **#487**: the `dstorage.rs` hunk does not change behaviour. `writable()` already checks every page with `VirtualQuery` after `ensure`, so a page that stayed reserved already failed the request. The new test releases a reservation and then commits at that address. In a test process running other tests in parallel, another allocation can take that address in between, and the commit would then succeed into foreign memory (unlikely, but possible). The description has no **Tested** / **Not tested** / **AI use** sections and no regression run, both of which `pr_check.py` asks for. - **#502** logs from inside the vectored exception handler (`format!` plus the log file's mutex). It does so exactly when the system is out of commit, where that allocation can itself fail. It also leaves out the crash-line part. The author already says the diff was written with a model that CONTRIBUTING does not accept. My suggestion, the maintainer's call: #488's approach with its test made reliable (more commit headroom in the job, or more stack committed before assigning it), and the atomics-only recording that #487 and #488 share. AI use: comparison, builds and test runs done with Claude Code (Claude Opus 5.5) on the machine above; each point was checked against the diffs and the runs before posting.
Author
Owner

@⁠Toons29 on GitHub · 2026-11-24 02:02 UTC · original

Second machine for the three PRs on this issue, same heads as the comparison above (#487 bf21bcb, #488 bd7b9e4, #502 be9423c; all three still merge cleanly into current main 508a0c7). Each head built and tested as-is.

Tested

  • AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0 (stable MSVC), debug
  • cargo test --workspace --no-fail-fast -- --test-threads=4, 0 GPU tests SKIPPED on any run:
#487 #488 #502
whole suite 677 passed, 0 failed, 41 ignored 676 passed, 1 failed, 41 ignored 677 passed, 0 failed, 41 ignored
the PR's new test passed failed 9 of 10 alone (--exact), 3 of 5 within hle::kernelx::lazy passed
  • #488: same failure as on the RTX 3060 above: missing 0xc0000005 in stderr, the child test process "has overflowed its stack" before the crash filter writes its line. So it is not specific to that machine.
  • #487: in its first run the lib tests had 3 failures: placed_title_textures_share_vram_and_preserve_pixels (cubemap extra_pages must be reused at same va, left 2359296, right 2555904), plus two tests that then panicked on its poisoned lock (transitions_apply_when_their_list_is_submitted, d32s8_targets_take_their_own_size_of_video_memory). It did not come back in 4 more runs of #487 (3 × cargo test -p xcl --lib, 1 × whole suite) or 3 runs of the test alone; the base 2997c9a had 0 failures in 3 lib runs. I can't tie it to #487 from one hit; it looks like an intermittent title-texture test.
  • Base 2997c9a and main 508a0c7 for reference: 636 / 640 lib tests passed, 0 failed; main's whole suite 680 passed, 0 failed, 41 ignored.

I also checked two points of the comparison against the code and agree: #502's commit_with runs xlog_warn! from the vectored handler's call to commit (lazy.rs, handler), and in #487 writable() in dstorage.rs already refuses a page that is not committed through its VirtualQuery loop, so the new early return there does not change the outcome.

Not tested

  • No regression run (scripts/smoke.ps1): I have no retail title.
  • A real commit-limit exhaustion in a title; only the PRs' own tests cover it.
  • NVIDIA / wave32-only GPUs.

AI use

  • Claude Code (Claude Opus 5.5) ran the builds and tests and drafted this report on the machine above; I checked each point against the diffs and the logs before posting.
**@⁠Toons29** on GitHub · 2026-11-24 02:02 UTC · [original](https://github.com/xcl-dev/xcl/issues/467#issuecomment-7119699742) Second machine for the three PRs on this issue, same heads as the comparison above (#487 `bf21bcb`, #488 `bd7b9e4`, #502 `be9423c`; all three still merge cleanly into current `main` 508a0c7). Each head built and tested as-is. **Tested** - AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0 (stable MSVC), debug - `cargo test --workspace --no-fail-fast -- --test-threads=4`, 0 GPU tests SKIPPED on any run: | | #487 | #488 | #502 | |---|---|---|---| | whole suite | 677 passed, 0 failed, 41 ignored | 676 passed, **1 failed**, 41 ignored | 677 passed, 0 failed, 41 ignored | | the PR's new test | passed | **failed 9 of 10** alone (`--exact`), **3 of 5** within `hle::kernelx::lazy` | passed | - #488: same failure as on the RTX 3060 above: `missing 0xc0000005 in stderr`, the child test process "has overflowed its stack" before the crash filter writes its line. So it is not specific to that machine. - #487: in its first run the lib tests had 3 failures: `placed_title_textures_share_vram_and_preserve_pixels` (`cubemap extra_pages must be reused at same va`, left 2359296, right 2555904), plus two tests that then panicked on its poisoned lock (`transitions_apply_when_their_list_is_submitted`, `d32s8_targets_take_their_own_size_of_video_memory`). It did not come back in 4 more runs of #487 (3 × `cargo test -p xcl --lib`, 1 × whole suite) or 3 runs of the test alone; the base `2997c9a` had 0 failures in 3 lib runs. I can't tie it to #487 from one hit; it looks like an intermittent title-texture test. - Base `2997c9a` and `main` 508a0c7 for reference: 636 / 640 lib tests passed, 0 failed; `main`'s whole suite 680 passed, 0 failed, 41 ignored. I also checked two points of the comparison against the code and agree: #502's `commit_with` runs `xlog_warn!` from the vectored handler's call to `commit` (`lazy.rs`, `handler`), and in #487 `writable()` in `dstorage.rs` already refuses a page that is not committed through its `VirtualQuery` loop, so the new early return there does not change the outcome. **Not tested** - No regression run (`scripts/smoke.ps1`): I have no retail title. - A real commit-limit exhaustion in a title; only the PRs' own tests cover it. - NVIDIA / wave32-only GPUs. **AI use** - Claude Code (Claude Opus 5.5) ran the builds and tests and drafted this report on the machine above; I checked each point against the diffs and the logs before posting.
Author
Owner

@⁠lordon1a on GitHub · 2026-11-24 03:52 UTC · original

Comparison of the three open PRs for #467 (#487, #488, #502), to help pick one.

All three fix the core bug the same way: commit checks LAZY.contains(&page) and removes the page only after VirtualAlloc(MEM_COMMIT) succeeds. Each one merges cleanly into main f4ce27c. I read the three diffs before running them. They touch only lazy.rs, eh.rs and dstorage.rs. #488's test starts a child copy of the test binary itself, and none of them make network calls or read files outside the tests' own.

PR head PR description check xcl-smoke lib tests on the merge with main
#487 bf21bcb fail: Tested / Not tested / AI use sections missing, no smoke blocks 0 661 passed, 0 failed
#488 bd7b9e4 fail: same three sections missing, and "fewer frames than main's (None against 1435)" 2 660 passed, 1 failed
#502 be9423c fail: no smoke block 0 661 passed, 0 failed

Differences that matter:

  • #488's test is flaky here. failed_lazy_commit_stays_lazy_and_reports_in_crash_line failed in 8 of 10 runs when started on its own (cargo test -p xcl --lib failed_lazy_commit_stays_lazy). It also failed in the full lib run. When it fails, the child prints has overflowed its stack and nothing else, so the 0xc0000005 / lazy commit failed asserts fail on an empty stderr. The job limit is PagefileUsage + 4 * PAGE, measured before the job is set up. That leaves no room for stack growth or for the crash handler's own allocations, so the child dies of the limit before it reaches the report the test looks for. A test that depends on that margin will likely fail on CI machines too. (Caveat: my toolchain is x86_64-pc-windows-gnullvm, not MSVC, which can change stack use.)
  • #502 logs from inside the vectored handler's path. commit is called from handler, and #502 adds xlog_warn! (formatting and a lock) on the failure path. The issue's plan asks for atomics only there, since the faulting thread may hold the heap or log lock. The description also says the diff was written by DeepSeek V4.1 Flash, which CONTRIBUTING.md does not accept.
  • #487 is closest to the plan. It keeps atomics only in the handler and appends the summary only to the access-violation crash line. ensure now returns bool, so a DirectStorage destination that cannot be committed fails the request instead of being written while still reserved. Its test is deterministic: it commits on a released reservation, so the commit always fails. Two small points:
    • the summary prints the bare error number ((1455)), where the issue asked for the name too, as #488 does;
    • the test releases its reservation and then marks that address lazy. Another test thread could reserve the same address in between, and commit would then commit that test's memory. Reserving two pages and releasing only the second one, or using #502's injected-allocator idea (commit_with), would avoid that.

Suggestion: take #487 once its description has the Tested / Not tested / AI use sections and a regression run. #488's error names could be folded into it. #488's test needs a margin that does not depend on the stack, or should become #502-style allocator injection. Close #502 per the model rule.

Tested on an i7-12700H with an RTX 3070 Ti Laptop, Windows 11 build 26200. Toolchain: rustc 1.100.0 x86_64-pc-windows-gnullvm, debug, cargo test -p xcl --lib -- --test-threads=4 on each PR merged into main f4ce27c. Not tested: the MSVC toolchain, cargo test --workspace, smoke runs, a real commit-limit failure under a title.

Written with Claude Code (Claude Opus 5.5). I checked each point against the diffs and the runs above.

**@⁠lordon1a** on GitHub · 2026-11-24 03:52 UTC · [original](https://github.com/xcl-dev/xcl/issues/467#issuecomment-7121500270) Comparison of the three open PRs for #467 (#487, #488, #502), to help pick one. All three fix the core bug the same way: `commit` checks `LAZY.contains(&page)` and removes the page only after `VirtualAlloc(MEM_COMMIT)` succeeds. Each one merges cleanly into `main` f4ce27c. I read the three diffs before running them. They touch only `lazy.rs`, `eh.rs` and `dstorage.rs`. #488's test starts a child copy of the test binary itself, and none of them make network calls or read files outside the tests' own. | PR | head | `PR description` check | xcl-smoke | lib tests on the merge with `main` | |---|---|---|---|---| | #487 | bf21bcb | fail: Tested / Not tested / AI use sections missing, no smoke blocks | 0 | 661 passed, 0 failed | | #488 | bd7b9e4 | fail: same three sections missing, and "fewer frames than main's (None against 1435)" | 2 | 660 passed, **1 failed** | | #502 | be9423c | fail: no smoke block | 0 | 661 passed, 0 failed | Differences that matter: - **#488's test is flaky here.** `failed_lazy_commit_stays_lazy_and_reports_in_crash_line` failed in 8 of 10 runs when started on its own (`cargo test -p xcl --lib failed_lazy_commit_stays_lazy`). It also failed in the full lib run. When it fails, the child prints `has overflowed its stack` and nothing else, so the `0xc0000005` / `lazy commit failed` asserts fail on an empty stderr. The job limit is `PagefileUsage + 4 * PAGE`, measured before the job is set up. That leaves no room for stack growth or for the crash handler's own allocations, so the child dies of the limit before it reaches the report the test looks for. A test that depends on that margin will likely fail on CI machines too. (Caveat: my toolchain is `x86_64-pc-windows-gnullvm`, not MSVC, which can change stack use.) - **#502 logs from inside the vectored handler's path.** `commit` is called from `handler`, and #502 adds `xlog_warn!` (formatting and a lock) on the failure path. The issue's plan asks for atomics only there, since the faulting thread may hold the heap or log lock. The description also says the diff was written by DeepSeek V4.1 Flash, which CONTRIBUTING.md does not accept. - **#487 is closest to the plan.** It keeps atomics only in the handler and appends the summary only to the access-violation crash line. `ensure` now returns `bool`, so a DirectStorage destination that cannot be committed fails the request instead of being written while still reserved. Its test is deterministic: it commits on a released reservation, so the commit always fails. Two small points: - the summary prints the bare error number (`(1455)`), where the issue asked for the name too, as #488 does; - the test releases its reservation and then marks that address lazy. Another test thread could reserve the same address in between, and `commit` would then commit that test's memory. Reserving two pages and releasing only the second one, or using #502's injected-allocator idea (`commit_with`), would avoid that. Suggestion: take #487 once its description has the Tested / Not tested / AI use sections and a regression run. #488's error names could be folded into it. #488's test needs a margin that does not depend on the stack, or should become #502-style allocator injection. Close #502 per the model rule. Tested on an i7-12700H with an RTX 3070 Ti Laptop, Windows 11 build 26200. Toolchain: rustc 1.100.0 `x86_64-pc-windows-gnullvm`, debug, `cargo test -p xcl --lib -- --test-threads=4` on each PR merged into `main` f4ce27c. Not tested: the MSVC toolchain, `cargo test --workspace`, smoke runs, a real commit-limit failure under a title. Written with Claude Code (Claude Opus 5.5). I checked each point against the diffs and the runs above.
This discussion has been locked. Commenting is limited to contributors.
No description provided.