Repository navigation
Conversation
From xcl-dev/xcl#487 by @Grimkaaah, squashed. Supersedes xcl-dev/xcl#488 (dropped: its child-process test overflows the stack under the job commit limit instead of hitting the limit, so the crash-line assertion cannot hold).
|
Tested exact head Tested
Not tested
AI use
|
|
Follow-up to my report above: why the new test's child overflows its stack, and a test-only change that makes it pass reliably here. The fix in Two causes, both in the test's set-up of the commit-limited child
Measured (head
With the last set-up, the test itself ( The change (test only; replaces the two // Commit stack *below* this frame, where the crash handler will run, before the limit.
#[inline(never)]
fn warm_below() {
let mut a = [0u8; 256 * 1024];
std::hint::black_box(&mut a);
}
warm_below();
// The crash line's register descriptions reach gpu::uma::get(): set it up now.
let _ = crate::gpu::uma::get();
// Grow the heap now so the crash line's strings fit without a new commit.
drop(std::hint::black_box((0..64).map(|_| vec![0u8; 1024]).collect::<Vec<_>>()));Not tested
Hardware: NVIDIA GeForce RTX 5070 Ti (616.64), Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug. AI use
|
|
AI Qwen (agent) — follow-up test report, 2026-11-24 Tested this PR stacked on fresh Title: GTA VI (Scarlett) Results:
So: this PR is a real forward step (it removes the first hard crash on this title) and I'd vote to merge it; the next blocker looks like the DirectStorage-failure → uncommitted-region chain (#505 territory) rather than the lazy commit itself. All observations above were produced by AI Qwen running the title under XCL; no promises made on behalf of the account owner. |
|
Built and tested the PR head on a Windows 10 machine that has no Shader Model 6.6 and only a GNU toolchain, because the job-object test in this PR is the one that decides whether the fix is verifiable. Every count below is pasted from the run, not written by hand. Machine
Apply / build
One earlier build attempt here failed with three errors in Tests
run 2, the failing one: The same test by name, So on this machine the test passes 2 of 3 times only when it runs next to the other
all 16 are Forcing the requirement shows the SM 6.5 cap directly ( What this machine can and cannot verify. It cannot put any pressure on the commit limit: 64 GB of RAM against a 153 GB commit limit with 125 GB of it free, so the only commit-limit failure this PR's code ever sees here is the one the Job Object forces inside the test. That makes the test the whole verification of the fix - and it is the part that is unreliable here. With two other reports already showing the same child-process stack overflow on MSVC and Windows 11, this looks like a property of the test's set-up rather than of one machine; a release build on 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. |
|
This and #487 (opened a minute earlier) both fix #467 the same way at the core. A lazy page whose
The two conflict in AI-assisted (Claude Code). |
|
One downstream Windows/RDNA3 integration result for bd7b9e4. I ran the workspace serially on main 930e8b4 plus this change, local physical-page range validation and the graphics changes from #789/#968/#1248/#640. One library test failed. Its diagnostic was: The failure is in the child used by the test. This was a combined checkout. On the title route, the comparison build without #488 had a second-chance write access violation on a DirectStorage thread in write_physical_pages. The next two runs on the combined checkout both reached the story card and exited later with different driver errors. I did not capture a failed lazy commit on that route, so these results do not establish its cause. Follow-up control: I checked out the unmodified PR head bd7b9e4 in a separate worktree and ran the exact focused test. It independently failed with the same missing 0xc0000005 and child stack-overflow diagnostic (0 passed, 1 failed). |
|
I checked futurepro62’s test-only setup on bd7b9e4. Windows 11 build 26300, Rust 1.99.1 MSVC, debug build, RTX 3080 Ti host. These tests are CPU-only. Tested
Not tested AI use |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Test report: Commit tested:
Two causes, both in the test (the change to
A version that passed 40 of 40 runs here:
With lazy.rs test changediff --git a/crates/xcl/src/hle/kernelx/lazy.rs b/crates/xcl/src/hle/kernelx/lazy.rs
index 6558cc6..3ab420e 100644
--- a/crates/xcl/src/hle/kernelx/lazy.rs
+++ b/crates/xcl/src/hle/kernelx/lazy.rs
@@ -134,7 +134,7 @@ pub fn ensure(p: usize, len: usize) {
#[cfg(test)]
mod tests {
use super::*;
- use windows_sys::Win32::System::Memory::{VirtualFree, MEM_RELEASE, MEM_RESERVE};
+ use windows_sys::Win32::System::Memory::{VirtualFree, MEM_DECOMMIT, MEM_RELEASE, MEM_RESERVE};
/// A lazy page reads as zeros on first touch, keeps what is written; `ensure` commits it
/// without a fault.
@@ -200,7 +200,7 @@ mod tests {
let stderr = String::from_utf8_lossy(&out.stderr);
assert!(stderr.contains("0xc0000005"), "missing 0xc0000005 in stderr: {stderr}");
assert!(stderr.contains("lazy commit failed"), "missing lazy commit summary in stderr: {stderr}");
- assert!(stderr.contains("1455 ERROR_COMMITMENT_LIMIT"), "missing ERROR_COMMITMENT_LIMIT in stderr: {stderr}");
+ assert!(stderr.contains("lazy commit failed 2 times"), "missing the second failed commit in stderr: {stderr}");
return;
}
unsafe {
@@ -217,8 +217,14 @@ mod tests {
// Pre-commit stack pages before applying the job commit limit so the crash handler
// itself does not hit a stack-guard commit failure.
- let mut stack_warm = [0u8; 64 * 1024];
- std::hint::black_box(&mut stack_warm);
+ // (in a call: the exception dispatch and the handler run below this frame, so the
+ // pages there must be committed; an array in this frame commits the ones above)
+ #[inline(never)]
+ fn warm_stack_below() {
+ let mut stack_warm = [0u8; 256 * 1024];
+ std::hint::black_box(&mut stack_warm);
+ }
+ warm_stack_below();
let mut pmc: PROCESS_MEMORY_COUNTERS = std::mem::zeroed();
assert_ne!(GetProcessMemoryInfo(GetCurrentProcess(), &mut pmc, std::mem::size_of_val(&pmc) as u32), 0);
@@ -227,34 +233,50 @@ mod tests {
assert!(!job.is_null());
let mut info: JOBOBJECT_EXTENDED_LIMIT_INFORMATION = std::mem::zeroed();
info.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_PROCESS_MEMORY;
- info.ProcessMemoryLimit = pmc.PagefileUsage + 4 * PAGE;
+ info.ProcessMemoryLimit = pmc.PagefileUsage + 16 * 1024 * 1024;
assert_ne!(SetInformationJobObject(job, JobObjectExtendedLimitInformation, &info as *const _ as *const _, std::mem::size_of_val(&info) as u32), 0);
assert_ne!(AssignProcessToJobObject(job, GetCurrentProcess()), 0);
- const PAGES: usize = 64;
- let r = VirtualAlloc(std::ptr::null(), PAGES * PAGE, MEM_RESERVE, PAGE_READWRITE) as usize;
+ let r = VirtualAlloc(std::ptr::null(), 2 * PAGE, MEM_RESERVE, PAGE_READWRITE) as usize;
assert_ne!(r, 0);
- for i in 0..PAGES {
- mark(r + i * PAGE);
- }
+ mark(r);
+ mark(r + PAGE);
// A page under the limit still commits on first touch.
std::ptr::write_volatile(r as *mut u32, 42);
assert_eq!(std::ptr::read_volatile(r as *const u32), 42);
assert!(!LAZY.read().unwrap().contains(&r));
- // Push past the job's commit limit: the failing page must stay in LAZY and record the error.
- for i in 1..PAGES {
- let page = r + i * PAGE;
- ensure(page, PAGE);
- if LAZY.read().unwrap().contains(&page) {
- assert_eq!(FAILED_COMMITS.load(Ordering::Acquire), 1);
- assert_eq!(LAST_FAILED_ERR.load(Ordering::Relaxed), ERROR_COMMITMENT_LIMIT);
- std::ptr::write_volatile(page as *mut u32, 99);
- unreachable!("touching an uncommitted page past the limit must fault");
- }
+ // Use up the limit with plain commits, then commit the lazy page with nothing on the
+ // heap in between (at the limit an allocation fails and aborts the process).
+ const SMALL: usize = 0x1000;
+ let filler_len = 32 * 1024 * 1024;
+ let filler = VirtualAlloc(std::ptr::null(), filler_len, MEM_RESERVE, PAGE_READWRITE) as usize;
+ assert_ne!(filler, 0);
+ let mut committed = 0;
+ while committed < filler_len && !VirtualAlloc((filler + committed) as *const c_void, SMALL, MEM_COMMIT, PAGE_READWRITE).is_null() {
+ committed += SMALL;
}
- panic!("expected lazy commit to hit process memory limit");
+ let page = r + PAGE;
+ let ok = commit(page);
+ let reached = committed < filler_len;
+ // Room again for the heap, the asserts and the crash line.
+ assert_ne!(VirtualFree(filler as *mut c_void, 0, MEM_RELEASE), 0);
+ assert!(reached, "the job's limit is reached ({committed} bytes)");
+
+ // Past the job's commit limit: the page stays in LAZY and the error is recorded.
+ assert!(!ok, "the commit past the limit fails");
+ assert!(LAZY.read().unwrap().contains(&page), "a page whose commit failed stays lazy");
+ assert_eq!(FAILED_COMMITS.load(Ordering::Acquire), 1);
+ assert_eq!(LAST_FAILED_ERR.load(Ordering::Relaxed), ERROR_COMMITMENT_LIMIT);
+ let summary = failure_summary().unwrap();
+ assert!(summary.contains("1455 ERROR_COMMITMENT_LIMIT"), "{summary}");
+
+ // A lazy page that cannot be committed (its reservation is gone) faults through to the
+ // crash handler, whose line carries the summary.
+ assert_ne!(VirtualFree(r as *mut c_void, 0, MEM_RELEASE), 0);
+ std::ptr::write_volatile(page as *mut u32, 99);
+ unreachable!("touching a lazy page that cannot be committed must fault");
}
}
}Not tested: AMD GPUs, Windows 11, debug builds. Tool: Claude Code, Claude Opus 5.5 (ran the tests, wrote the test change and this report). |
What is in it
Fixes #467.
crates/xcl/src/hle/kernelx/lazy.rs: incommit, checkLAZY.contains(&page)first and onlyLAZY.remove(&page)afterVirtualAlloc(MEM_COMMIT)succeeds. On failure, leavepageinLAZYand record the failure count, last failing page address, andGetLastError()in atomics (no allocation or logging inside the vectored exception handler), exposed viafailure_summary().crates/xcl/src/eh.rs: inunhandled_filter, appendlazy::failure_summary()(lazy commit failed N times, last 0x... (err)) to the crash line when non-empty.hle::kernelx::lazy::tests::failed_lazy_commit_stays_lazy_and_reports_in_crash_line(spawns a child test process inside a Job Object withJOB_OBJECT_LIMIT_PROCESS_MEMORY) verifying that a page under the limit commits, a page past the limit stays inLAZY, and the unhandled-exception crash line includeslazy commit failedand1455 ERROR_COMMITMENT_LIMIT.Tested
cargo build --workspace(XCL_ADAPTER=radeon): passedcargo test --workspace -- --test-threads=4(XCL_ADAPTER=radeon): 677 passed; 0 failed; 41 ignoredxcllib:637 passed; 0 failed; 21 ignoredconsole_dlls_e2e:13 passed; 0 failedconsole_shaders:3 passed; 0 failed; 4 ignoreddisasm_e2e:1 passed; 0 failede2e:3 passed; 0 failedgpu_compute_e2e:2 passed; 0 failedgpu_pso_e2e:7 passed; 0 failedheap_probe:0 passed; 0 failed; 4 ignoredpls_quota:1 passed; 0 failedpredication_e2e:1 passed; 0 failedrpf_e2e:2 passed; 0 failedtexture_states:1 passed; 0 failedxg_oracle:6 passed; 0 failed; 12 ignored.\scripts\smoke.ps1 -Game "<game folder>" -Seconds 60(XCL_NETWORK=0,XCL_ADAPTER=radeon):Not tested
AI use