xmem: host memory fills the space below 4 GiB, so the title's 32-bit placeholder is refused at startup (fix on a branch) #790

Closed
opened 2026-11-26 04:13:58 +00:00 by github-bot · 3 comments
Owner

@⁠NuraadGit on GitHub · 2026-11-24 10:59 UTC · original

What happens

At startup, Grand Theft Auto VI asks XMemVirtualAlloc for a 185 MB placeholder with the 32-bit address flag (size=193986560 kind=0x42000 flags=0x7; ADDRESS_32BIT = 4, so address_range gives 0..4 GiB). If the host's own memory has already filled the space below 4 GiB, VirtualAlloc2 fails with ERROR_NOT_ENOUGH_MEMORY. The title then stops at its own assertion, 0x80000003 at +0x19f4f58 (a check right after window setup), about 3 s after the D3D12 device is made.

Windows allocates bottom up, so the host's early memory lands below 4 GiB first. That includes driver allocations, heap segments, the executable read in run, and cache data. main doesn't log the refusal (only the title's assertion shows), which makes this hard to spot.

Evidence (RTX 2080, Windows 11, 32 GB)

A temporary probe in the refusal path walked 0..4 GiB at the moment of failure:

XMemVirtualAlloc refused size=193986560 kind=0x42000 flags=0x7 error=... (os error 8)
range below the limit: want=193986560 free_total=22515712 largest_free=14213120 regions=167
  0x2f230000 1024 MB private committed
  0x7fff0000 1024 MB private committed
  0xbfff0000  256 MB mapped
  2 x 114 MB private reserved, dozens of 32 MB private committed blocks ...

That leaves 22 MB free below 4 GiB, with a largest hole of 14 MB. How often it happens depends on how much the host allocates early:

  • With a large pipeline cache it failed 2 of 3 startups (a build of main plus open PRs).
  • With an empty cache directory it started every time.
  • With the D3D12 debug layer (VICTORY_D3D12_DEBUG=1) it failed every time on this machine, through the same assertion. That's probably why GPU-based validation was unusable here.

Fix

Branch: NuraadGit:xmem/guard-32bit-window, commit ab749fd on main ffe310e, +181 lines in two files.

  • Install at startup: xmem::low_guards::install() runs at the start of run when executing, before the image read, the device and the caches. It reserves the free space below 4 GiB except the lowest 256 MB, which is left to the host.
  • Make room on refusal: a 32-bit XMemVirtualAlloc that finds no room releases the smallest guard that fits it (else the largest) and retries the same call. It then guards whatever is still free of that hole.
  • The normal path is unchanged. It's only a retry on refusal, so write-watch and placeholder semantics stay exactly as they are.
  • Test: low_guards::tests::a_released_guard_is_guarded_again_around_what_took_it.

Result on the same machine and build: 5 of 5 startups passed, with 3.7 GB below 4 GiB kept for the title. Before the fix it failed 2 of 3.

AI-assisted (Claude Code): the probe, fix, test and runs were automated. The hardware, title copy and runs are the user's.

**@⁠NuraadGit** on GitHub · 2026-11-24 10:59 UTC · [original](https://github.com/Marvisak/VIctory/issues/790) ## What happens At startup, Grand Theft Auto VI asks `XMemVirtualAlloc` for a **185 MB placeholder with the 32-bit address flag** (`size=193986560 kind=0x42000 flags=0x7`; `ADDRESS_32BIT` = 4, so `address_range` gives `0..4 GiB`). If the host's own memory has already filled the space below 4 GiB, `VirtualAlloc2` fails with `ERROR_NOT_ENOUGH_MEMORY`. The title then stops at its own assertion, `0x80000003` at `+0x19f4f58` (a check right after window setup), about 3 s after the D3D12 device is made. Windows allocates bottom up, so the host's early memory lands below 4 GiB first. That includes driver allocations, heap segments, the executable read in `run`, and cache data. `main` doesn't log the refusal (only the title's assertion shows), which makes this hard to spot. ## Evidence (RTX 2080, Windows 11, 32 GB) A temporary probe in the refusal path walked `0..4 GiB` at the moment of failure: ``` XMemVirtualAlloc refused size=193986560 kind=0x42000 flags=0x7 error=... (os error 8) range below the limit: want=193986560 free_total=22515712 largest_free=14213120 regions=167 0x2f230000 1024 MB private committed 0x7fff0000 1024 MB private committed 0xbfff0000 256 MB mapped 2 x 114 MB private reserved, dozens of 32 MB private committed blocks ... ``` That leaves 22 MB free below 4 GiB, with a largest hole of 14 MB. How often it happens depends on how much the host allocates early: - **With a large pipeline cache** it failed 2 of 3 startups (a build of main plus open PRs). - **With an empty cache directory** it started every time. - **With the D3D12 debug layer** (`VICTORY_D3D12_DEBUG=1`) it failed every time on this machine, through the same assertion. That's probably why GPU-based validation was unusable here. ## Fix Branch: [NuraadGit:xmem/guard-32bit-window](https://github.com/NuraadGit/VIctory/tree/xmem/guard-32bit-window), commit `ab749fd` on `main` `ffe310e`, +181 lines in two files. - **Install at startup:** `xmem::low_guards::install()` runs at the start of `run` when executing, before the image read, the device and the caches. It reserves the free space below 4 GiB except the lowest 256 MB, which is left to the host. - **Make room on refusal:** a 32-bit `XMemVirtualAlloc` that finds no room releases the smallest guard that fits it (else the largest) and retries the same call. It then guards whatever is still free of that hole. - **The normal path is unchanged.** It's only a retry on refusal, so write-watch and placeholder semantics stay exactly as they are. - **Test:** `low_guards::tests::a_released_guard_is_guarded_again_around_what_took_it`. Result on the same machine and build: 5 of 5 startups passed, with 3.7 GB below 4 GiB kept for the title. Before the fix it failed 2 of 3. *AI-assisted (Claude Code): the probe, fix, test and runs were automated. The hardware, title copy and runs are the user's.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:13:58 +00:00
Author
Owner

@⁠LAKSHYA-cmd-tech on GitHub · 2026-11-24 11:11 UTC · original

Verified and merged downstream in https://github.com/LAKSHYA-cmd-tech/VIctory/pull/11.

  • Installed \xmem::low_guards::install()\ at the start of
    un\ to preserve address space below 4 GiB for GTA VI's 185 MB 32-bit placeholder.
  • Verified on Windows 11: all 103 \ ictory-hle\ tests pass cleanly including \low_guards::tests::a_released_guard_is_guarded_again_around_what_took_it.
**@⁠LAKSHYA-cmd-tech** on GitHub · 2026-11-24 11:11 UTC · [original](https://github.com/Marvisak/VIctory/issues/790#issuecomment-7129773769) Verified and merged downstream in https://github.com/LAKSHYA-cmd-tech/VIctory/pull/11. - Installed \xmem::low_guards::install()\ at the start of \ un\ to preserve address space below 4 GiB for GTA VI's 185 MB 32-bit placeholder. - Verified on Windows 11: all 103 \ ictory-hle\ tests pass cleanly including \low_guards::tests::a_released_guard_is_guarded_again_around_what_took_it\.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 03:53 UTC · original · edited 2026-11-25 12:44 UTC

Automated triage for the maintainers. Confirmed by reading main (940d32f): XMemVirtualAlloc in crates/victory-hle/src/modules/xmem.rs limits a request with the 32-bit flag to 0..4 GiB (address_range). Nothing keeps the host's own early allocations out of that range, and the refusal is not logged. A large 32-bit placeholder can therefore fail whenever the host has already used most of the low 4 GiB, as the probe above shows. None of the changes merged since the first triage touch this.

Open PR #1009 (keep the space below 4 GiB for the title's 32-bit memory) carries this fix. The comment from WHOISJARDAS adds a second trigger that makes it fail every time: Bottom-up ASLR turned off system-wide (RX 9070 XT, 4 of 4 starts stopped at +0x19f4f58). #1009's guards fixed that case too (3 of 3 starts). Until it lands, turning Bottom-up ASLR back on, or forcing it for victory.exe, works around it.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 03:53 UTC · [original](https://github.com/Marvisak/VIctory/issues/790#issuecomment-7152328515) · edited 2026-11-25 12:44 UTC <!-- victory-issue-triage v1 verdict=confirmed seen=2026-11-25T12:05:50Z at=2026-11-25T12:44:24Z --> Automated triage for the maintainers. Confirmed by reading `main` (940d32f): `XMemVirtualAlloc` in `crates/victory-hle/src/modules/xmem.rs` limits a request with the 32-bit flag to `0..4 GiB` (`address_range`). Nothing keeps the host's own early allocations out of that range, and the refusal is not logged. A large 32-bit placeholder can therefore fail whenever the host has already used most of the low 4 GiB, as the probe above shows. None of the changes merged since the first triage touch this. Open PR #1009 (keep the space below 4 GiB for the title's 32-bit memory) carries this fix. The comment from WHOISJARDAS adds a second trigger that makes it fail every time: Bottom-up ASLR turned off system-wide (RX 9070 XT, 4 of 4 starts stopped at `+0x19f4f58`). #1009's guards fixed that case too (3 of 3 starts). Until it lands, turning Bottom-up ASLR back on, or forcing it for `victory.exe`, works around it. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠WHOISJARDAS on GitHub · 2026-11-25 12:05 UTC · original

Another trigger that makes this deterministic: Windows Security, Exploit protection, Randomize memory allocations (Bottom-up ASLR) turned Off system-wide (Get-ProcessMitigation -System shows BottomUp: OFF; the default is On). With it off, every host allocation starts at the lowest free address.

AMD Radeon RX 9070 XT (driver 32.0.32029.2010), Windows 11 26200, title build b99f876b: the title stopped at +0x19f4f58 on 4 of 4 starts. A probe in the refusal path found 3 MB free below 4 GiB, largest hole 64 KiB, 1,635 regions. 2.3 GB of it was the AMD driver's shader cache files (%LOCALAPPDATA%\AMD\DxcCache\*.parc, one of 1.5 GB) mapped there, plus 1.7 GB of private memory.

Two checks:

  • The same unpatched build started with bottom-up and high-entropy ASLR forced on for that one process (PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY with BOTTOM_UP_ASLR_ALWAYS_ON | HIGH_ENTROPY_ASLR_ALWAYS_ON, no system change) reached the menus at 30 fps.
  • With #1009's guards (ported to another tree) and the setting still off: 3 of 3 starts reached the menus, guards=2 mb=3797..3805.

So #1009 covers this case too. For anyone hitting the int3 without it, turning Bottom-up ASLR back on (or forcing it for victory.exe under "Program settings") is a workaround.

AI-assisted (Claude Code). Hashes, offsets, sizes and the runtime's own log text only.

**@⁠WHOISJARDAS** on GitHub · 2026-11-25 12:05 UTC · [original](https://github.com/Marvisak/VIctory/issues/790#issuecomment-7161914223) Another trigger that makes this deterministic: Windows Security, Exploit protection, *Randomize memory allocations (Bottom-up ASLR)* turned **Off** system-wide (`Get-ProcessMitigation -System` shows `BottomUp: OFF`; the default is On). With it off, every host allocation starts at the lowest free address. AMD Radeon RX 9070 XT (driver 32.0.32029.2010), Windows 11 26200, title build `b99f876b`: the title stopped at `+0x19f4f58` on 4 of 4 starts. A probe in the refusal path found 3 MB free below 4 GiB, largest hole 64 KiB, 1,635 regions. 2.3 GB of it was the AMD driver's shader cache files (`%LOCALAPPDATA%\AMD\DxcCache\*.parc`, one of 1.5 GB) mapped there, plus 1.7 GB of private memory. Two checks: - The same unpatched build started with bottom-up and high-entropy ASLR forced on for that one process (`PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY` with `BOTTOM_UP_ASLR_ALWAYS_ON | HIGH_ENTROPY_ASLR_ALWAYS_ON`, no system change) reached the menus at 30 fps. - With #1009's guards (ported to another tree) and the setting still off: 3 of 3 starts reached the menus, `guards=2 mb=3797..3805`. So #1009 covers this case too. For anyone hitting the int3 without it, turning Bottom-up ASLR back on (or forcing it for `victory.exe` under "Program settings") is a workaround. AI-assisted (Claude Code). Hashes, offsets, sizes and the runtime's own log text only.
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#790
No description provided.