Skip to content

kernelx: a lazy page whose commit fails stays lazy, and says so - #502

Closed
Luislariosss wants to merge 1 commit into
xcl-dev:mainfrom
Luislariosss:fix/lazy-commit-failure
Closed

Luislariosss wants to merge 1 commit into
xcl-dev:mainfrom
Luislariosss:fix/lazy-commit-failure

Conversation

@Luislariosss

@Luislariosss Luislariosss commented Nov 24, 2026 •

Copy link
Copy Markdown

Fixes #467.

Tested

cargo test --workspace -- --test-threads=4
677 passed, 0 failed, 41 ignored

On: AMD Radeon RX 9060 XT (RDNA4, gfx1200), Adrenalin 26.10.1 (Windows driver 32.0.32015.7029), Windows 11 26200, MSVC 2022, base 2997c9aca.

The new unit test reserves one page, marks it lazy, commits it with an allocator that fails and asserts the page is still in LAZY; commits it with one that succeeds and asserts it is out; then asserts a page that was never lazy is not touched.

Not tested

No regression run: I do not have the game package, so scripts/smoke.ps1 cannot be run here, and pr_check.py will say so - the file is under crates/xcl/src/, which it treats as runtime even though every added line is inside #[cfg(test)] (this is the case #452 describes).

The commit-limit failure itself was not reproduced against a title; only the unit test above covers it. The xlog_warn! is new and could be noisy if the limit is reached with many pages at once - happy to cap it.

AI use

Written by an AI agent under this repository's rules: the diff was produced by DeepSeek V4.1 Flash, with the design discussed with Gemini 4 Neon (T3 Code) and reviewed line by line by the operator, who ran the suites above. CONTRIBUTING.md does not accept open-weight models for code and pr_check.py names deepseek, so this PR does not meet that rule as written. I am declaring it rather than leaving it out: close it if that rule is firm, and keep the test idea for whoever writes it by hand.

Regression run

None: no game package on this machine.

commit() removed the page from LAZY before VirtualAlloc, so a failed commit - the system's commit limit, which a retail title on a 16 GB machine gets close to - left the page out of the set with nothing committed. The next access to it was no longer recognised as lazy, the handler returned EXCEPTION_CONTINUE_SEARCH, and the title died with 0xc0000005 on a page that was still MEM_RESERVE, with no log line: the crash named a wild write instead of an out-of-memory.

The page now leaves the set only once the allocation succeeded. The allocation is a parameter (commit_with), so a test can make it fail and assert that the page stays lazy, that a retry that succeeds takes it out, and that a page that was never lazy is not touched.
@TurGangS

Copy link
Copy Markdown

cool

@yyc160

yyc160 commented Nov 24, 2026

Copy link
Copy Markdown

Regression run, with a caveat about what it can and cannot show on this title.

main@2997c9a (two runs, idle GPU):

xcl-smoke v1
commit: 2997c9aca6ebf4577fed34ebdb3cb0a77dd9ec21
gpu: NVIDIA GeForce RTX 5070 Ti / seconds: 180 / exit: 0x0
frames shown: 871 (PresentX 871)
presents per 2 s (last 3): 9 10 10
device removals: 0 / crashes: 0 / peak commit: 15044 MB
frames shown: 953 (PresentX 954) / presents per 2 s (last 3): 10 10 9
peak commit: 15061 MB / device removals: 0 / crashes: 0

This PR @be9423c:

xcl-smoke v1
commit: be9423c6285a6a9b6cc373f53fcdd71d9a5a9970
gpu: NVIDIA GeForce RTX 5070 Ti / seconds: 180 / exit: 0x0
frames shown: 1047 (PresentX 1047)
presents per 2 s (last 3): 10 11 11
device removals: 0 / crashes: 0 / peak commit: 15052 MB

Hardware and toolchain: RTX 5070 Ti (Blackwell, 32-lane), driver 32.0.16.1742, Windows 11, 32 GB, DXC 1.9.2609. scripts/smoke.ps1 -Seconds 180, no uncommitted changes.

The frame counts are not a performance signal on this title yet. Every activity line in the log of all three runs reads 0 draws, 0 dispatches — the title presents 871-1047 times and never submits a draw or a dispatch, i.e. it is sitting in a menu/loading state. That also explains why these runs were faster on a GPU that was 100 % busy with an unrelated job (1479 frames) than on an idle one: XCL was not using the GPU at all. So 1047 vs 871/953 says nothing about this change; it is the idle-spin rate of a menu.

What the run does show: no crash, no device removal, exit 0x0, and peak commit 15052 MB against 15044/15061 on main — no memory regression.

The path this PR changes was not taken. lazy page appears zero times in the log, so no commit failed during these runs; the fix's commit_with failure branch never ran. The run therefore confirms "no regression", not "the fix works".

Not tested: the actual failure case (a commit hitting the system commit limit). Triggering it would need either an artificial commit-limit pressure or a title that gets close to it — this machine has 32 GB and did not approach it. The unit test in the PR covers the behaviour; what is missing is a run where the branch is reached for real.

