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

Open
Lyrnc wants to merge 1 commit from upstream-pr/3787 into main
Lyrnc commented 2026-11-30 07:11:10 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Lyrnc on 2026-11-30T07:11:10Z.


Problem

Since v2026.11.29.01 the Series S profile can hang at boot inside VirtualAlloc2. The process cannot be ended, tasklist hangs, 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 after title 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) since c71e16e2). "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-constrained VirtualAlloc2 into 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), in address_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 every XMemAllocDefault graphics block (virtual_alloc).
    • watched_reservation: every XMemAllocDefault heap block of 1 MiB or more, MEM_RESERVE | MEM_COMMIT | MEM_WRITE_WATCH, in the same window. #3023 bisected the hang to 78324212 and 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 to address_range). jhon17parizotto-byte's run with watch_placement = false still 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 MiB MEM_WRITE_WATCH pieces (3,200 MB with the structure builder), and reserve's arenas. #2973's freeze at frame 2 with ray tracing (a process that could not be ended, 3 of 3 runs) went away with VICTORY_LOW_EARLY_MB=0 (0 of 3), which fits a fuller window too; not shown to be this.

largest_free_gap already 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 holds size (rounded to the host page) at alignment (at least 64 KiB) inside [lowest, highest], if there is one. The first 64 KiB are never room. The walk starts at the caller's hint (where room was found the last time) and comes round to lowest, so the common case reads a region or two. Only a request that fits nowhere walks the whole window.
  • reserve_in(space, ..., hint, reserve) calls reserve (the caller's own VirtualAlloc2, unchanged) only if room found a place. Otherwise it returns None without calling, with ERROR_NOT_ENOUGH_MEMORY as 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.
  • Windows still picks the address. The check only says that a fitting run exists, so placements are the same as before wherever there is room.
  • Space is a trait (Host = this process), so the tests can give it a fake address space.

In xmem.rs:

  • XMemVirtualAlloc's constrained path goes through place_in_window: ask (if there is room), and if that does not place it, give TITLE_SPARE back before Windows is asked again, then ask once more (again only with room). The "no room at first" line gains host_asked (false: Windows was not asked, no room).
  • watched_reservation: no room means no reservation, so the block comes from the host heap, as XMemAllocDefault already does when the reservation fails.
  • reserve_title_spare: through the same check.
  • largest_free_gap is room::largest_free now (same output: largest run, number of runs).

In upload.rs, allocate_in_window goes through room::reserve (no room: Err(8), which reserve_space, reserve_early and reserve already 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 (+0x1e6c284 for 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 inside place_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 at usize::MAX, the first 64 KiB.
    • the_host_walk_sees_a_hole_in_our_own_reservation: the real VirtualQuery walk. 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, and reserve_in refuses 128 MiB without calling, with error 8. No constrained VirtualAlloc2 is made.
  • cargo test -j 6 --locked -p victory-hle --lib modules::xmem::tests::: 45 passed, 1 failed, 1 ignored. The failure is a_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 --skip it: 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, as VICTORY_TEST_REFUSE_MB) still gets the spare.
    • The existing graphics_memory_types_are_title_graphics_memory, alloc_honours_alignment_and_frees and title_memory_stays_within_the_by_address_directory pass. 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 in room.rs or on a line this changes in xmem.rs, upload.rs or lib.rs (checked against git diff -U0 41adb551 b0416267). The first run flagged room.rs:60 (then → then_some), fixed in this commit.

NOT tested

  • No game run, on purpose: a hang here needs a hard power-off. Not run on the Series S profile, on Windows 11 26300 (where the reports are), or on any PC whose window is full.
  • No probe of the real hang. The tests never ask Windows for a reservation that cannot fit. The Host test only makes fixed reservations and placeholder splits of its own, then runs the walk over them. Whether the check removes every hang rests on rlenci99's table: every hang had no fitting run, every call with one returned in microseconds. If a constrained call can hang with a fitting run, this does not cover it.
  • The walk's cost in game is not measured. VirtualQuery is 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.
  • Others' reservations between the check and the call are not covered. Only our own searches take turns. The driver (nvcuda's 36 + 28 GiB in #2081) or another library reserving the same run in those microseconds would bring the old hang back.
  • #3273's stop in the shader-cache walk is not shown to be this. That process was idle (16 s of CPU in 3 minutes), not spinning in the kernel like the hangs above. #3353 (spare 6,300 MiB) is what fixed it there.
  • Exact repro once someone can risk a hard power-off (Windows 11 26300, Series S files): victory run <exe> --console series-s --execute, DLSS Performance at 1080p, frame generation off, the shader cache warm. Before: the log ends after title memory asked for as protection 0x4, kind 0x203000, flags 0x3: 4 times, 82 MB and 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=true and either the pool placed or XMemVirtualAlloc refused and the title's own crash, a process that can be ended.

Overlap

gh pr list --state open --search for "VirtualAlloc2", "xmem", "XMemVirtualAlloc", "spare", "free gap", "write-watch" (2026-11-30). git merge-tree of this branch with each PR head:

  • #3126 (TheSovietWaffle, "title-placed reservations are write-watched only when asked for", #3023): merges cleanly. It is the other half: reservations at the title's own address, which do not search. jhon17parizotto-byte's run 1 in #3234 (watch_placement = false) still hung, so it is not enough alone, and this does not replace it.
  • #2133 (bstillbstill, fallback above 128 GiB when nothing below has room): 1 conflict hunk, on the line after the first 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 through place_in_window / room::reserve with the console's top as highest (that range is nearly empty, so the check is short).
  • #3242 (vanatorr, log large reservations before the call): 1 conflict hunk, the same line; it also conflicts with main there already. With this, the line can say whether Windows is asked at all.
  • #3353 (kibagami-nc, spare 6,300 MiB, #3273): merges cleanly. Complementary (the spare's size, not the search).
  • #3293 (spk-c, coalesce failed window searches in upload.rs::reserve): merges cleanly. Its backoff is in reserve; this is inside allocate_in_window.
  • #3738 (rdj415, lazy commit for XMemVirtualAlloc): 1 conflict hunk, both rewrite let mut at = ... in XMemVirtualAlloc. Its deferred path is for title-placed commits (base given), so the two compose: take its deferred branch first, then this branch's if constrained block.
  • #2725 (placeholders with PAGE_NOACCESS): merges cleanly.
  • rlenci99's comment in #3234 suggests exactly this check before every such call (watched_reservation, allocate_in_window), and names draft #3293 for upload.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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5560740447 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3787). Originally posted by [Lyrnc](https://github.com/Lyrnc) on 2026-11-30T07:11:10Z. --- ## Problem Since v2026.11.29.01 the Series S profile can hang at boot inside `VirtualAlloc2`. The process cannot be ended, `tasklist` hangs, 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 after `title 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) since c71e16e2). "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-constrained `VirtualAlloc2` into 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`), in `address_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 every `XMemAllocDefault` graphics block (`virtual_alloc`). - `watched_reservation`: every `XMemAllocDefault` heap block of 1 MiB or more, `MEM_RESERVE | MEM_COMMIT | MEM_WRITE_WATCH`, in the same window. #3023 bisected the hang to 78324212 and 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 to `address_range`). jhon17parizotto-byte's run with `watch_placement = false` still 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 MiB `MEM_WRITE_WATCH` pieces (3,200 MB with the structure builder), and `reserve`'s arenas. #2973's freeze at frame 2 with ray tracing (a process that could not be ended, 3 of 3 runs) went away with `VICTORY_LOW_EARLY_MB=0` (0 of 3), which fits a fuller window too; not shown to be this. `largest_free_gap` already 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 holds `size` (rounded to the host page) at `alignment` (at least 64 KiB) inside `[lowest, highest]`, if there is one. The first 64 KiB are never room. The walk starts at the caller's `hint` (where room was found the last time) and comes round to `lowest`, so the common case reads a region or two. Only a request that fits nowhere walks the whole window. - `reserve_in(space, ..., hint, reserve)` calls `reserve` (the caller's own `VirtualAlloc2`, unchanged) only if `room` found a place. Otherwise it returns `None` without calling, with `ERROR_NOT_ENOUGH_MEMORY` as 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. - Windows still picks the address. The check only says that a fitting run exists, so placements are the same as before wherever there is room. - `Space` is a trait (`Host` = this process), so the tests can give it a fake address space. In `xmem.rs`: - `XMemVirtualAlloc`'s constrained path goes through `place_in_window`: ask (if there is room), and if that does not place it, give `TITLE_SPARE` back **before** Windows is asked again, then ask once more (again only with room). The "no room at first" line gains `host_asked` (false: Windows was not asked, no room). - `watched_reservation`: no room means no reservation, so the block comes from the host heap, as `XMemAllocDefault` already does when the reservation fails. - `reserve_title_spare`: through the same check. - `largest_free_gap` is `room::largest_free` now (same output: largest run, number of runs). In `upload.rs`, `allocate_in_window` goes through `room::reserve` (no room: `Err(8)`, which `reserve_space`, `reserve_early` and `reserve` already 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 (`+0x1e6c284` for 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 inside `place_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 at `usize::MAX`, the first 64 KiB. - `the_host_walk_sees_a_hole_in_our_own_reservation`: the real `VirtualQuery` walk. 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, and `reserve_in` refuses 128 MiB without calling, with error 8. No constrained `VirtualAlloc2` is made. - `cargo test -j 6 --locked -p victory-hle --lib modules::xmem::tests::`: **45 passed, 1 failed, 1 ignored.** The failure is `a_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 `--skip` it: **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`, as `VICTORY_TEST_REFUSE_MB`) still gets the spare. - The existing `graphics_memory_types_are_title_graphics_memory`, `alloc_honours_alignment_and_frees` and `title_memory_stays_within_the_by_address_directory` pass. 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 in `room.rs` or on a line this changes** in `xmem.rs`, `upload.rs` or `lib.rs` (checked against `git diff -U0 41adb551 b0416267`). The first run flagged `room.rs:60` (`then` → `then_some`), fixed in this commit. ## NOT tested - **No game run, on purpose:** a hang here needs a hard power-off. Not run on the Series S profile, on Windows 11 26300 (where the reports are), or on any PC whose window is full. - **No probe of the real hang.** The tests never ask Windows for a reservation that cannot fit. The Host test only makes fixed reservations and placeholder splits of its own, then runs the walk over them. Whether the check removes every hang rests on rlenci99's table: every hang had no fitting run, every call with one returned in microseconds. If a constrained call can hang with a fitting run, this does not cover it. - **The walk's cost in game is not measured.** `VirtualQuery` is 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. - **Others' reservations between the check and the call are not covered.** Only our own searches take turns. The driver (nvcuda's 36 + 28 GiB in #2081) or another library reserving the same run in those microseconds would bring the old hang back. - **#3273's stop in the shader-cache walk is not shown to be this.** That process was idle (16 s of CPU in 3 minutes), not spinning in the kernel like the hangs above. #3353 (spare 6,300 MiB) is what fixed it there. - Exact repro once someone can risk a hard power-off (Windows 11 26300, Series S files): `victory run <exe> --console series-s --execute`, DLSS Performance at 1080p, frame generation off, the shader cache warm. Before: the log ends after `title memory asked for as protection 0x4, kind 0x203000, flags 0x3: 4 times, 82 MB` and 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=true` and either the pool placed or `XMemVirtualAlloc refused` and the title's own crash, a process that can be ended. ## Overlap `gh pr list --state open --search` for "VirtualAlloc2", "xmem", "XMemVirtualAlloc", "spare", "free gap", "write-watch" (2026-11-30). `git merge-tree` of this branch with each PR head: - **#3126** (TheSovietWaffle, "title-placed reservations are write-watched only when asked for", #3023): merges cleanly. It is the other half: reservations at the title's own address, which do not search. jhon17parizotto-byte's run 1 in #3234 (`watch_placement = false`) still hung, so it is not enough alone, and this does not replace it. - **#2133** (bstillbstill, fallback above 128 GiB when nothing below has room): 1 conflict hunk, on the line after the first `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 through `place_in_window` / `room::reserve` with the console's top as `highest` (that range is nearly empty, so the check is short). - **#3242** (vanatorr, log large reservations before the call): 1 conflict hunk, the same line; it also conflicts with main there already. With this, the line can say whether Windows is asked at all. - **#3353** (kibagami-nc, spare 6,300 MiB, #3273): merges cleanly. Complementary (the spare's size, not the search). - **#3293** (spk-c, coalesce failed window searches in `upload.rs::reserve`): merges cleanly. Its backoff is in `reserve`; this is inside `allocate_in_window`. - **#3738** (rdj415, lazy commit for `XMemVirtualAlloc`): 1 conflict hunk, both rewrite `let mut at = ...` in `XMemVirtualAlloc`. Its deferred path is for title-placed commits (base given), so the two compose: take its `deferred` branch first, then this branch's `if constrained` block. - #2725 (placeholders with `PAGE_NOACCESS`): merges cleanly. - rlenci99's comment in #3234 suggests exactly this check before every such call (`watched_reservation`, `allocate_in_window`), and names draft #3293 for `upload.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](https://claude.com/claude-code)
biishop commented 2026-11-30 11:42:41 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by biishop on 2026-11-30T11:42:41Z.


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_MB unset (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:

Run FG 3977 MB pool 1632 MB reservation Result
1 off 0x1b00000000 fit on the first try boot OK
2 off 0x1b00000000 largest free run 633 MB → refused, spare returned, placed at 0x1dcea10000 boot OK
3 2x (DLSS FG) 0x1b00000000 largest free run 178 MB → refused, spare returned, placed at 0x1deb1d0000 boot OK

Runs 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:

WARN victory_gpu::room: a placed reservation's look for room took long size=1711669248 regions=16960 ms=100 times=2
WARN victory_hle::modules::xmem: XMemVirtualAlloc: no room at first in the title's window size=1711669248 kind=0x42000 flags=0x23 error=(os error 8) host_asked=false largest_free_mb=178 free_runs=47 spare_given_back=true
INFO victory_hle::modules::xmem: title memory asked for as protection 0x2404, kind 0x42000, flags 0x23: 1 times, 1632 MB, last 0x1deb1d0000+0x66060000

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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7277407602 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3787#issuecomment-7277407602). Originally posted by [biishop](https://github.com/biishop) on 2026-11-30T11:42:41Z. --- 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_MB` unset (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:** | Run | FG | 3977 MB pool | 1632 MB reservation | Result | |---|---|---|---|---| | 1 | off | `0x1b00000000` | fit on the first try | boot OK | | 2 | off | `0x1b00000000` | largest free run **633 MB** → refused, spare returned, placed at `0x1dcea10000` | boot OK | | 3 | 2x (DLSS FG) | `0x1b00000000` | largest free run **178 MB** → refused, spare returned, placed at `0x1deb1d0000` | boot OK | Runs 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: ``` WARN victory_gpu::room: a placed reservation's look for room took long size=1711669248 regions=16960 ms=100 times=2 WARN victory_hle::modules::xmem: XMemVirtualAlloc: no room at first in the title's window size=1711669248 kind=0x42000 flags=0x23 error=(os error 8) host_asked=false largest_free_mb=178 free_runs=47 spare_given_back=true INFO victory_hle::modules::xmem: title memory asked for as protection 0x2404, kind 0x42000, flags 0x23: 1 times, 1632 MB, last 0x1deb1d0000+0x66060000 ``` `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.
Lyrnc commented 2026-11-30 18:59:07 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Lyrnc on 2026-11-30T18:59:07Z.


@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 XMemAllocDefault heap 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 (now 528fa39b).

#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 gives VirtualAlloc2 a 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:

  • the refusal without asking Windows when no run holds the request;
  • giving the spares back before the second ask (with .30.02 that is both: release_title_spare also frees #4043's 512 MB below 4 GiB);
  • the room check for the reservations #3767 does not touch: watched_reservation, reserve_title_spare, upload.rs's allocate_in_window, and .30.02's reserve_low_spare, which this commit now routes through room::reserve as well.

The only textual conflict was in the tests (both sets kept). With both PRs, a constrained XMemVirtualAlloc is checked for room first, under SEARCHES, and then placed by #3767's walk at a fixed address. That walk also runs under SEARCHES. So the window is walked twice for such a request. A follow-up could pass room'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-hle passes, 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 is a_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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7288664851 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3787#issuecomment-7288664851). Originally posted by [Lyrnc](https://github.com/Lyrnc) on 2026-11-30T18:59:07Z. --- @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 `XMemAllocDefault` heap 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 (now 528fa39b). #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 gives `VirtualAlloc2` a 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: - the refusal without asking Windows when no run holds the request; - giving the spares back before the second ask (with .30.02 that is both: `release_title_spare` also frees #4043's 512 MB below 4 GiB); - the room check for the reservations #3767 does not touch: `watched_reservation`, `reserve_title_spare`, upload.rs's `allocate_in_window`, and .30.02's `reserve_low_spare`, which this commit now routes through `room::reserve` as well. The only textual conflict was in the tests (both sets kept). With both PRs, a constrained `XMemVirtualAlloc` is checked for room first, under `SEARCHES`, and then placed by #3767's walk at a fixed address. That walk also runs under `SEARCHES`. So the window is walked twice for such a request. A follow-up could pass `room`'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-hle` passes, 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 is `a_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.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3787:upstream-pr/3787'
git switch 'upstream-pr/3787'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3787'
git switch 'upstream-pr/3787'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3787'
git switch 'upstream-pr/3787'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3787'
git switch 'main'
git merge --squash 'upstream-pr/3787'
git switch 'main'
git merge --ff-only 'upstream-pr/3787'
git switch 'main'
git merge 'upstream-pr/3787'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
trustno1-coder/VIctory-NVIDIA!3787
No description provided.