D3D12-GPU-QUEUE-COPY-PAGE-MAPPINGS-BOUNDS: bound ranges and report failures #2833

Open
bobcatchris wants to merge 4 commits from upstream-pr/2833 into main
bobcatchris commented 2026-12-01 04:31:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-12-01T04:31:23Z.


Claim: D3D12-GPU-QUEUE-COPY-PAGE-MAPPINGS-BOUNDS-AND-HRESULT (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7300779895), from zmasi's "open for anyone" finding.

What and why

d3d12/crates/leonida-gpu/src/queue.rs::copy_page_mappings had four gaps:

  1. std::slice::from_raw_parts(b.ranges, 0) was called even for a null or misaligned ranges pointer. An empty batch needs no pointer, and a non-null one must be aligned; the new batch_ranges() helper handles both and refuses an impossible pointer.
  2. pool + u64::from(r.start) * PAGE was computed before matching r.kind, so kinds 2 (unmap) and 3 (leave alone), whose start is unused, could overflow. map_range() computes the source only in the branches that use it, with checked arithmetic, and checks every destination step.
  3. Non-zero flags was ignored. The ChildProxy console shim (runtime/shims/d3d12_xs_device.cpp:2429) refuses them.
  4. A failed mapping still returned S_OK; the ChildProxy shim path returns E_INVALIDARG (:2199). It now does too.

Behaviour change: Non-zero flags, null/misaligned PageBatch pointers (count > 0), and any failed/left-out mapping now log a rate-limited warning and return E_INVALIDARG instead of silently returning S_OK. Note: the separate 4-argument shim route (runtime/shims/d3d12_xs_device.cpp:2173) is out of scope for this leonida-gpu PR.

The title's successful page-mapping path is unchanged: same map calls, same sources, same destinations. No rendering or visual setting changes.

Verification (offline, no game files)

cargo test --locked -p leonida-gpu --lib queue::tests
  running 9 tests ... test result: ok. 9 passed; 0 failed

cargo clippy --locked -p leonida-gpu --lib   # no new warnings
python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/queue.rs
git diff --check                             # clean

Four new tests cover: an empty batch with a null or misaligned pointer, an unmapping range with an out-of-pool start, a wrapping source and a wrapping next-range address, and kind 1 mapping every page from one source.

GPUs tested: RTX 4060 8 GB (third-party in-game batch PASS on 823087ec3 by @MoonEyes, 2026-12-02T17:06:53Z; offline Windows unit tests on local host).

AI-assisted: Gemini 4 Neon (including independent read-only review on 823087ec3, plus maintainer commit e1a0e5c31).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5579054140 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2833). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-12-01T04:31:23Z. --- Claim: `D3D12-GPU-QUEUE-COPY-PAGE-MAPPINGS-BOUNDS-AND-HRESULT` (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7300779895), from zmasi's "open for anyone" finding. ## What and why `d3d12/crates/leonida-gpu/src/queue.rs::copy_page_mappings` had four gaps: 1. `std::slice::from_raw_parts(b.ranges, 0)` was called even for a null or misaligned `ranges` pointer. An empty batch needs no pointer, and a non-null one must be aligned; the new `batch_ranges()` helper handles both and refuses an impossible pointer. 2. `pool + u64::from(r.start) * PAGE` was computed before matching `r.kind`, so kinds 2 (unmap) and 3 (leave alone), whose `start` is unused, could overflow. `map_range()` computes the source only in the branches that use it, with checked arithmetic, and checks every destination step. 3. Non-zero `flags` was ignored. The `ChildProxy` console shim (`runtime/shims/d3d12_xs_device.cpp:2429`) refuses them. 4. A failed mapping still returned `S_OK`; the `ChildProxy` shim path returns `E_INVALIDARG` (`:2199`). It now does too. **Behaviour change:** Non-zero `flags`, null/misaligned `PageBatch` pointers (`count > 0`), and any failed/left-out mapping now log a rate-limited warning and return `E_INVALIDARG` instead of silently returning `S_OK`. Note: the separate 4-argument shim route (`runtime/shims/d3d12_xs_device.cpp:2173`) is out of scope for this `leonida-gpu` PR. The title's successful page-mapping path is unchanged: same map calls, same sources, same destinations. No rendering or visual setting changes. ## Verification (offline, no game files) ``` cargo test --locked -p leonida-gpu --lib queue::tests running 9 tests ... test result: ok. 9 passed; 0 failed cargo clippy --locked -p leonida-gpu --lib # no new warnings python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/queue.rs git diff --check # clean ``` Four new tests cover: an empty batch with a null or misaligned pointer, an unmapping range with an out-of-pool `start`, a wrapping source and a wrapping next-range address, and kind 1 mapping every page from one source. GPUs tested: RTX 4060 8 GB (third-party in-game batch PASS on `823087ec3` by `@MoonEyes`, 2026-12-02T17:06:53Z; offline Windows unit tests on local host). AI-assisted: Gemini 4 Neon (including independent read-only review on `823087ec3`, plus maintainer commit `e1a0e5c31`).
KelboLive commented 2026-12-01 04:45:32 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T04:45:32Z.

