HLE reuses freed physical page numbers #1445

Open
github-bot wants to merge 3 commits from github-bot/gh-1445 into main AGit
Owner

@⁠BaggyALPHA on GitHub · 2026-11-24 18:03 UTC · original
BaggyALPHA:fix/reuse-physical-page-numbers → main · +133 −20 · 1 files · 3 commits · open

Addresses item 36 (VIC-BT-036) in #1249. The allocator now reuses freed page numbers and refuses a request if it cannot fit every number into the title's existing 21-bit field. A repeated free cannot add the same number twice. Existing mappings still refer to their original section when a number is reused for a new section.

I seeded the allocator just below the limit in an isolated test process and used the public allocation and free functions. Upstream returned an unrepresentable number on the second allocation despite the first having been freed. The patch reused the freed number. The regression also checks exhaustion with a live allocation, a duplicate free, and an old mapped view keeping its bytes after reuse. All 96 HLE tests, Clippy with all targets and features, and the asset-policy hook passed on Windows.

The follow-up checks the page-count limit before calculating the section size, so oversized requests clear the output count and leave the page array untouched. The synthetic regression now exercises allocation, mapping, aliasing, and physical writes at the limit. After reuse, the old mapping and an alias made from it retain their data, and writes by page number reach the new allocation. The oversized-request assertion failed before the follow-up and passes with it. Windows HLE tests (96), all-targets/all-features HLE Clippy, and the pre-commit asset-policy check passed.

AI-assisted (Codex).

**@⁠BaggyALPHA** on GitHub · 2026-11-24 18:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/1445) `BaggyALPHA:fix/reuse-physical-page-numbers` → `main` · +133 −20 · 1 files · 3 commits · open Addresses item 36 (VIC-BT-036) in #1249. The allocator now reuses freed page numbers and refuses a request if it cannot fit every number into the title's existing 21-bit field. A repeated free cannot add the same number twice. Existing mappings still refer to their original section when a number is reused for a new section. I seeded the allocator just below the limit in an isolated test process and used the public allocation and free functions. Upstream returned an unrepresentable number on the second allocation despite the first having been freed. The patch reused the freed number. The regression also checks exhaustion with a live allocation, a duplicate free, and an old mapped view keeping its bytes after reuse. All 96 HLE tests, Clippy with all targets and features, and the asset-policy hook passed on Windows. The follow-up checks the page-count limit before calculating the section size, so oversized requests clear the output count and leave the page array untouched. The synthetic regression now exercises allocation, mapping, aliasing, and physical writes at the limit. After reuse, the old mapping and an alias made from it retain their data, and writes by page number reach the new allocation. The oversized-request assertion failed before the follow-up and passes with it. Windows HLE tests (96), all-targets/all-features HLE Clippy, and the pre-commit asset-policy check passed. AI-assisted (Codex).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:31:59 +00:00
Author
Owner

@⁠Daniel333313131 on GitHub · 2026-11-24 20:29 UTC · original

Tested on AMD (RDNA3) together with #431, to see whether this PR removes the one GPU page fault that remains there. In three runs it did not.

Setup: AMD Radeon RX 7900 XTX 24 GB, driver 32.0.32029.2010; Ryzen 7 9800X3D, 32 GB; Windows 11 10.0.26300. Diag build of main ffe310e with this PR's head f89051f and #431's head 23ced70 merged. Each run used its own empty VICTORY_CACHE_DIR, VICTORY_D3D12_DRED=1, and VICTORY_KEYS set to Enter every 3 s from 8 s to 47 s. Each run was stopped after 180 s.

Background: with #431 alone, faults inside freed textures are gone on this GPU (#431). What is left is a page fault where DRED names no resource. main shows the same kind in one of three runs.

run world ms/frame device removed DRED
#431 1 / 2 / 3 1037 / 936 / 929 169 s / none / none no resource named ×1
#1445 + #431 1 919 168 s page fault at 0x4fa396000, no resource named
#1445 + #431 2 1053 none reported – (but the log stops about 19 s before the run was stopped)
#1445 + #431 3 834 166 s page fault at 0x505a27000, no resource named
  • No freed-resource faults, same as #431 alone.
  • The page fault with no resource named still happens, in two of three runs, at about the same time as with #431 alone. In this test, this PR does not change it.
  • Caveat: three runs, and run 2 may have stalled rather than survived. #1445 was not tested alone.

