d3d12: XMemVirtualAlloc refused (~185 MB) then 0x80000003 on a PC with 31 GB of RAM #3337

Open
opened 2026-12-03 14:20:54 +00:00 by MoonEyes · 2 comments
MoonEyes commented 2026-12-03 14:20:54 +00:00 (Migrated from github.com)
Contributor

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T14:20:54Z.


What happens

A player with an RX 7800 XT and 31 GB of RAM (commit limit 91 GB), Series S, no frame generation, -Log: the newest play log ends with an XMemVirtualAlloc refused warning for about 185 MB ("not enough memory resources"), followed by unhandled exception 0x80000003. Another player stopped with code 2147483651 (also 0x80000003) the same day, without a log.

Why it matters

With that much RAM and commit room, the refusal is more likely an address range already taken than memory running out. #3154 (reserving the title's address range) may cover it; not checked.

Needs

The full play log of an affected run (local), and a check of which range the refused allocation asked for.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:6770645714 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/issues/3337). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-03T14:20:54Z. --- ### What happens A player with an RX 7800 XT and 31 GB of RAM (commit limit 91 GB), Series S, no frame generation, `-Log`: the newest play log ends with an `XMemVirtualAlloc refused` warning for about 185 MB ("not enough memory resources"), followed by `unhandled exception 0x80000003`. Another player stopped with code 2147483651 (also `0x80000003`) the same day, without a log. ### Why it matters With that much RAM and commit room, the refusal is more likely an address range already taken than memory running out. #3154 (reserving the title's address range) may cover it; not checked. ### Needs The full play log of an affected run (local), and a check of which range the refused allocation asked for. AI-assisted (Claude Code).
MoonEyes commented 2026-12-03 14:24:57 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T14:24:57Z.


Code reading at main 9039f6a31 (no run):

  • The warning is logged at d3d12/crates/leonida-hle/src/modules/xmem.rs ~266, only for a reserve (a refused commit goes to commit_refused instead). The host call is VirtualAlloc2 with address bounds from address_range (~93-100): [0, 4 GiB) when the title asks for a 32-bit address, [4 GiB, 2^40) otherwise.
  • "not enough memory resources" is ERROR_NOT_ENOUGH_MEMORY: for a bounded reserve that means no free range of that size in the bounds, not RAM or commit running out.
  • On refusal the title gets a null pointer; nothing of ours raises 0x80000003 (the only DebugBreak is in leonida-loader/src/thunks.rs for unimplemented imports, and logs it first). Most likely the title's own assert on the null return.
  • #3154 (merged) holds [4 GiB, 2^37) for the title, not the low 4 GiB. So a 32-bit request goes straight to the host, where the low 4 GiB may be fragmented by the driver, DLLs or the title's own 32-bit heap.

To confirm: the full XMemVirtualAlloc refused line (kind= and flags= values) and the unhandled exception 0x80000003 at ... line of the same log. If the 32-bit flag (0x4) is set, a fix would be to also hold the free parts of the low 4 GiB at startup, before the driver loads, next to #3154's range; and the warning should log the bounds and the largest free block. AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7381407517 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/issues/3337#issuecomment-7381407517). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-03T14:24:57Z. --- Code reading at main 9039f6a31 (no run): - The warning is logged at `d3d12/crates/leonida-hle/src/modules/xmem.rs` ~266, only for a reserve (a refused commit goes to `commit_refused` instead). The host call is `VirtualAlloc2` with address bounds from `address_range` (~93-100): [0, 4 GiB) when the title asks for a 32-bit address, [4 GiB, 2^40) otherwise. - "not enough memory resources" is `ERROR_NOT_ENOUGH_MEMORY`: for a bounded reserve that means no free range of that size in the bounds, not RAM or commit running out. - On refusal the title gets a null pointer; nothing of ours raises 0x80000003 (the only `DebugBreak` is in `leonida-loader/src/thunks.rs` for unimplemented imports, and logs it first). Most likely the title's own assert on the null return. - #3154 (merged) holds [4 GiB, 2^37) for the title, not the low 4 GiB. So a 32-bit request goes straight to the host, where the low 4 GiB may be fragmented by the driver, DLLs or the title's own 32-bit heap. To confirm: the full `XMemVirtualAlloc refused` line (`kind=` and `flags=` values) and the `unhandled exception 0x80000003 at ...` line of the same log. If the 32-bit flag (0x4) is set, a fix would be to also hold the free parts of the low 4 GiB at startup, before the driver loads, next to #3154's range; and the warning should log the bounds and the largest free block. AI-assisted (Claude Code).
azsekazvamdimitar commented 2026-12-03 15:58:28 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ubiquitarianism/leonida. Originally posted by azsekazvamdimitar on 2026-12-03T15:58:28Z.


A related case on Linux, with no XMemVirtualAlloc refused line, so not the same failure. It points at the same thing as the code reading above: the title's address range, not memory.