Review: COMMENTED


The arithmetic is right: len = count * 64 KiB cannot wrap (u32 × 2^16), start + count is checked in u32 (queue.rs:1431), the source (:1432), kind 1's per-page destination and the final advance (:1448) are all checked_add, and kinds 2/3 correctly ignore the unused start. It matches the console row (docs/d3d12_vulkan.md:5103) and the ChildProxy shim route, E_INVALIDARG and the flags refusal included. cargo test --locked -p leonida-gpu --lib queue::tests is 9/9 here.

Three things I would change, in order of how much they would hide:

  1. The pool bound is the one rule no test covers. Replacing inside(pool_pages, …) at :1431 with |_| true leaves all 9 tests green. A kind-0 case ending at pool_pages + 1 (expects false) and one ending exactly at pool_pages (expects true) would pin it; flags != 0 and a null-ranges-with-count case are also unpinned.
  2. "Report failures" is half done. batch_ranges → None (:1484) and the wrap refusal (:1489) return E_INVALIDARG with no log at all; only the ok == false path warns. The shim's first refusal logs kind/start/count/destination (runtime/shims/d3d12_xs_device.cpp:2191), and since the retail call site ignores the HRESULT (:2131) the log is the only way a refusal is ever seen.
  3. One impossible pointer left: :1470 builds the batches slice with from_raw_parts and no alignment check, while batch_ranges refuses a misaligned ranges for each batch. Same check on PageBatch, one line.

Scope question: the four-argument shim route (runtime/shims/d3d12_xs_device.cpp:2173) still ignores flags and wraps pool + start*64KiB (:2157) and at += count*64KiB (:2196), so "the shim already does this" holds for only one of its two implementations — either bound that one too or say the scope is the Rust path.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6125261358 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2833#pullrequestreview-6125261358). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-12-01T04:45:32Z. **Review:** COMMENTED --- The arithmetic is right: `len = count * 64 KiB` cannot wrap (`u32 × 2^16`), `start + count` is checked in `u32` (`queue.rs:1431`), the source (`:1432`), kind 1's per-page destination and the final advance (`:1448`) are all `checked_add`, and kinds 2/3 correctly ignore the unused `start`. It matches the console row (`docs/d3d12_vulkan.md:5103`) and the `ChildProxy` shim route, `E_INVALIDARG` and the flags refusal included. `cargo test --locked -p leonida-gpu --lib queue::tests` is 9/9 here. Three things I would change, in order of how much they would hide: 1. **The pool bound is the one rule no test covers.** Replacing `inside(pool_pages, …)` at `:1431` with `|_| true` leaves all 9 tests green. A kind-0 case ending at `pool_pages + 1` (expects `false`) and one ending exactly at `pool_pages` (expects `true`) would pin it; `flags != 0` and a null-ranges-with-count case are also unpinned. 2. **"Report failures" is half done.** `batch_ranges → None` (`:1484`) and the wrap refusal (`:1489`) return `E_INVALIDARG` with **no log at all**; only the `ok == false` path warns. The shim's first refusal logs kind/start/count/destination (`runtime/shims/d3d12_xs_device.cpp:2191`), and since the retail call site ignores the HRESULT (`:2131`) the log is the only way a refusal is ever seen. 3. **One impossible pointer left**: `:1470` builds the batches slice with `from_raw_parts` and no alignment check, while `batch_ranges` refuses a misaligned `ranges` for each batch. Same check on `PageBatch`, one line. Scope question: the four-argument shim route (`runtime/shims/d3d12_xs_device.cpp:2173`) still ignores flags and wraps `pool + start*64KiB` (`:2157`) and `at += count*64KiB` (`:2196`), so "the shim already does this" holds for only one of its two implementations — either bound that one too or say the scope is the Rust path.
fiestorra commented 2026-12-01 04:52:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-01T04:52:25Z.