AI use: Claude Code (Claude Opus 5.5) merged and built the commits, ran the title, summarised the log lines and wrote this comment. The numbers come from the runs above.

**@⁠Daniel333313131** on GitHub · 2026-11-24 20:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/1445#issuecomment-7143633170) Tested on AMD (RDNA3) together with #431, to see whether this PR removes the one GPU page fault that remains there. In three runs it did not. **Setup:** AMD Radeon RX 7900 XTX 24 GB, driver 32.0.32029.2010; Ryzen 7 9800X3D, 32 GB; Windows 11 10.0.26300. Diag build of `main` `ffe310e` with this PR's head `f89051f` and #431's head `23ced70` merged. Each run used its own empty `VICTORY_CACHE_DIR`, `VICTORY_D3D12_DRED=1`, and `VICTORY_KEYS` set to Enter every 3 s from 8 s to 47 s. Each run was stopped after 180 s. Background: with #431 alone, faults inside freed textures are gone on this GPU (https://git.gtahub.st/github/Marvisak--VIctory/pulls/431). What is left is a page fault where DRED names no resource. `main` shows the same kind in one of three runs. | | run | world ms/frame | device removed | DRED | |---|---|---|---|---| | #431 | 1 / 2 / 3 | 1037 / 936 / 929 | 169 s / none / none | no resource named ×1 | | **#1445 + #431** | 1 | 919 | 168 s | page fault at `0x4fa396000`, no resource named | | **#1445 + #431** | 2 | 1053 | none reported | – (but the log stops about 19 s before the run was stopped) | | **#1445 + #431** | 3 | 834 | 166 s | page fault at `0x505a27000`, no resource named | - No freed-resource faults, same as #431 alone. - The page fault with no resource named still happens, in two of three runs, at about the same time as with #431 alone. In this test, this PR does not change it. - Caveat: three runs, and run 2 may have stalled rather than survived. #1445 was not tested alone. **AI use:** Claude Code (Claude Opus 5.5) merged and built the commits, ran the title, summarised the log lines and wrote this comment. The numbers come from the runs above.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 03:28 UTC · original · edited 2026-11-25 20:19 UTC

Automated triage for the maintainers.

The rebased head merges cleanly. In crates/victory-hle/src/modules/xmem.rs, XMemFreePhysicalPages now hands numbers to a free list through Physical::free, which only pushes a number that was actually allocated, so freeing twice cannot hand the number out twice. Physical::allocate reuses freed numbers before taking new ones and refuses a request that would go past the 21-bit page-number limit already described next to FRAMES on main. On refusal and for oversized counts, the function writes 0 to count and returns 0, which matches the failure path main already has. Reused numbers can come back out of order within one allocation. That is fine: runs groups pages by section and slice index, not by number. Existing views keep their own Arc<Section>, so a reused number does not change what an older mapping shows. The tests use a private allocator, so they do not change the global one. One small thing: there is a stray second blank line before XMemFreePhysicalPages. CI passes.

Reply to the author: thanks for the rebase. I reviewed the current head 3f88d1f. The conflict resolution keeps main's unknown_pages() and the wording of its doc comment, as you described. Your withdrawn note about watch.rs matches the code: free touches no mapping, and both map and unmap report remaps.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 03:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/1445#issuecomment-7151940556) · edited 2026-11-25 20:19 UTC <!-- victory-triage v1 head=3f88d1fa62e02046b8a15507ae3d031f1722d452 verdict=merge-candidate at=2026-11-25T20:18:54Z --> Automated triage for the maintainers. The rebased head merges cleanly. In `crates/victory-hle/src/modules/xmem.rs`, `XMemFreePhysicalPages` now hands numbers to a free list through `Physical::free`, which only pushes a number that was actually allocated, so freeing twice cannot hand the number out twice. `Physical::allocate` reuses freed numbers before taking new ones and refuses a request that would go past the 21-bit page-number limit already described next to `FRAMES` on `main`. On refusal and for oversized counts, the function writes 0 to `count` and returns 0, which matches the failure path `main` already has. Reused numbers can come back out of order within one allocation. That is fine: `runs` groups pages by section and slice index, not by number. Existing views keep their own `Arc<Section>`, so a reused number does not change what an older mapping shows. The tests use a private allocator, so they do not change the global one. One small thing: there is a stray second blank line before `XMemFreePhysicalPages`. CI passes. Reply to the author: thanks for the rebase. I reviewed the current head `3f88d1f`. The conflict resolution keeps `main`'s `unknown_pages()` and the wording of its doc comment, as you described. Your withdrawn note about `watch.rs` matches the code: `free` touches no mapping, and both `map` and `unmap` report remaps. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠BaggyALPHA on GitHub · 2026-11-25 03:41 UTC · original