Setup: leonida.exe built at a5ea251f9 (PR #3316 head, on main d9b618f101), Wine 11.0 Staging (GE-Proton) with DXVK dxgi and VKD3D-Proton 3.1, RTX 3090 24 GB, 61 GB RAM, Series S, fresh data and cache folders, no gta6rt settings in the environment. Two runs, one with #3316's play-linux.sh and one with main's, gave the same result.

At start-up the held range is in 124 pieces:

title range held: the free places of [4 GiB, 128 GiB - 64 KiB) reserved with no access ... held_mb=126974 pieces=124

The 16 GiB pair and the 1.3 GB block then don't fit in any piece, so they go to the host and land above 2^37:

XMemVirtualAlloc: not placed in the title's range; asked of the host, perhaps above 2^37 where shaders do not reach it size=17179869184 times=1 miss=Refused
title memory asked for as protection 0x4, kind 0x42000, flags 0x21: 1 times, 16384 MB, last 0x20001f0000+0x400000000
XMemVirtualAlloc: not placed in the title's range; ... size=17179869184 times=2 miss=Refused
title memory asked for as protection 0x801, kind 0x42000, flags 0x3: 1 times, 16384 MB, last 0x24001f0000+0x400000000
XMemVirtualAlloc: not placed in the title's range; ... size=1339031552 times=4 miss=Refused
title memory asked for as protection 0x2404, kind 0x203000, flags 0x283: 1 times, 1277 MB, last 0x2848c00000+0x4fd00000

The 185 MB flags 0x7 request from this issue was placed: protection 0x1, kind 0x42000, flags 0x7: 1 times, 185 MB, last 0x9470000+0xb900000. About 15 s later (15:19:06 to 15:19:21), at title frame 82 on the loading screen (still at 60 fps), both runs stop with:

Leonida: unhandled exception 0x80000003 at leonida-image-b99f876b74d4a77f.dll+0x4dcbc9d

That is the same image offset as #3020 (Windows). There the fix was a fresh data folder; here the folders were fresh.

Reading: under Wine the held range is split into many pieces, so allocations of 16 GiB or more cannot be placed in it. Whether placement above 2^37, or the title's own check on the result, raises the 0x80000003 is not established. I have not run a Windows log beside it. The full local logs are available, and I can check a fix on this machine.

Data from a Linux run. AI-assisted (Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7384044075 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/issues/3337#issuecomment-7384044075). Originally posted by [azsekazvamdimitar](https://github.com/azsekazvamdimitar) on 2026-12-03T15:58:28Z. --- A related case on Linux, with no `XMemVirtualAlloc refused` line, so not the same failure. It points at the same thing as the code reading above: the title's address range, not memory. Setup: `leonida.exe` built at a5ea251f9 (PR #3316 head, on main d9b618f101), Wine 11.0 Staging (GE-Proton) with DXVK dxgi and VKD3D-Proton 3.1, RTX 3090 24 GB, 61 GB RAM, Series S, fresh data and cache folders, no gta6rt settings in the environment. Two runs, one with #3316's `play-linux.sh` and one with main's, gave the same result. At start-up the held range is in 124 pieces: ``` title range held: the free places of [4 GiB, 128 GiB - 64 KiB) reserved with no access ... held_mb=126974 pieces=124 ``` The 16 GiB pair and the 1.3 GB block then don't fit in any piece, so they go to the host and land above 2^37: ``` XMemVirtualAlloc: not placed in the title's range; asked of the host, perhaps above 2^37 where shaders do not reach it size=17179869184 times=1 miss=Refused title memory asked for as protection 0x4, kind 0x42000, flags 0x21: 1 times, 16384 MB, last 0x20001f0000+0x400000000 XMemVirtualAlloc: not placed in the title's range; ... size=17179869184 times=2 miss=Refused title memory asked for as protection 0x801, kind 0x42000, flags 0x3: 1 times, 16384 MB, last 0x24001f0000+0x400000000 XMemVirtualAlloc: not placed in the title's range; ... size=1339031552 times=4 miss=Refused title memory asked for as protection 0x2404, kind 0x203000, flags 0x283: 1 times, 1277 MB, last 0x2848c00000+0x4fd00000 ``` The 185 MB `flags 0x7` request from this issue was placed: `protection 0x1, kind 0x42000, flags 0x7: 1 times, 185 MB, last 0x9470000+0xb900000`. About 15 s later (15:19:06 to 15:19:21), at title frame 82 on the loading screen (still at 60 fps), both runs stop with: ``` Leonida: unhandled exception 0x80000003 at leonida-image-b99f876b74d4a77f.dll+0x4dcbc9d ``` That is the same image offset as #3020 (Windows). There the fix was a fresh data folder; here the folders were fresh. Reading: under Wine the held range is split into many pieces, so allocations of 16 GiB or more cannot be placed in it. Whether placement above 2^37, or the title's own check on the result, raises the 0x80000003 is not established. I have not run a Windows log beside it. The full local logs are available, and I can check a fix on this machine. Data from a Linux run. AI-assisted (Claude Opus 5.5).
Sign in to join this conversation.
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
ProjectLeonida/mandy#3337
No description provided.