Verified on Windows: the crate is green with it, and it adds 4 tests - measured against main's own file, which is 591.

main 5dd6d444f, cherry-picked (one commit, merge-base 86c30fcea), cargo 1.98.1:

cargo test -p leonida-gpu --lib with this pull request: ok. 595 passed; 0 failed; 53 ignored with queue.rs from main: ok. 591 passed; 0 failed; 53 ignored

So the change is tied to its tests and nothing else in the crate moved. That is an existence control - I did not break the code to watch a specific test fail, because the tests that come with it are the ones that would. Whoever knows what los bounds de CopyPageMappingsBatch guards should say whether removing it makes one of them fail; I can say the crate passes and 4 tests arrive.

What I could not test: anything that needs a card doing the thing. These are the descriptor and queue paths, and this machine has a 4090 but not the title that exercises los bounds de CopyPageMappingsBatch end to end - the unit tests are what I ran, and they are green.

AI-assisted: yes - DeepSeek v4.1 (flash), both arms on the machine above.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7301189820 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2833#issuecomment-7301189820). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-01T04:52:25Z. --- **Verified on Windows: the crate is green with it, and it adds 4 tests - measured against `main`'s own file, which is 591.** **`main` `5dd6d444f`, cherry-picked (one commit, merge-base `86c30fcea`), `cargo 1.98.1`:** ` cargo test -p leonida-gpu --lib with this pull request: ok. 595 passed; 0 failed; 53 ignored with queue.rs from main: ok. 591 passed; 0 failed; 53 ignored ` **So the change is tied to its tests and nothing else in the crate moved.** **That is an existence control** - **I did not break the code to watch a specific test fail, because the tests that come with it are the ones that would.** **Whoever knows what los bounds de CopyPageMappingsBatch guards should say whether removing it makes one of them fail; I can say the crate passes and 4 tests arrive.** **What I could not test**: **anything that needs a card doing the thing**. **These are the descriptor and queue paths, and this machine has a 4090 but not the title that exercises los bounds de CopyPageMappingsBatch end to end** - **the unit tests are what I ran, and they are green.** **AI-assisted:** yes - DeepSeek v4.1 (flash), both arms on the machine above. Written with an AI assistant.
MoonEyes commented 2026-12-01 15:20:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-01T15:20:37Z.


e1a0e5c31: a batch that cannot be read, or a range whose addresses wrap, is left out and the call fails, but the other batches are mapped (before, the early return dropped what was already gathered). The refusal for flags is said once in the log. The doc comment of copy_page_mappings is back on it. No test for the dropped batches: it needs a page mapper. On main cd0c52fcf: 635 passed, 0 failed.

Pushed to your branch by MoonEyes (maintainer, the branch allows it), on top of your head, nothing rewritten. Say so if you would rather have it another way, and I take it out. The earlier verdicts are for the head before this one.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7315751677 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2833#issuecomment-7315751677). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-01T15:20:37Z. --- `e1a0e5c31`: a batch that cannot be read, or a range whose addresses wrap, is left out and the call fails, but the other batches are mapped (before, the early return dropped what was already gathered). The refusal for flags is said once in the log. The doc comment of `copy_page_mappings` is back on it. No test for the dropped batches: it needs a page mapper. On `main` `cd0c52fcf`: 635 passed, 0 failed. Pushed to your branch by MoonEyes (maintainer, the branch allows it), on top of your head, nothing rewritten. Say so if you would rather have it another way, and I take it out. The earlier verdicts are for the head before this one. AI-assisted (Claude Code).
bobcatchris commented 2026-12-01 18:25:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-12-01T18:25:51Z.


@MoonEyes Thanks for e1a0e5c31 — kept it as-is, merged main to clear the unrelated Python CI failures, and addressed @KelboLive's remaining items in 823087ec3:

  • Added unsafe fn page_batches (mirroring unsafe fn batch_ranges) to reject null/misaligned PageBatch pointers when count > 0, with # Safety contracts and call-site // SAFETY: comments.
  • Updated map_range to check at.checked_add(len)? and source-end from.checked_add(len/PAGE)? before calling map(...) so wrapping ranges never invoke map or leak into gathered.
  • Added ranges_past_the_pool_end_are_refused, page_batches_rejects_null_and_misaligned_pointers, and strengthened a_wrapping_source_or_next_range_is_refused across kinds 0..=3 asserting zero map calls.
  • Verified locally on Windows (Rust 1.98.1): cargo test --locked -p leonida-gpu --lib queue::tests (11 passed, 0 failed) and python -I scripts/check_no_game_data.py (clean).