Follow-up for the triage concern: a2defb2 removes the child process. The limit regression seeds a private Physical allocator in-process, so parallel HLE tests cannot see the artificial limit. It still checks exhaustion, duplicate free, reuse, and distinct live Windows mappings for the old and new backing sections. A separate test exercises the public allocation API's oversized-request outputs.

Windows HLE library tests: 96 passed with default parallel scheduling. Strict Clippy with all targets and features, and the pre-commit asset-policy check, passed. Inputs were synthetic. No game run or relationship to the GPU page fault is claimed.

AI-assisted (OpenAI Codex).

**@⁠BaggyALPHA** on GitHub · 2026-11-25 03:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/1445#issuecomment-7152156136) Follow-up for the triage concern: `a2defb2` removes the child process. The limit regression seeds a private `Physical` allocator in-process, so parallel HLE tests cannot see the artificial limit. It still checks exhaustion, duplicate free, reuse, and distinct live Windows mappings for the old and new backing sections. A separate test exercises the public allocation API's oversized-request outputs. Windows HLE library tests: 96 passed with default parallel scheduling. Strict Clippy with all targets and features, and the pre-commit asset-policy check, passed. Inputs were synthetic. No game run or relationship to the GPU page fault is claimed. AI-assisted (OpenAI Codex).
Author
Owner

@⁠BaggyALPHA on GitHub · 2026-11-25 04:56 UTC · original

Pre-merge concern worth a maintainer's eyes, found while investigating #2025: crates/victory-gpu/src/watch.rs lines 33-35 document an accepted gap — "memory freed and allocated again while a tracker holds it is not seen." On current main, XMemFreePhysicalPages never recycles a page number (next_page only increments), so that gap is currently unreachable through XMem. This PR's free-list reuse is the first thing that would make a freed-and-reallocated XMem page number reachable while some victory_gpu::watch::Tracked/Shadow still holds stale state for the old backing, if the title (or our own view-remapping) reuses a number quickly enough relative to an in-flight GPU submission's copy-back.