@asd3670576

Copy link
Copy Markdown

Built and tested the PR head on a Windows 10 machine that has no Shader Model 6.6 and only a GNU toolchain. Every count below is pasted from the run, not written by hand.

Machine

  • Windows 10 Pro for Workstations 19045.3324 (22H2), Rust/cargo 1.100.0, host toolchain x86_64-pc-windows-gnu (no MSVC, no Windows SDK: cargo build here needs MinGW-w64 on PATH or it dies with error calling dlltool 'dlltool.exe': program not found), Ryzen 9 5950X (32 logical CPUs), 64 GB RAM.
  • GPU: RTX 3080 20 GB, driver 610.88. DXC 1.9.2609.5 at H:\leonida\dxc\bin\x64 (XCL_DXC_DIR). Agility 1.620.2 at H:\leonida\agility\build\native\bin\x64 (XCL_D3D12_DIR) but it cannot load on this OS build (no ID3D12SDKConfiguration1 before KB5029331), so the inbox runtime caps at Shader Model 6.5 and XCL's GPU recompiler path is unavailable here.
  • Release profile throughout. No title run here, so no xcl-smoke block from this machine.

Apply / build

  • git fetch --depth=1 https://github.com/ivall/xcl pull/502/head:pr502 → be9423c6285a6a9b6cc373f53fcdd71d9a5a9970, checked out as-is: no rebase, no conflict resolution, git status --porcelain empty before the build and after it. (The first three unshallowed fetch attempts died with SSL_ERROR_SYSCALL, so the head came in shallow; the tree built is the head commit itself, verified by its sha.) The API reports mergeable: true, mergeable_state: unstable.
  • cargo build --release --workspace → exit code 0:
    Finished `release` profile [optimized] target(s) in 27.40s

Tests

cargo test --release -p xcl --lib -- kernelx::lazy, three runs on the default thread count:

run 1: test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 655 filtered out; finished in 0.03s
run 2: test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 655 filtered out; finished in 0.02s
run 3: test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 655 filtered out; finished in 0.02s

cargo test --release -p xcl --lib -- gpu::recomp::dxc:

test result: ok. 14 passed; 0 failed; 0 ignored; 0 measured; 644 filtered out; finished in 0.44s

cargo test --release -p xcl --lib -- kernelx::lazy gpu::recomp::dxc (both modules in one process, default threads):

test result: ok. 17 passed; 0 failed; 0 ignored; 0 measured; 641 filtered out; finished in 0.44s

cargo test --release --workspace --no-fail-fast -- --test-threads=4 → exit code 0. 16 test result: lines (one per test binary plus the doc-test run); the xcl lib is:

test result: ok. 637 passed; 0 failed; 21 ignored; 0 measured; 0 filtered out; finished in 6.08s

all 16 are ok; summed over them: 677 passed; 0 failed; 41 ignored. Skips, reported rather than counted as coverage: 86 SKIPPED lines, 84 : no GPU and 2 : no wave64, for example

SKIPPED gpu::recomp::tests::gpu_bvh_intersect_ray: no GPU
SKIPPED gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no GPU
SKIPPED gpu::recomp::mesh_dispatch::tests::gpu_dispatch_matches_native_wave64_reference: no GPU

One thing the new test output shows. The new warning prints an os error that is not the commit error, because in the test the failing allocator is an injected closure that never calls VirtualAlloc, so std::io::Error::last_os_error() reports whatever the thread last saw — here the zero code:

xcl: lazy page 0x1c9f4d40000: commit failed (操作成功完成。 (os error 0)); the title's next access to it faults here

(that message on an English display locale reads "The operation completed successfully. (os error 0)", which is an odd thing to print after "commit failed"). With a real VirtualAlloc failure the last error would be set, so this looks like a test-path artifact rather than a bug in the fix; if you want the two apart, the test could call SetLastError or the message could only be printed when an allocation was actually attempted.

What this machine can and cannot verify. It can verify that the head builds in release with the GNU toolchain, that the new a_failed_commit_leaves_the_page_lazy test passes (3/3, and 17/17 together with the dxc tests), and that nothing else in the workspace regresses. It cannot verify the failure it guards against: with 64 GB of RAM and a 153 GB commit limit (125 GB of it free) nothing here reaches ERROR_COMMITMENT_LIMIT, so the branch only runs because the test injects a failing allocator, and the "could be noisy" question in the description cannot be measured on this machine either. And because the adapter caps at SM 6.5, no GPU test executed at all.

AI use: an agent (DeepSeek Harness, "auto" route - I do not know the underlying model) built the head, ran the tests and pasted the output.

@raylitebull

Copy link
Copy Markdown
Member

Closing per CONTRIBUTING.md / pr_check.py, which does not accept open-weight models (DeepSeek) for code contributions. Thank you for declaring AI use transparently — the fix idea on #467 remains helpful for a compliant follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

5 participants