XMem: a reservation we place in the title's window is asked of Windows only where a free run holds it (Series S boot hang that cannot be killed, #3234) #3787
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!3787
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3787"
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?
@Lyrnc on GitHub · 2026-11-30 07:11 UTC · original
Lyrnc:fix/xmem-no-block→main· +784 −71 · 4 files · 1 commits · openProblem
Since v2026.11.29.01 the Series S profile can hang at boot inside
VirtualAlloc2. The process cannot be ended,tasklisthangs, and only a restart (often the power button) clears it (#3234 and #3023: RawTech with an RTX 3080 Ti, jhon17parizotto-byte with an RTX 3060, both on Windows 11 26300; #2963 by its title is the same kind of Series S start). The log stops a few ms aftertitle pipelines to start early, before the title's 3977 MB pool (protection 0x2004, kind 0x42000, flags 0x23) is logged.jhon17parizotto-byte put lines around the call (#3234, run 2): the call is
size=4170186752 base=0 kind=0x42000 flags=0x23 protect=PAGE_NOACCESS, so a placeholder reservation at an address of our choice (MEM_ADDRESS_REQUIREMENTS, [4 GiB, 128 GiB) sincec71e16e2). "before VirtualAlloc2" was logged, "after" never was. The thread had 91.6 s of kernel time 90 s later. Just before the call (run 3), the largest free run below 128 GiB was 2,047 MB. The request was 3,977 MB.rlenci99 reproduced it without the game on Windows 11 26200 (#3234,
vatest.c): an address-constrainedVirtualAlloc2into a range of 1 GiB or more where no free run holds the request (fully reserved, or with only a 1 MiB run free) was still in the kernel after 78 to 99 minutes, at 99.8 % privileged time. Small fully-reserved ranges (64 to 512 MiB) returned error 8 in microseconds. Every call whose range had a run that fits was placed in 4 to 13 µs.So the refusal we count on does not always come. .04's spare does not help here: it is given back only after a refused call, and a call that never returns never reaches the give-back (as jhon17parizotto-byte noted).
Root cause
We hand Windows searches it cannot satisfy. Every reservation we place with address requirements goes straight to
VirtualAlloc2, with no check that the range has room for it:crates/victory-hle/src/modules/xmem.rs:XMemVirtualAlloc: every request with no base of the title's (constrained), inaddress_range(flags)= [4 GiB, 2^37) (TITLE_TOP_BITS = 37,c71e16e2), or the low 4 GiB for 32-bit ones. This includes the Series S pool, the 6.5 GB TileHeap, and everyXMemAllocDefaultgraphics block (virtual_alloc).watched_reservation: everyXMemAllocDefaultheap block of 1 MiB or more,MEM_RESERVE | MEM_COMMIT | MEM_WRITE_WATCH, in the same window. #3023 bisected the hang to78324212and booted with it reverted. That commit is the placed write watch (watch_placement), but it also moved these blocks off the host heap into reservations of their own, placed bottom-up, so into the low addresses the window is in (later limited toaddress_range). jhon17parizotto-byte's run withwatch_placement = falsestill hung (#3234), which fits the second part: a window that fills earlier. That reading is ours, not measured.reserve_title_spare(f72cec77): 8 GiB top-down in the window at start.crates/victory-gpu/src/upload.rs,allocate_in_window:reserve_space's 32 pieces of 64 MiB (top-down),reserve_early's 64 MiBMEM_WRITE_WATCHpieces (3,200 MB with the structure builder), andreserve's arenas. #2973's freeze at frame 2 with ray tracing (a process that could not be ended, 3 of 3 runs) went away withVICTORY_LOW_EARLY_MB=0(0 of 3), which fits a fuller window too; not shown to be this.largest_free_gapalready walked the free runs, but only for the log, after a refusal.Fix
A new module,
crates/victory-gpu/src/room.rs, used by every call above:room(space, lowest, highest, size, alignment, hint)walks the regions of the range (VirtualQuery; no search in the kernel). It returns the first place that holdssize(rounded to the host page) atalignment(at least 64 KiB) inside[lowest, highest], if there is one. The first 64 KiB are never room. The walk starts at the caller'shint(where room was found the last time) and comes round tolowest, so the common case reads a region or two. Only a request that fits nowhere walks the whole window.reserve_in(space, ..., hint, reserve)callsreserve(the caller's ownVirtualAlloc2, unchanged) only ifroomfound a place. Otherwise it returnsNonewithout calling, withERROR_NOT_ENOUGH_MEMORYas the thread's last error, which is what Windows gives when it does refuse. Our searches take turns on one lock (SEARCHES), so one of ours cannot take the run another has just seen. A walk over 20 ms is logged (first, then each power of two) with its region count.Spaceis a trait (Host= this process), so the tests can give it a fake address space.In
xmem.rs:XMemVirtualAlloc's constrained path goes throughplace_in_window: ask (if there is room), and if that does not place it, giveTITLE_SPAREback before Windows is asked again, then ask once more (again only with room). The "no room at first" line gainshost_asked(false: Windows was not asked, no room).watched_reservation: no room means no reservation, so the block comes from the host heap, asXMemAllocDefaultalready does when the reservation fails.reserve_title_spare: through the same check.largest_free_gapisroom::largest_freenow (same output: largest run, number of runs).In
upload.rs,allocate_in_windowgoes throughroom::reserve(no room:Err(8), whichreserve_space,reserve_earlyandreservealready handle).What the title then gets: the Series S pool and the TileHeap are refused (null) when nothing in the window holds them, even after the spare is given back. So a PC whose window is that full gets the title's own crash on the refusal (
+0x1e6c284for the TileHeap, #2081) instead of an unkillable process and a hard power-off. Getting such a PC to boot is a separate question: a fallback above 128 GiB (#2133) or a smaller spare (#3353). Both work with this: #2133's second call goes through the same check if it is placed insideplace_in_window.Verification
Windows 11 26200, rustc 1.98.1 (the pinned toolchain), Ryzen 7 9800X3D. On
b0416267:cargo check -j 6 --locked -p victory-gpu -p victory-hle --all-targets: passes (the crates' existing warnings only).cargo test -j 6 --locked -p victory-gpu --lib room::: 7 passed, 0 failed.a_request_no_free_run_holds_is_refused_without_asking: #3234's window (free runs of 1,100 MB, 2,047 MB and 64 KiB, the rest taken in 64 MiB pieces with 64 KiB gaps). The 4,170,186,752-byte pool is asked for on a thread of its own through a fake "kernel" that never returns when nothing fits. It comes back refused within the 10 s limit, and the kernel was never asked.a_request_that_fits_is_asked_for_and_placed: 2,000 MiB goes to the 2,047 MB run, then 100 MiB to the 1,100 MB run (the walk comes round from the hint), each asked once.a_place_is_aligned_as_asked,the_walk_starts_at_the_hint_and_comes_round,free_runs_end_at_the_range_end,the_first_64_kib_are_never_room: alignment (64 KiB and 2 MiB), page rounding, the hint inside a used region, inside a free run and outside the range, runs clipped at the range's end, a range ending atusize::MAX, the first 64 KiB.the_host_walk_sees_a_hole_in_our_own_reservation: the realVirtualQuerywalk. A 256 MiB placeholder of our own (top-down, fixed by Windows, no requirements) is split and its middle 64 MiB released. The walk sees one free run of 64 MiB, places 32 and 64 MiB at the hole and not 64 MiB + 4 KiB, andreserve_inrefuses 128 MiB without calling, with error 8. No constrainedVirtualAlloc2is made.cargo test -j 6 --locked -p victory-hle --lib modules::xmem::tests::: 45 passed, 1 failed, 1 ignored. The failure isa_read_by_range_waits_only_for_a_remapping_that_meets_it("a read apart from the remapping had to wait", 7025 vs 0), the range-lock test known to fail beside the other tests (#2439: 9 in 10 runs; #3621 moves it to a process of its own). It does no reservation of ours. Run alone (-- --exact): 1 passed. The rest with--skipit: 45 passed, 0 failed, 1 ignored. The new ones:the_title_heap_is_placed_after_the_spare_is_given_back_without_a_blind_search: #2081's window (two 24 GiB title pools, 36 + 28 GiB of the driver's at 60 and 96 GiB, the 2 GiB upload pool, the 8 GiB spare in the one run that holds it, 2 GiB left). The 6,538,919,936-byte heap (flags 0x23) on its own thread, fake kernel as above:First::NoRoom, the kernel not asked before the spare is given back, then placed where the spare was, asked once, within 10 s.a_reservation_with_no_room_and_no_spare_is_refused_at_once: the same with no spare: refused, never asked, the log figures right (largest run 2 GiB).a_reservation_that_fits_is_asked_for_and_a_refused_one_gets_the_spare: 1 GiB is placed at 124 GiB. One refused by "Windows" (refuse_first, asVICTORY_TEST_REFUSE_MB) still gets the spare.graphics_memory_types_are_title_graphics_memory,alloc_honours_alignment_and_freesandtitle_memory_stays_within_the_by_address_directorypass. They make real reservations through the new path in the test process's empty window.cargo clippy -j 6 --locked -p victory-gpu -p victory-hle --all-targets: finishes with warnings only. None is inroom.rsor on a line this changes inxmem.rs,upload.rsorlib.rs(checked againstgit diff -U0 41adb551 b0416267). The first run flaggedroom.rs:60(then→then_some), fixed in this commit.NOT tested
VirtualQueryis some microseconds a region. The window holds the title's placeholders and whatever they are split into (#3279 counted 93k regions in the whole process). With the hint, a request that fits reads a few regions. A request that does not fit walks the whole window once, and twice if the spare is given back. The 20 ms warning will show it if it matters.victory run <exe> --console series-s --execute, DLSS Performance at 1080p, frame generation off, the shader cache warm. Before: the log ends aftertitle memory asked for as protection 0x4, kind 0x203000, flags 0x3: 4 times, 82 MBand the process cannot be ended. After: within a second of that point,XMemVirtualAlloc: no room at first in the title's window size=4170186752 ... host_asked=false ... spare_given_back=trueand either the pool placed orXMemVirtualAlloc refusedand the title's own crash, a process that can be ended.Overlap
gh pr list --state open --searchfor "VirtualAlloc2", "xmem", "XMemVirtualAlloc", "spare", "free gap", "write-watch" (2026-11-30).git merge-treeof this branch with each PR head:watch_placement = false) still hung, so it is not enough alone, and this does not replace it.allocate(kind), and it already conflicts with main there (1 hunk). Complementary: it is what lets a full window boot instead of being refused. Its second call should go throughplace_in_window/room::reservewith the console's top ashighest(that range is nearly empty, so the check is short).upload.rs::reserve): merges cleanly. Its backoff is inreserve; this is insideallocate_in_window.XMemVirtualAlloc): 1 conflict hunk, both rewritelet mut at = ...inXMemVirtualAlloc. Its deferred path is for title-placed commits (base given), so the two compose: take itsdeferredbranch first, then this branch'sif constrainedblock.PAGE_NOACCESS): merges cleanly.watched_reservation,allocate_in_window), and names draft #3293 forupload.rs. No open PR does it.AI use
Claude Code (Claude Opus 5.5) read the issues' text (no attachments), wrote the change and its tests, ran the checks listed above, and wrote this note. Nothing was run in game.
🤖 Generated with Claude Code
@biishop on GitHub · 2026-11-30 11:42 UTC · original
In-game test of #3787 (together with #3353): Series S boots, 3/3, no freeze
Rig: RTX 4070 Ti 12 GB, driver 610.88, 64 GB RAM, Windows 11 26300, Streamline 2.14.16.
Build: local build of
v2026.11.29.05(41adb551) + #3787 (b0416267) + #3353 (25ee3b48), clean merge,cargo build --release --locked -p victory.cargo test -p victory-gpu room: 25 passed.Settings: Series S, scene 540p, DLSS performance,
VICTORY_TITLE_SPARE_MBunset (so #3353's 6,300 MiB default applies).Before: vanilla .05 with the same settings, FG off, hung twice the same morning (#2191/#3023 symptoms: white "Americas" window, one core at 100 %, process can't be killed, whole PC frozen, Kernel-Power 41 + WHEA after a reboot).
With the two PRs:
0x1b000000000x1b000000000x1dcea100000x1b000000000x1deb1d0000Runs 2 and 3 hit exactly the case this PR describes: a constrained request with no free run big enough. Before, that call never came back from the kernel. Run 3 log excerpt:
host_asked=false: Windows was never asked for the reservation that could not fit. The spare from #3353 was then returned, and the retry succeeded right away. So the two PRs work together here: #3787 prevents the kernel hang, and #3353 makes sure there is room on the retry. Frame generation only takes up more of the window (633 → 178 MB largest free run); it is not the cause.Small side note: the room walk logs a "took long" warning at 64–164 ms over ~15–17k regions. It is harmless at boot, but worth knowing if it runs during gameplay.
Logs available on request.
b0416267f0to528fa39bcb@Lyrnc on GitHub · 2026-11-30 18:59 UTC · original
@biishop, thank you, this is the case the PR was written for and we could not run it ourselves. Runs 2 and 3 took the no-room path:
host_asked=false, so Windows was not asked for the 1,632 MB that no free run held (largest 633 MB and 178 MB). Then the spare was given back and the second ask found room. Before, that call never came back.About the "took long" line (64-164 ms over 15-17k regions): that is the walk of a request that fits nowhere. A walk starts at the hint, where room was found the last time, so a request that fits reads a few regions. Only a request that fits nowhere walks the whole window, once, and once more after the spare is given back. During play the requests that can end up there are
XMemAllocDefaultheap blocks of 1 MiB and more when the window is full. Without this PR, such a request may never come back at all. If the line shows up during play, the next step would be to keep the window's free runs between asks instead of walking again. The line is there so we can tell.Since your test, the branch is rebased onto main
84bd61e2(v2026.11.30.02) and force-pushed (now528fa39b).#3767 is merged in v2026.11.30.01 and does part of the same job. For a constrained, non-top-down
XMemVirtualAlloc, it walks the window itself and givesVirtualAlloc2a fixed address, so the kernel searches nothing when there is room (#3765's case). But when its walk finds no room, it falls back to the kernel's constrained search, as before, which is the call that hung in #3234 and in your runs before. This PR still adds:release_title_sparealso frees #4043's 512 MB below 4 GiB);watched_reservation,reserve_title_spare, upload.rs'sallocate_in_window, and .30.02'sreserve_low_spare, which this commit now routes throughroom::reserveas well.The only textual conflict was in the tests (both sets kept). With both PRs, a constrained
XMemVirtualAllocis checked for room first, underSEARCHES, and then placed by #3767's walk at a fixed address. That walk also runs underSEARCHES. So the window is walked twice for such a request. A follow-up could passroom's place to the fixed-address call, or drop one of the two walkers. I left that out of the rebase.Checks on
528fa39b(Windows 11, rustc 1.98.1, its own target dir):cargo check -p victory-gpu -p victory-hlepasses, with only main's one warning.cargo test -p victory-gpu --lib -- room::: 7 passed.cargo test -p victory-hle --lib -- modules::xmem::tests::: 49 passed, 1 failed, 1 ignored. The failure isa_read_by_range_waits_only_for_a_remapping_that_meets_it("a read apart from the remapping had to wait", 6118 vs 0). That is the range-lock timing test that fails beside the others on main as well (#3767's description says the same; #3621 moves it into its own process). Run alone, it passes. The rest with it skipped: 49 passed, 1 ignored. #3767's two tests pass with this branch.Nothing was run in game.
AI use: Claude Code (Claude Opus 5.5) did the rebase, ran the tests and wrote this reply.
528fa39bcbtofa23d88dd6View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.