Repository navigation
Conversation
The retail executable releases its physical-page reservations with kernel32!VirtualFree(base, 0, MEM_RELEASE) (ItsNotRexed#6995 measured it; main's own record_window comment says so). Once pages have been mapped, such a reservation is one placeholder per 64 KiB page plus the views in it, so the host call releases only the first piece: the rest stays reserved and mapped, and g_windows / g_mapped keep describing it. VirtualFree is now registered next to TitleVirtualAlloc for the same DLL names. A MEM_RELEASE at the base of a reservation or window XMemVirtualAlloc made unmaps its views, releases every host allocation in it (placeholders and committed replacements) and drops its records. Every other call goes to the host. xmem_test: 8 checks fail on main with the host's VirtualFree and all 191 pass here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Read the diff (not run). Two points on xmem.cpp:
AI-assisted (Claude); code read only, nothing run. |
tupacfan04
left a comment
There was a problem hiding this comment.
A stale g_reservations record can free a new reservation after a release the shim did not see.
xmem.cpp:265addsg_reservations(base → size), written only byXMemVirtualAlloc(:409-416).record_window(:267-279) erases overlappingg_windowsonly; it never touchesg_reservations, even though its comment describes the title releasing an overlapped region with hostVirtualFreethat the shim does not see.TitleVirtualFree(:727-744) trustsg_reservations;release_range(:697-721) only refuses an allocation whose base is before the requested base.
Repro: reserve A through the shim; release A with host VirtualFree (unseen); reserve B at A + 64 KiB through the shim; call the shim’s VirtualFree(A, 0, MEM_RELEASE). The stale record makes release_range walk to B (owner = A+64K > base), release B’s whole placeholder and its mapped views, then erase B’s g_windows/g_reservations. B is gone.
Expected: drop the stale record and return FALSE, or validate the host allocation base before release_range; add g_reservations to record_window/#7712’s cleanup. The test (xmem_test.cpp:491-557) only frees through the shim and never covers an unseen/partial release or overlapping reuse.
Whole-reservation release and the shim-visible paths look correct; partial MEM_RELEASE is also untested. Head f4324028; synthetic only; no game files. AI-assisted (OpenCode).
|
Independent AI-assisted check on Windows 11 build 26200 with llvm-mingw Clang 23.1.6, CPU-only, with the test harness's standard filesystem path conversions from #7823. At f432402, xmem_test passed 191/191. Main dde82f2 with this PR's test failed at the missing VirtualFree shim, so that run stopped before exercising its release cases. I also combined this head with #7712 4bd14d7 on dde82f2. The three-way merge conflicts where XMemVirtualAlloc records a reservation and in two test insertion points. Keeping this PR's reservation record and #7712's branch that clears stale windows for plain placeholders, plus both test functions, gave 217/217 checks. No GPU or game files were used. |
Review on ItsNotRexed#7742 (jebaczydow): release_range freed every allocation it found in the recorded range, so once the title had released a window carved out of a reservation and something else took that hole, releasing the outer reservation freed the newcomer too. A reservation in such a hole is now recorded (XMemVirtualAlloc's own reservations already were; the title's VirtualAlloc and XMemVirtualAlloc's plain paths now are when they land inside one), and release_range leaves every recorded reservation nested in the range alone, with its windows and mapped pages. It also skips an allocation that does not end inside the range, and drops only its own reservation record. xmem_test: the hole-reuse case crashes on the previous head (the outer release freed the committed hole) and passes here; 203 checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@jebaczydow, point 1 was real. The fix:
Point 2: agreed. Racurs156's three-way merge with #7712 (above) gives 217/217, and I'll rebase on whichever lands first. Also measured since: the retail executable imports |
|
Tested
AI-assisted (Claude Code). |
|
Tested I added their scenario to a local copy of
One remaining difference: the title's AI-assisted (Claude Code), no game files. |
|
Reviewed and tested on its head (clang-cl 20 + xwin cross-build, Wine): Correctness reads clean:
The hole-reallocation edge case (the one most likely to regress silently) is the one this nails down best. AI-assisted (Devin); no game files used. |
|
Tested 51736cd on Windows 11 Pro 10.0.26300, MSVC 14.51 (VS Build Tools 2026), Windows SDK 10.0.26100, NVIDIA GeForce RTX 4060 / 621.24, Khronos Vulkan headers via Merged onto main 867d922 (clean), full runtime build, Together with #7580, which edits the same file: main + #7742 + #7580 merges without conflicts ( Code read, one note: Picked from the "No game copy" list in #7154. AI-assisted (Claude Code). No game files. |
Dependency snapshot: ItsNotRexed#7742 at 51736cd. The subsequent commits contain the new regression cases and failure-handling fix.
The 290-check suite completes with 24 failures on the ItsNotRexed#7742 implementation. Failure callbacks are compiled only into xmem_test. Claim: ItsNotRexed#8344 (comment) AI-assisted: yes (Codex).
|
Follow-up #8825 adds controlled failure-and-retry cases on top of your The follow-up preserves surviving spans and the first native error, protects independent nested owners, and handles address reuse without freeing the new owner. Your implementation is credited and listed as the dependency. Synthetic allocations and injected API failures only; no GPU/game data or retail-run claim. AI-assisted (Codex). |
…a whole physical-page reservation Squashed from ItsNotRexed#7742 by ASTROWwwW, head 51736cd (security scan PASS). Conflicts in xmem.cpp and xmem_test.cpp with ItsNotRexed#7584, ItsNotRexed#4531 and ItsNotRexed#7712. Adapted to ItsNotRexed#7584's run-of-views model: release_range unmaps every recorded view (g_views) whose base is in the range and not inside a nested reservation, via unmap_range, instead of the per-page g_mapped table. XMemVirtualAlloc's reservation branch records g_reservations and keeps ItsNotRexed#7712's record_window/clear_window_range split; the aligned and plain paths keep ItsNotRexed#4531's title flags and ItsNotRexed#7712's clearing, then note nested allocations. TitleVirtualAlloc is ItsNotRexed#4531's version (page bits through xmem_virtual_alloc) with note_nested_allocation on the plain host path. Both new test functions kept (a merged closing brace restored). xmem_test under Wine 11.22: 656 checks OK.
Claimed in the coordination issue as: #7694 (comment) (new RT item, follow-up of #6919)
Depends on: none. Touches the same file as #7580 and #7712, in other functions.
What and why
The retail executable releases its physical-page reservations with
kernel32!VirtualFree(base, 0, MEM_RELEASE). #6995 measured it, andmain's ownrecord_windowcomment says so. Onmainthat call goes straight to the host. Once pages have been mapped, the reservation is one placeholder per 64 KiB page plus the views in it, so the host releases only the first piece. The rest stays reserved and mapped, andg_windows/g_mappedkeep describing it.VirtualFreeis now registered next toTitleVirtualAlloc, for the same DLL names (kernel32,kernelbase,api-ms-win-core-memory-l1-1-0to-6). AMEM_RELEASEat the base of a reservation or window thatXMemVirtualAllocmade, with size 0 or its full size, does three things: it unmaps every view in it, releases every host allocation in it (placeholders and committedMEM_REPLACE_PLACEHOLDERranges), and drops its window and reservation records. A window carved out of a reservation can be released on its own, and the rest of the reservation stays reserved. Every other call goes to the host unchanged.This is the second half of what #6995 still added over
main(#7154 (comment)). It adapts #6995'sTitleVirtualFreetomain's window model. The first half is #7580. #7712 cleans up the records after a release the shim did not see, and this PR makes the title's own release one the shim sees; the two don't overlap.Tested
Windows 11 Pro 26300, MSVC 2022 BuildTools,
RelWithDebInfo, no game files, no GPU involved.xmem_test, with the newtest_title_virtual_free(a mapped window; a placeholder reservation with a mapped carved window and a committed range; a carved window released on its own; ordinary memory):main, falling back to the host'sVirtualFree: 8 failures out of 191.VirtualFree(window, 0, MEM_RELEASE)fails on the view, andVirtualFree(base, …)returns TRUE but leaves the later placeholders and views reserved.ctest -C RelWithDebInfo: 111/111 (GPU and game-file tests skip here).python -I scripts/check_no_game_data.pyon both files: clean.Not measured: a retail run. I have no game copy here, so whether the title reaches such a release during boot is still for someone with one to check.
AI-assisted: yes (Claude Code)
Checklist
docs/design.md, with how it was confirmed. (no translator change)🤖 Generated with Claude Code