AI-assisted: Gemini 4 Neon (including an independent read-only reviewer pass).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7320933095 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2833#issuecomment-7320933095). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-12-01T18:25:51Z. --- @MoonEyes Thanks for `e1a0e5c31` — kept it as-is, merged `main` to clear the unrelated Python CI failures, and addressed @KelboLive's remaining items in `823087ec3`: - Added `unsafe fn page_batches` (mirroring `unsafe fn batch_ranges`) to reject null/misaligned `PageBatch` pointers when `count > 0`, with `# Safety` contracts and call-site `// SAFETY:` comments. - Updated `map_range` to check `at.checked_add(len)?` and source-end `from.checked_add(len/PAGE)?` *before* calling `map(...)` so wrapping ranges never invoke `map` or leak into `gathered`. - Added `ranges_past_the_pool_end_are_refused`, `page_batches_rejects_null_and_misaligned_pointers`, and strengthened `a_wrapping_source_or_next_range_is_refused` across kinds `0..=3` asserting zero `map` calls. - Verified locally on Windows (Rust 1.98.1): `cargo test --locked -p leonida-gpu --lib queue::tests` (11 passed, 0 failed) and `python -I scripts/check_no_game_data.py` (clean). AI-assisted: Gemini 4 Neon (including an independent read-only reviewer pass).
MoonEyes commented 2026-12-02 12:28:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T12:28:16Z.


This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).

Could you, or anyone with a working setup, post a run report on the current head merged onto current main:

  • the head SHA and the main SHA it was merged onto;
  • GPU, driver and OS;
  • at least 300 s in the world after loading;
  • device lost / crashes (count), and rendered fps (median) if you have them;
  • the same run on main alone for comparison, if you can.

Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7345388361 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2833#issuecomment-7345388361). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T12:28:16Z. --- This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists). Could you, or anyone with a working setup, post a run report on the **current head** merged onto current `main`: - the head SHA and the `main` SHA it was merged onto; - GPU, driver and OS; - at least 300 s in the world after loading; - device lost / crashes (count), and rendered fps (median) if you have them; - the same run on `main` alone for comparison, if you can. Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough. AI-assisted (Claude Code).
MoonEyes commented 2026-12-02 17:06:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T17:06:53Z.


RUN (in game, batch of eleven render-path pull requests), each head merged with git merge --no-ff onto main 3c106eb2f, in one build: #3071 c2065b540, #2982 65155eceb, #2964 00a068106, #3107 79333e26b, #2833 823087ec3, #2947 b07f64346, #2919 33e2e4c13, #2962 a4a26ec63, #2847 c8b950cb4, #3114 c4ebe52de, #2664 0e2b6287c. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, -Resolution 1080, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world.

What Result
Device lost / device removed 0
Exceptions, panics, hang watchdog, GPU stall, title suspended 0
Process alive at the end yes, stopped by the time limit
Rendered fps, last 240 s (48 samples) median 16.2, mean 16.1
Rendered fps, last 120 s median 15.1

For reference, the same machine and route rendered 13.3 to 17.2 fps today on main with single pull requests or other batches. These fps are a check that nothing fell over, not a measurement of a gain.

Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it.

Limits: one run; free system memory was low (median 0.6 GB); arrival in the world was driven by keys and not checked on pictures. An earlier attempt of this batch is not counted: two runs were started at the same time by mistake on one GPU (no device loss in either, but the measure is not clean).

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7352917368 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2833#issuecomment-7352917368). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T17:06:53Z. --- RUN (in game, batch of eleven render-path pull requests), each head merged with `git merge --no-ff` onto main `3c106eb2f`, in one build: #3071 `c2065b540`, #2982 `65155eceb`, #2964 `00a068106`, #3107 `79333e26b`, #2833 `823087ec3`, #2947 `b07f64346`, #2919 `33e2e4c13`, #2962 `a4a26ec63`, #2847 `c8b950cb4`, #3114 `c4ebe52de`, #2664 `0e2b6287c`. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, `-Resolution 1080`, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world. | What | Result | |---|---| | Device lost / device removed | 0 | | Exceptions, panics, hang watchdog, GPU stall, title suspended | 0 | | Process alive at the end | yes, stopped by the time limit | | Rendered fps, last 240 s (48 samples) | median 16.2, mean 16.1 | | Rendered fps, last 120 s | median 15.1 | For reference, the same machine and route rendered 13.3 to 17.2 fps today on main with single pull requests or other batches. These fps are a check that nothing fell over, not a measurement of a gain. Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it. Limits: one run; free system memory was low (median 0.6 GB); arrival in the world was driven by keys and not checked on pictures. An earlier attempt of this batch is not counted: two runs were started at the same time by mistake on one GPU (no device loss in either, but the measure is not clean). AI-assisted (Claude Code).
MoonEyes commented 2026-12-02 18:12:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:12:53Z.