I have not demonstrated this actually happens — it would need either a live repro with real page churn (I attempted one for #2025 and didn't get far enough on NVIDIA hardware before hitting the unrelated world-hang device-removal) or a synthetic concurrency test exercising both crates together. Flagging it so it's weighed before merge rather than discovered after; happy to help verify if useful.

AI-assisted (Claude Code).

**@⁠BaggyALPHA** on GitHub · 2026-11-25 04:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/1445#issuecomment-7153302505) Pre-merge concern worth a maintainer's eyes, found while investigating #2025: `crates/victory-gpu/src/watch.rs` lines 33-35 document an accepted gap — "memory freed and allocated again while a tracker holds it is not seen." On current `main`, `XMemFreePhysicalPages` never recycles a page *number* (`next_page` only increments), so that gap is currently unreachable through XMem. This PR's free-list reuse is the first thing that would make a freed-and-reallocated XMem page number reachable while some `victory_gpu::watch::Tracked`/`Shadow` still holds stale state for the old backing, if the title (or our own view-remapping) reuses a number quickly enough relative to an in-flight GPU submission's copy-back. I have not demonstrated this actually happens — it would need either a live repro with real page churn (I attempted one for #2025 and didn't get far enough on NVIDIA hardware before hitting the unrelated world-hang device-removal) or a synthetic concurrency test exercising both crates together. Flagging it so it's weighed before merge rather than discovered after; happy to help verify if useful. AI-assisted (Claude Code).
Author
Owner

@⁠BaggyALPHA on GitHub · 2026-11-25 15:30 UTC · original

Withdrawing my own pre-merge concern above: page-number reuse cannot reach the watch.rs gap. Mechanism and a synthetic test below.

I flagged that this PR's free-list reuse would be the first thing to make watch.rs's documented caveat reachable — "memory freed and allocated again while a tracker holds it is not seen". I said then that I had not demonstrated it. Having now tested the gap directly and read the paths, I think the concern does not apply, and it should not sit on this PR unanswered.

The gap is real, and reporting the mapping is what closes it. A synthetic test in victory-gpu's own watch::tests (write-watched pool memory, no GPU, no game): track two pages, take them so they are guarded and clean, release the allocation, take the same address back with VirtualAlloc, then write to it.

  • The write is missed — the tracker still reads clean. Freeing destroys the guard with the pages, so the new allocation is read-write and the write faults nothing.
  • After title_memory_remapped for that range, the same take reports it changed.

So the caveat is exactly as the module describes, and the runtime's own mapping report is the thing that closes it.

Why reuse cannot trigger it. The gap needs the bytes behind an already-tracked address to change with no report. Reuse does not do that:

  • XMemFreePhysicalPages calls Physical::free, which removes the number from pages and pushes it onto free_pages. It touches no view, no mapping and no address, so nothing behind any tracked address changes.
  • Reuse only decides which backing a future map() resolves for that number. An existing view keeps its own section slice (views hold their Arc<Section>), which is the behaviour XMemFreePhysicalPages' own comment already describes for pages freed while still mapped.
  • The only places what an address shows changes are map() and unmap(), and both call victory_gpu::title_memory_remapped for the range — the call the test shows closes the gap.

So the sequence I was worried about (reuse, then a tracker missing the new owner's writes) needs a mapping step, and that step reports itself.

What I ran. cargo test -p victory-gpu --features diagnostics --locked on main 940d32f plus the test: 145 passed, 2 failed, against 144 passed, 2 failed for main alone in a separate target directory — the two being the capped-view-heap pair (FIND-9, what #2121 addresses). The new test passed 4 of 4 runs, three of them under default parallelism, one serial. RTX 3080, Windows 11 26300. Synthetic inputs only; no game files.

Two notes in the interest of completeness:

  1. This branch predates main's title_memory_aliased call in map(), so it has two notification sites where main has three. That is branch age, not a behaviour difference — the merge is clean and that call comes with it.
  2. The test is not part of this PR. It pins a caveat that is currently only a comment, so if it is wanted I am happy to send it as a test-only change against victory-gpu rather than smuggle it in here; say the word and I will, otherwise the result above stands as evidence.

AI-assisted (Claude Code); the numbers are from the runs described.

**@⁠BaggyALPHA** on GitHub · 2026-11-25 15:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/1445#issuecomment-7166943579) **Withdrawing my own pre-merge concern above: page-number reuse cannot reach the `watch.rs` gap. Mechanism and a synthetic test below.** I [flagged](https://git.gtahub.st/github/Marvisak--VIctory/pulls/1445) that this PR's free-list reuse would be the first thing to make `watch.rs`'s documented caveat reachable — "memory freed and allocated again while a tracker holds it is not seen". I said then that I had not demonstrated it. Having now tested the gap directly and read the paths, I think the concern does not apply, and it should not sit on this PR unanswered. **The gap is real, and reporting the mapping is what closes it.** A synthetic test in `victory-gpu`'s own `watch::tests` (write-watched pool memory, no GPU, no game): track two pages, take them so they are guarded and clean, release the allocation, take the same address back with `VirtualAlloc`, then write to it. - The write is **missed** — the tracker still reads clean. Freeing destroys the guard with the pages, so the new allocation is read-write and the write faults nothing. - After `title_memory_remapped` for that range, the same take reports it changed. So the caveat is exactly as the module describes, and the runtime's own mapping report is the thing that closes it. **Why reuse cannot trigger it.** The gap needs the bytes behind an *already-tracked address* to change with no report. Reuse does not do that: - `XMemFreePhysicalPages` calls `Physical::free`, which removes the number from `pages` and pushes it onto `free_pages`. It touches no view, no mapping and no address, so nothing behind any tracked address changes. - Reuse only decides which backing a **future** `map()` resolves for that number. An existing view keeps its own section slice (views hold their `Arc<Section>`), which is the behaviour `XMemFreePhysicalPages`' own comment already describes for pages freed while still mapped. - The only places what an address shows changes are `map()` and `unmap()`, and both call `victory_gpu::title_memory_remapped` for the range — the call the test shows closes the gap. So the sequence I was worried about (reuse, then a tracker missing the new owner's writes) needs a mapping step, and that step reports itself. **What I ran.** `cargo test -p victory-gpu --features diagnostics --locked` on `main` `940d32f` plus the test: **145 passed, 2 failed**, against **144 passed, 2 failed** for `main` alone in a separate target directory — the two being the capped-view-heap pair (`FIND-9`, what #2121 addresses). The new test passed 4 of 4 runs, three of them under default parallelism, one serial. RTX 3080, Windows 11 26300. Synthetic inputs only; no game files. Two notes in the interest of completeness: 1. This branch predates `main`'s `title_memory_aliased` call in `map()`, so it has two notification sites where `main` has three. That is branch age, not a behaviour difference — the merge is clean and that call comes with it. 2. The test is not part of this PR. It pins a caveat that is currently only a comment, so if it is wanted I am happy to send it as a test-only change against `victory-gpu` rather than smuggle it in here; say the word and I will, otherwise the result above stands as evidence. AI-assisted (Claude Code); the numbers are from the runs described.
Author
Owner

@⁠BaggyALPHA on GitHub · 2026-11-25 20:07 UTC · original

Rebased onto current main (13f91ca); the branch had gone conflicting as main moved. New head 3f88d1f, same three commits.

One conflict, in modules/xmem.rs: main has since added unknown_pages() (used by dstorage.rs) next to FRAMES, which this branch had moved to the top of the file beside PAGE_NUMBER_LIMIT. Resolved by keeping unknown_pages() and dropping the now-duplicate FRAMES, with main's fuller wording of its doc comment kept rather than mine, so the only change to that comment is where it sits.

On the rebased head: cargo test -p victory-hle --locked 148 passed, 0 failed, including freed_page_numbers_can_be_reused_at_the_limit and oversized_physical_request_clears_count_without_writing_page_numbers; cargo clippy -p victory-hle --all-targets --locked -- -D warnings clean; cargo xtask policy 184 files ok. Synthetic inputs only, no game files.

Nothing about the change itself is different — it is the same allocator, the same two tests, and the in-process limit test from the earlier follow-up. The concern I raised and then withdrew about page-number reuse reaching watch.rs's caveat still stands as withdrawn; main moving has not changed that reasoning, since free still touches no mapping.

AI-assisted (Claude Code).

**@⁠BaggyALPHA** on GitHub · 2026-11-25 20:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/1445#issuecomment-7173212599) Rebased onto current `main` (`13f91ca`); the branch had gone conflicting as `main` moved. New head `3f88d1f`, same three commits. One conflict, in `modules/xmem.rs`: `main` has since added `unknown_pages()` (used by `dstorage.rs`) next to `FRAMES`, which this branch had moved to the top of the file beside `PAGE_NUMBER_LIMIT`. Resolved by keeping `unknown_pages()` and dropping the now-duplicate `FRAMES`, with `main`'s fuller wording of its doc comment kept rather than mine, so the only change to that comment is where it sits. On the rebased head: `cargo test -p victory-hle --locked` **148 passed, 0 failed**, including `freed_page_numbers_can_be_reused_at_the_limit` and `oversized_physical_request_clears_count_without_writing_page_numbers`; `cargo clippy -p victory-hle --all-targets --locked -- -D warnings` clean; `cargo xtask policy` 184 files ok. Synthetic inputs only, no game files. Nothing about the change itself is different — it is the same allocator, the same two tests, and the in-process limit test from the earlier follow-up. The [concern I raised and then withdrew](https://git.gtahub.st/github/Marvisak--VIctory/pulls/1445) about page-number reuse reaching `watch.rs`'s caveat still stands as withdrawn; `main` moving has not changed that reasoning, since `free` still touches no mapping. AI-assisted (Claude Code).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 16:12 UTC · original · approved these changes

Reviewed 3f88d1fa62e02046b8a15507ae3d031f1722d452 (merged cleanly onto 63bcca43c6a00a758510398fa43096ce7e4f7df0) and verified on Windows 11 x64 (rustc 1.98.1 MSVC).

Audit

  • Bounds & atomic failure (crates/victory-hle/src/modules/xmem.rs:364, :365, :465, :518):
    • XMemAllocatePhysicalPages rejects counts above (PAGE_NUMBER_LIMIT - FIRST_PAGE_NUMBER) / FRAMES before checked_mul(PAGE) or CreateFileMappingW, zeroing *count without touching pages.
    • Physical::allocate checks fresh = numbers.len().saturating_sub(self.free_pages.len()) <= (PAGE_NUMBER_LIMIT - self.next_page) / FRAMES up front (next_page <= PAGE_NUMBER_LIMIT is preserved as an invariant), so exhaustion fails all-or-nothing, leaves numbers untouched, and drops Arc<Section> cleanly (closing the section handle).
  • Duplicate frees, LIFO reuse & mapping isolation (crates/victory-hle/src/modules/xmem.rs:392, :488):
    • Physical::free pushes to free_pages only when self.pages.remove(&number).is_some(), making duplicate and unknown-PFN frees safe no-ops.
    • Existing views retain their own Arc<Section> in views, runs / XMemMapPhysicalPages coalesce by (section, slice.index) rather than PFN order (so LIFO out-of-order recycled PFNs from one allocation still map in a single run), and virtual mapping changes remain reported through map/unmap (title_memory_remapped).
  • Minor non-blocking nit: stray extra blank line above XMemFreePhysicalPages.

Verification

  • Clean merge onto 63bcca43c6a00a758510398fa43096ce7e4f7df0 + cargo run -p xtask -- policy (191 files ok)
  • cargo clippy -p victory-hle --all-targets -- -D warnings (default & --all-features)
  • cargo test -p victory-hle --lib -- modules::xmem::: 16/16 passed (including freed_page_numbers_can_be_reused_at_the_limit and oversized_physical_request_clears_count_without_writing_page_numbers).
  • Additional probe verified exact max_pages + 1 rejection (2_031_617), n == 0 / null-pointer calls, unknown-PFN frees (0, usize::MAX, unallocated) not poisoning free_pages, duplicate-free idempotency, LIFO reversed PFN reuse preserving sequential slice indices, and atomic failure on exhaustion.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 16:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/1445#pullrequestreview-6077338650) · **approved these changes** Reviewed `3f88d1fa62e02046b8a15507ae3d031f1722d452` (merged cleanly onto `63bcca43c6a00a758510398fa43096ce7e4f7df0`) and verified on Windows 11 x64 (`rustc 1.98.1` MSVC). ### Audit - **Bounds & atomic failure** (`crates/victory-hle/src/modules/xmem.rs:364`, `:365`, `:465`, `:518`): - `XMemAllocatePhysicalPages` rejects counts above `(PAGE_NUMBER_LIMIT - FIRST_PAGE_NUMBER) / FRAMES` before `checked_mul(PAGE)` or `CreateFileMappingW`, zeroing `*count` without touching `pages`. - `Physical::allocate` checks `fresh = numbers.len().saturating_sub(self.free_pages.len()) <= (PAGE_NUMBER_LIMIT - self.next_page) / FRAMES` up front (`next_page <= PAGE_NUMBER_LIMIT` is preserved as an invariant), so exhaustion fails all-or-nothing, leaves `numbers` untouched, and drops `Arc<Section>` cleanly (closing the section handle). - **Duplicate frees, LIFO reuse & mapping isolation** (`crates/victory-hle/src/modules/xmem.rs:392`, `:488`): - `Physical::free` pushes to `free_pages` only when `self.pages.remove(&number).is_some()`, making duplicate and unknown-PFN frees safe no-ops. - Existing views retain their own `Arc<Section>` in `views`, `runs` / `XMemMapPhysicalPages` coalesce by `(section, slice.index)` rather than PFN order (so LIFO out-of-order recycled PFNs from one allocation still map in a single run), and virtual mapping changes remain reported through `map`/`unmap` (`title_memory_remapped`). - Minor non-blocking nit: stray extra blank line above `XMemFreePhysicalPages`. ### Verification - Clean merge onto `63bcca43c6a00a758510398fa43096ce7e4f7df0` + `cargo run -p xtask -- policy` (`191 files ok`) - `cargo clippy -p victory-hle --all-targets -- -D warnings` (default & `--all-features`) - `cargo test -p victory-hle --lib -- modules::xmem::`: **16/16 passed** (including `freed_page_numbers_can_be_reused_at_the_limit` and `oversized_physical_request_clears_count_without_writing_page_numbers`). - Additional probe verified exact `max_pages + 1` rejection (`2_031_617`), `n == 0` / null-pointer calls, unknown-PFN frees (`0`, `usize::MAX`, unallocated) not poisoning `free_pages`, duplicate-free idempotency, LIFO reversed PFN reuse preserving sequential slice indices, and atomic failure on exhaustion.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1445/head:github-bot/gh-1445'
git switch 'github-bot/gh-1445'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1445'
git switch 'github-bot/gh-1445'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1445'
git switch 'github-bot/gh-1445'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1445'
git switch 'main'
git merge --squash 'github-bot/gh-1445'
git switch 'main'
git merge --ff-only 'github-bot/gh-1445'
git switch 'main'
git merge 'github-bot/gh-1445'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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!1445
No description provided.