kernelx: XMemMapPhysicalPagesScatter with no page array unmaps #495
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!495
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/495/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@notdxbi on GitHub · 2026-11-24 01:02 UTC · original
notdxbi:pr-scatter-null-unmaps→main· +41 −3 · 1 files · 1 commits · merged 2026-11-25 16:29 UTCA retail game unmaps addresses while it streams its world with
XMemMapPhysicalPagesScatter(addresses, n, NULL). It checks the result and runs into its ownint3when the call fails (+0xb18de7; the function at+0xb18dc0calls the scatter through its IAT slot and breaks on 0), then its crash reporter. XCL refused a NULL page array withERROR_INVALID_PARAMETER. Page 0 already means "unmap this address" in a scatter, so no array is now taken as page 0 for every address. Part of #175 (https://github.com/ivall/xcl/issues/175#issuecomment-7118129089).What is in it
hle/kernelx.rs:XMemMapPhysicalPagesScatterwith a NULL page array unmaps each address (through the existing page-0 path).scatter_without_pages_unmaps: two pages mapped and written, unmapped with no array (the call succeeds, the addresses are no longer committed), mapped again they read what was written. Without the change it fails ("no page array: unmapped, not refused").Tested
from_ifacechecks relaxed and-Db_ndebug=true, as in #257; DXVK 3.1.1 dxgi), Rust stablex86_64-pc-windows-gnu(cross-built), releasemain2997c9a+ this commit): CPU tests--skip gpu:: --test-threads=4: 364 passed, 0 failed, 3 ignored; GPU testsgpu:: --test-threads=1: 271 passed, 0 failed, 18 ignored (run serially: with 4 threads this card sometimes loses the device, NVRM Xid 109, in tests this change does not touch).mesh_dispatch::tests::gpu_*/paired_*were excluded: they hang this GPU onmaintoo.SKIPPEDon this adapter:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64)int3at+0xb18de7at ~113 s; after, the run went on past it.Regression run
scripts/smoke.ps1needs Windows (see Not tested).Not tested
scripts/smoke.ps1blocks and no MSVC build; this PR needs someone to run the regression on Windows before it can be merged.AI use
🤖 Generated with Claude Code
A retail game unmaps addresses while it streams its world with XMemMapPhysicalPagesScatter(addresses, n, NULL); it checks the result and runs into its own int3 when the call fails (+0xb18de7, then its crash reporter). XCL refused a NULL page array with ERROR_INVALID_PARAMETER. Page 0 already means "unmap this address" in a scatter, so no array is taken as page 0 for every address. Test scatter_without_pages_unmaps: two pages mapped and written, unmapped with no array (the call succeeds, the addresses are no longer committed), mapped again they read what was written. It fails without the change ("refused"). Co-Authored-By: Claude Opus 5.5 <[email protected]>mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@yyc160 on GitHub · 2026-11-24 01:31 UTC · original
Regression run, plus two review notes. Native Windows 11, RTX 5070 Ti (Blackwell, 32-lane, driver 32.0.16.1742), 32 GB. Same title, 180 s each, no uncommitted changes.
main@2997c9aThis PR @
1822092Frames 1377 vs 1479 (93 %), peak commit 15040 vs 15064 MB (100 %), no device removal, no crash, exit 0x0. Inside the 80 % / 125 % bounds — but see the note at the end about the frame counts on this machine.
Not tested: neither build stopped on the NULL-scatter path, so this run does not confirm the fix fires.
mainshould have failed on that call and did not, which means the title did not reach that stream-out point inside 180 s here.1.
-Seconds 60is too short for this title on this hardware. The same commit measured 340 and 271 frames in two 60 s runs (±25 %), steady state 9/9/8 vs 6/7/6 per 2 s. At 180 s the same binary settles at 25-26 per 2 s. The 60 s window is still inside loading and shader compilation, so a low 60 s number here would not mean a regression.2. Three points on the change itself (static read, not from a test):
vec![0u64; n]withn == 0givesas_mut_ptr()a non-null dangling pointer, so the recursive call takes the "pages provided" branch instead of the null branch. Harmless only if nothing dereferencespages[0]whenn == 0; the two paths disagree on that edge.8 * nbytes before the UMA check, so a call that used to fail fast on "UMA not initialised" now allocates first. Reading the page id inside the existing loop needs neither:let page_id = if pages.is_null() { 0 } else { *pages.add(i) };MapUserPhysicalPagesScatteranalogue. The title only shows it expects success, not what success must do to the mapping. If the console contract cannot be pinned down, a compatibility switch may be safer than changing it globally.All of this is one title on one GPU, and that machine had other heavy load on it during the runs — treat the frame counts as indicative and the review points as questions, not as a block.
@notdxbi on GitHub · 2026-11-24 01:59 UTC · original
@yyc160 thanks for the regression run and the review. Pushed
3ae0841(squashed into the one commit):n == 0/ the dangling pointer, and the allocation before the UMA check: both gone. There is no temporary array any more. The page for addressiis read in the existing loop asif pages.is_null() { 0 } else { *pages.add(i) }, after the UMA check, so with and without an array the call goes down the same path. The test now also checks thatn == 0gives the same answer with and without a page array.MapUserPhysicalPagesScatter: "If the PageArray parameter is NULL, the specified address ranges are unmapped." On the title's side I only know that it requires the call to succeed (it breaks on 0). I haven't traced what it does with those addresses afterwards. I don't have the console SDK text, so if the maintainer prefers a switch I'll add one, but I'd rather not make a guess the default the other way.Tested on
3ae0841(Linux/Wine, RTX 5060): lib suite 373 passed / 0 failed / 3 ignored (CPU) + 274 / 0 / 18 (GPU, serial);scatter_without_pages_unmapspasses.@Kalmarv on GitHub · 2026-11-24 02:17 UTC · original
Regression run for this PR's head on Windows, as asked in #175.
Tested
cargo build --release -p xcl) from clean checkouts2997c9aca6ebf4577fed34ebdb3cb0a77dd9ec21(this PR's base); PR head:3ae08413426eee45cc95f2c3c7e3d2b169ed1142, no uncommitted changesscripts/smoke.ps1 -Game <title folder> -Seconds 60on a retail title, main first, after one 60 s warm-up run of main; both sides start from the same learned coherent-window sizeRegression run
main:
PR:
Not tested
XMemMapPhysicalPagesScatter, and main's run did not crash either (no int3, no crash reporter) in its 60 s, so this run does not show whether the title made the call with no page array; it is a regression check onlycargo test --workspace(not run for this report)🤖 Claude Opus 5.5
@albertoglvn on GitHub · 2026-11-24 03:40 UTC · original
Tested on native Windows 11, RTX 4060 Laptop 8 GB (7956 MiB), driver 621.24, 15 GB RAM, release MSVC build. The newer retail title (TitleID 7952987A) with the Series S profile (
device_type = "lockhart"),XCL_NETWORK=0,XCL_ACTIVITY=1. Build: #484 head (9783066) + #242, with this PR's commit (3ae0841) and #496's (409f40f) cherry-picked on top.Without #495/#496:
int3at+0xb18de7at 130.8 s, 4.7 s after the title's XStore query (XErrorReport 0x89240107). The function at+0xb18dc0callsxmem.dll!XMemMapPhysicalPagesScatterwithr8 = 0and breaks on a 0 result, andrcx = 0x57at the break, which matches this PR's description.With both: the run went past that point (XStore query at 186 s) and played on until 354.5 s. No device removal and no failed scatter calls logged.
scatter_without_pages_unmapsandunmapping_waits_for_work_on_title_queuespass here.The run then ended on #333 (
0x80000003at+0x193e00f,rax = 0x8007000e, after 7× "no video memory for more pages of title textures"), at the same local video memory as on the Series X profile (10.2 GB):So on 8 GB the Series S profile trades target pages for sparse pools and starts 1.2 GB higher. It lasted about 12 s longer after the load point than Series X did. It is not a way around #333.
Caveats: one run, no
scripts/smoke.ps1blocks (two Windows regression runs are already above). Base is #484's, not current main.AI use: the crash was traced and this comment drafted with Claude Opus 5.5; I ran the game and checked the results.
@crosettiremi on GitHub · 2026-11-24 04:23 UTC · original
Native Windows 11 / RX 7900 XT, retail 1.0.2.1, Series S profile. The local control accepted A, then took 0x80000003 at title+0xb18de7 at 41.473 s (RCX 0x57, R8 zero). Adding
3ae0841plus #615's presentation overlay to the same integration build, with the same saved profile, input and initial application caches, got past that breakpoint and into world streaming. The isolated scatter_without_pages_unmaps regression passed in the combined workspace suite. I did not instrument the scatter return value in the retail run.The follow-up run ended at 168.731 s at the separate title+0x23cf683 watchdog, with zero device removals. The full combined suite passed 730 tests, 0 failed, 41 ignored; one nominal pass reported SKIPPED for missing xgameruntime.dll. Commands: cargo build --workspace --offline --locked and cargo test --workspace --offline --locked -- --test-threads=4 --nocapture, followed by a release hardware run. Codex (GPT-6) ran the checks and summarized the local logs.
@MrEjecutor on GitHub · 2026-11-24 05:56 UTC · original
Test report on Windows + NVIDIA for
3ae0841(this PR's head): the+0xb18de7assert is the one I hit, and with this PR the title runs past itOn the Series S profile (
device_type = "lockhart") the retail title 1.0.2.1 stops at+0xb18de7(0x80000003) about 5 s after itsXStorequery, on Windows too. The function at+0xb18dc0callsXMemMapPhysicalPagesScatterthrough its IAT slot with a NULL page array, as described above. #242 is needed to get there on NVIDIA (the earlier format-67 assert at+0xcc2834), so I tested this PR together with #242.Tested
stable-x86_64-pc-windows-msvc; DXC 1.8.2505.32 (SDK 10.0.28000); releasemaine50836b+ #242 (e54a0d4) + this PR (3ae0841), merged locally without conflicts (073bd69)cargo test --workspace --release --no-fail-fast -- --test-threads=4: 705 passed, 0 failed, 41 ignored;SKIPPED(no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardwarelockhart,XCL_NETWORK=0, 180 s: theXStorequery at 73 s, then no assert; the title runs to the end of the 180 s and starts streaming its world (BCPack refusals from 86 s on, BC5 / BC7)e54a0d4), same setup:0x80000003at+0xb18de7at 51.6 s (report on #242)Regression run
This block is from the local merge, not from this PR's head alone: on this card the title does not reach the scatter without #242, so a run of this PR alone would only show the earlier assert.
Not tested
AI use
@volkan12a-bot on GitHub · 2026-11-24 06:44 UTC · original
Test report: retail title, a run confirming the problem this PR fixes
Not a run of this PR's head (
3ae0841): it is a run of my local patch with the same behaviour (no page array → page 0 for every address), onmain7ebf1b8. I post it because it shows the failing call and the effect of the fix on real hardware.Hardware / build
cargo build --releaseWithout the fix
game_scarlett_master.exe+0xb18de7:unhandled exception 0x80000003, exit 0x80000003.mov edx,[count]/lea rcx,[address array]/xor r8d,r8d/call XMemMapPhysicalPagesScatter/test eax,eax/jne/int3. So the call is (addresses, n, NULL), and theint3fires when it returns FALSE.With the fix
mainfixed in #484, not something this PR adds.cargo test -p xcl --lib kernelxpassed: 26 passed, 0 failed, 1 ignored (with my own test of a scatter call without pages).Not tested
smoke.ps1blocks; AMD GPUs.AI use
mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175@rrrarrra9 on GitHub · 2026-11-24 16:21 UTC · original
Windows validation on a GTX 1650 (4 GB)
Retail 1.0.2.1 in the Series S profile. I compared
mainb7aa9f3+ #605 (e21849e, local) with the same tree plus this PR's3ae0841(15d6e71, local). The latter cherry-pick resolved a conflict between adjacent tests inkernelx.rs.e21849e0x80000003atgame+0xb18de7at 82.63 s. Final exit0xc0000005.15d6e710x0. XCL counted 1,773 frames shown and 1,775 PresentX calls. Peak process commit was 18,196 MiB.The final sampled 1920×1080 frame had 0 of 129,600 non-dark samples. The report also recorded 45 calls to queue slot #31 (the case tracked in #1031). This is Windows runtime evidence that the scatter change clears the assertion at
game+0xb18de7in this stack.AI use
Codex (GPT-6) prepared the local cherry-pick, ran the comparison, and wrote the report from the generated logs.
@gavinnolan on GitHub · 2026-11-24 22:47 UTC · original
Confirming the diagnosis on Series S (
device_type = "lockhart"), retail title 1.0.2.1: the title asserts at+0xb18de7afterXMemMapPhysicalPagesScatter(addresses, n, NULL)returns 0 withERROR_INVALID_PARAMETER(rcx=0x57at theint3). Disassembly matches: the function at+0xb18dc0calls the IAT slot forxmem.dll!XMemMapPhysicalPagesScatterwithr8 = 0and breaks on 0.Setup: NVIDIA GeForce RTX 2060 Laptop 6 GB (driver 595.79), i7-10750H, 16 GB RAM, Windows 11 10.0.26200, release build.
main689f2dbplus #615, #833, #751, #1792.0x80000003at+0xb18de7at 208 s, twice (two runs).XMemMapPhysicalPagesScatterchange applied by hand (it no longer merges withmain: the function is unchanged, the conflict is elsewhere inkernelx.rs): no assert there; the title reached its world loading screens at ~218 s. It then stopped at 246 s on video memory (0x8007000e,+0x193e00f, 6 GB card), which is #333, not this.I did not port the test.
@yinx080 on GitHub · 2026-11-25 00:44 UTC · original
Test report from Windows: the same assert reproduces here and the same change fixes it.
c160d86plus an equivalent change (a NULL page array goes through the page-0 path).device_type = "lockhart"). After A on the account prompt, without the change:int3at+0xb18de7with identical registers in two runs (+0xb18dc0calls the scatter with(its address table, n, NULL)and breaks on FALSE). With it, the title goes on to its loading screen andstarts streaming (it later stops on this card's video memory, see #345).
main; happy to retest after a rebase.AI use: Claude Code (Claude Opus 5.5) found the assert, wrote the local change and this report.
@imnicho on GitHub · 2026-11-25 08:09 UTC · original
RTX 5080, Series S profile: the title stops at this
int3without the change and goes on with itdevice_type = "lockhart"on #2057 atf862f5f+ #684 + #266 + #1515: two runs, both ended at the title's own0x80000003of the description, at 51 s and at 73 s, before the world's set-up.3ae0841cherry-picked onto #2057 at41303e4(+ #2067, #684, #266, #1515, #1405, #751): one run of 900 s in the same profile got past that point and reached the world's set-up at 200.8 s. It ended at 726 s for another reason (a GPU hang after the tile queue made no progress for 10 s, with local video memory 3 GB over this 16 GB card's budget).main: for me it was only in the test module ofkernelx.rs.mapping_fresh_pages_does_not_query_each_pagewith what follows it onmain's side andscatter_without_pages_unmapson this side were added at the same place and share the test's last lines; keeping both tests whole resolves it, andscatter_without_pages_unmapspasses on that tree.Setup: RTX 5080 16 GB (driver 610.47), i7-7700K, 16 GB RAM, Windows 10 22H2, release,
XCL_NETWORK=0,XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1, scripted pad;XCL_UMA_SHADOW=1in the run with the change and in one of the two without. In the Series X profile I have not seen thisint3in any run.Not tested: this head rebased on
mainby itself, and the suite on it. One run with the change.AI use: Claude Code with Claude Fable 5.2 ran the title and wrote this.
@DavidM1911 on GitHub · 2026-11-25 14:05 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.@427001 on GitHub · 2026-11-25 13:54 UTC · original · edited 2026-11-25 14:07 UTC
Test report for
3ae0841merged intomain379725a: the Series S assert at+0xb18de7is gone; and how the conflict withmainresolvesThe conflict.
3ae0841conflicts withmain379725ain the tests ofcrates/xcl/src/hle/kernelx.rsonly:mainadded tests at the place where this PR addsscatter_without_pages_unmaps(mapping_fresh_pages_does_not_query_each_page,sparse_pages, the twopages_mapped_again_…tests,mapping_lazy_pages_again_does_not_query_each_page). Keeping both sides resolves it:main's tests as they are and this PR's test after them, beforescatter_matches_a_model_of_physical_pages. The change toXMemMapPhysicalPagesScatteritself applies as it is, and the merged diff againstmainis the PR's +41/−3.Tested
stable-x86_64-pc-windows-msvc; tests in debug, runs in release.main379725a+ this PR (3ae0841, resolved as above) + #615 (9251d80, adapted tomain's presenter), a local merge. #615 is in it so that the Series S window shows a picture; it does not touchkernelx.rs.cargo build --workspace+cargo test --workspace --no-fail-fast -- --test-threads=4on that tree: 1257 passed, 0 failed, 46 ignored.scatter_without_pages_unmapspasses. 27SKIPPEDlines of 17 tests: 20 "no wave64", 3 per-lane f16 forms refused, 1 "no heap windows", 2 without the D3D12 debug layer, 1 that cannot turn the driver cache off (no Developer Mode).device_type = "lockhart"/console_type_raw = 5,XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_FRAME_DUMP=100 XCL_PRESS_A_AT=40,55, the same saved state:main379725a0x80000003at+0xb18de7+0x193e00fwith0x8007000e(#333) at 118.2 s and 145.5 sint3havercx=0x57(ERROR_INVALID_PARAMETER), as in the description and in @gavinnolan's report.+0x193e00fis the one of #333, not this PR: a pool heap for title textures is refused with about 12.5 GB of local video memory in use on this 10 GB card. (Corrected: I first put it down to the system's commit, which was nearly used up in these runs; a later run with a larger page file and 31.8 GB of commit free stops the same way at 127.4 s.)Not tested
main(the tree with it also has #615); AMD; the Series X profile; asmoke.ps1pair.AI use
@pickles976 on GitHub · 2026-11-25 15:18 UTC · original
Additional Linux/Wine + RTX 4060 Laptop validation of the change and regression from
3ae08413426eee45cc95f2c3c7e3d2b169ed1142.Scope: the function change and
scatter_without_pages_unmapstest were ported unchanged into a mixed local integration based on06c9f5505f63f10c5ec49ef932d75b2c28177324, including #867/#1395 (stock-vkd3d vtable compatibility), #1069, #1916 and #615. This is not a clean-head or Windows smoke report, and not a competing fix.Environment: Linux 6.17.0-40-generic, Wine 11.0, stock/assert-enabled vkd3d-proton 3.2.0 (
2576c0b4adfae4a), DXVK 3.1.1-209; RTX 4060 Laptop 8 GiB, NVIDIA 590.48.01; i7-13620H, 16 GiB RAM; Rust 1.98.1, Windows MSVC cross-target.Observed before the change: retail 1.0.2.1, Series S profile, stopped at
+0xb18de7,rax=0,rcx=0x57,rdx=14,r8=0. Bounded disassembly resolves the call through thunk0x145f3fd20/ IAT0x146793a48toxmem.dll!XMemMapPhysicalPagesScatter; the caller breaks when the call returns zero. This matches the report here.Regression: ran
cargo +1.98.1 test -p xcl --lib --target x86_64-pc-windows-msvc scatter_without_pages_unmaps -- --test-threads=1 --nocapture, through the Wine runner, once withXCL_DEFER_PRIVATE_HOME_TILES=0and once with=1. Both passed (one unique test, two executions); UMA initialized in both, so its early-return skip was not taken. The test checks inaccessible unmapped addresses, preserved data after remapping and zero-count parity. Release MSVC-target build passed.Bounded title follow-up:
XCL_COHERENT_MB=3408 XCL_ACTIVITY=1 XCL_PSO_PRELOAD=0 XCL_DEFER_PRIVATE_HOME_TILES=1 XCL_FRAME_DUMP=300 XCL_PRESS_A_AT=40,55, same Series S profile, offline. The resource guard terminated the process at 60.44 s when board-wide GPU usage reached 7,233 MiB (7,200 MiB guard); available RAM was 4,462.8 MiB and free disk 13.527 GiB. The log reached DirectStorage request #16384 and its first successful BC7 BCPack unpack, with no+0xb18de7exception recorded. The scatter call itself was not instrumented, and this short guarded run does not establish sustained world loading or gameplay. Last captured backbuffer was still the account picker. Offline XStore errors and command-list resubmission warnings remained, so this is not an error-free run.Not tested: native Windows, AMD, clean PR head, full suite, or 15-minute gameplay/30fps. No proprietary assets or frame dumps attached.
AI assistance: omp / openai-codex/gpt-6-astra performed the local integration, commands, inspection and report. Existing PR authors retain credit for the fix and test.
@ivall on GitHub · 2026-11-25 16:29 UTC · original
Merged into
main(65fc114); the only conflict was in the tests (both kept).main), 46 ignored. Without the change,scatter_without_pages_unmapsfails on Windows with your assertion ("no page array: unmapped, not refused"); with it, it passes.int3after the failed call; with this it goes on (in a tree with other open PRs).XCL_PAGE_ALIAS=1the NULL array crashes: that branch readspages.add(i), and the second page is read at address 8. The test here does not see it because it runs without aliasing. In my tree every page is unmapped with one page 0.AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this on the maintainer's behalf.