Reviewed #2833 (code review only, not built here: Windows-only). Bounds and pointer checks are sound and tested; in-game PASS at this head. One behaviour change worth stating in the description.

Head 823087ec39
Merge with main 45dc41f95c clean (git merge-tree); merge base 27613ab6b8, 369 commits behind
Switches registry on the merge exit 0
Evidence fiestorra (Windows, crate green), MoonEyes' e1a0e5c31 on the branch, author's Windows run of queue::tests (11 passed) at this head, MoonEyes in-game PASS (2 December 17:06, batch of eleven)

Review of d3d12/crates/leonida-gpu/src/queue.rs copy_page_mappings

  • page_batches and batch_ranges return an empty slice for count == 0 (no pointer needed) and refuse null or misaligned pointers otherwise, so from_raw_parts is never called with a pointer that violates its contract. The # Safety sections match.
  • map_range computes the source only for kinds 0 and 1 (kinds 2 and 3 carry an unused start), with checked_add/checked_mul on every destination and source step, and refuses a wrapping range before any map call. The tests assert zero map calls for wrapping ranges of every kind.
  • A batch that cannot be read, or a range that wraps, is left out, but the other batches are still mapped (MoonEyes' change), and the call reports failure.

Behaviour change. Two things that returned S_OK now return E_INVALIDARG: non-zero flags, and any failed or left-out mapping. Both match the console shim (runtime/shims/d3d12_xs_device.cpp:2429 and :2199, as the description cites), and the in-game batch saw no regression. If a later run shows the title passing non-zero flags (the ONCE warning "CopyPageMappings refused" would say), that is where to look first.

Process. The description's AI line is just "yes"; the author's comment names Gemini 4 Neon for the last round. No GPUs tested: line.

Verdict: ready.

AI-assisted: Claude Opus 5.5 (Claude Code), review only.

AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.


Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7354137822 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2833#issuecomment-7354137822). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T18:12:53Z. --- **Reviewed #2833 (code review only, not built here: Windows-only). Bounds and pointer checks are sound and tested; in-game PASS at this head. One behaviour change worth stating in the description.** | | | |---|---| | Head | `823087ec39` | | Merge with `main` `45dc41f95c` | clean (`git merge-tree`); merge base `27613ab6b8`, 369 commits behind | | Switches registry on the merge | exit 0 | | Evidence | fiestorra (Windows, crate green), MoonEyes' `e1a0e5c31` on the branch, author's Windows run of `queue::tests` (11 passed) at this head, MoonEyes in-game PASS (2 December 17:06, batch of eleven) | **Review of `d3d12/crates/leonida-gpu/src/queue.rs` `copy_page_mappings`** - `page_batches` and `batch_ranges` return an empty slice for `count == 0` (no pointer needed) and refuse null or misaligned pointers otherwise, so `from_raw_parts` is never called with a pointer that violates its contract. The `# Safety` sections match. - `map_range` computes the source only for kinds 0 and 1 (kinds 2 and 3 carry an unused `start`), with `checked_add`/`checked_mul` on every destination and source step, and refuses a wrapping range before any `map` call. The tests assert zero `map` calls for wrapping ranges of every kind. - A batch that cannot be read, or a range that wraps, is left out, but the other batches are still mapped (MoonEyes' change), and the call reports failure. **Behaviour change.** Two things that returned `S_OK` now return `E_INVALIDARG`: non-zero `flags`, and any failed or left-out mapping. Both match the console shim (`runtime/shims/d3d12_xs_device.cpp:2429` and `:2199`, as the description cites), and the in-game batch saw no regression. If a later run shows the title passing non-zero flags (the `ONCE` warning "CopyPageMappings refused" would say), that is where to look first. **Process.** The description's AI line is just "yes"; the author's comment names Gemini 4 Neon for the last round. No `GPUs tested:` line. **Verdict: ready.** AI-assisted: Claude Opus 5.5 (Claude Code), review only. AI-assisted verification: Claude Opus (Claude Code), separate agent per batch. --- _Generated by [Claude Code](https://claude.ai/code)_
bobcatchris commented 2026-12-02 21:02:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-12-02T21:02:13Z.


@MoonEyes @KelboLive Thank you both for the reviews!

  • Updated the PR description to state the E_INVALIDARG behaviour change on non-zero flags / failed/left-out mappings, add GPUs tested:, clarify AI-assisted disclosure, and scope the shim comparison to the ChildProxy path.
  • Answering @KelboLive's question: the 4-argument C++ shim route (runtime/shims/d3d12_xs_device.cpp:2173, :2157, :2196) is intentionally left out of scope for a separate PR.
  • Head 823087ec3 is left untouched to preserve @MoonEyes's 2026-12-02T17:06:53Z in-game batch PASS.

AI-assisted: Gemini 4 Neon

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7358696024 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2833#issuecomment-7358696024). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-12-02T21:02:13Z. --- @MoonEyes @KelboLive Thank you both for the reviews! - Updated the PR description to state the `E_INVALIDARG` behaviour change on non-zero `flags` / failed/left-out mappings, add `GPUs tested:`, clarify `AI-assisted` disclosure, and scope the shim comparison to the `ChildProxy` path. - Answering `@KelboLive`'s question: the 4-argument C++ shim route (`runtime/shims/d3d12_xs_device.cpp:2173`, `:2157`, `:2196`) is intentionally left out of scope for a separate PR. - Head `823087ec3` is left untouched to preserve `@MoonEyes`'s `2026-12-02T17:06:53Z` in-game batch PASS. AI-assisted: Gemini 4 Neon
MoonEyes commented 2026-12-03 17:39:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T17:39:40Z.


In-game gate run on an RTX 4060 8 GB (driver 610.88, Windows 11), in a batch of #2840, #2833, #2832 and #2831 merged into main 09273248c; this PR tested at its current head 823087ec3. Series S 1080, DLSS FG 2x, play-nvidia.ps1 -SeriesS -Resolution 1080 -FrameGen 2 -PrecompileUsed, scripted walk, 330 s, screen kept on.

  • Result: PASS. No device lost, no crash, no unhandled exception; the run ended on its time limit.
  • Median over the last 240 s: 15.4 fps (main alone today: 15.8-17.5; the batch before this one on the same main gave 15.8); 23.3 frames per 1000 over 100 ms.
  • Covered: a normal launch and walk with this PR's code in the build. It does not isolate this PR's own change from the three others in the batch.

AI-assisted (Claude Opus 5.5), run and read by MoonEyes' agent.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7386863083 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2833#issuecomment-7386863083). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-03T17:39:40Z. --- In-game gate run on an RTX 4060 8 GB (driver 610.88, Windows 11), in a batch of #2840, #2833, #2832 and #2831 merged into main `09273248c`; this PR tested at its current head `823087ec3`. Series S 1080, DLSS FG 2x, `play-nvidia.ps1 -SeriesS -Resolution 1080 -FrameGen 2 -PrecompileUsed`, scripted walk, 330 s, screen kept on. - Result: **PASS**. No device lost, no crash, no unhandled exception; the run ended on its time limit. - Median over the last 240 s: 15.4 fps (main alone today: 15.8-17.5; the batch before this one on the same main gave 15.8); 23.3 frames per 1000 over 100 ms. - Covered: a normal launch and walk with this PR's code in the build. It does not isolate this PR's own change from the three others in the batch. AI-assisted (Claude Opus 5.5), run and read by MoonEyes' agent.
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/2833:upstream-pr/2833'
git switch 'upstream-pr/2833'

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/2833'
git switch 'upstream-pr/2833'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2833'
git switch 'upstream-pr/2833'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2833'
git switch 'main'
git merge --squash 'upstream-pr/2833'
git switch 'main'
git merge --ff-only 'upstream-pr/2833'
git switch 'main'
git merge 'upstream-pr/2833'
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
ProjectLeonida/mandy!2833
No description provided.