GPU: remapping one mapping of aliased pages marks the others changed, dropping marked shader writes there #2414

Open
opened 2026-11-26 05:04:59 +00:00 by github-bot · 3 comments
Owner

@⁠BastienRodz on GitHub · 2026-11-25 13:07 UTC · original

What happens

When physical pages show at two addresses a and b (linked by title_memory_aliased) and the runtime remaps or unmaps b (title_memory_remapped(b, len), called from xmem::unmap and the mapping paths), watch.rs marks [b, b + len) changed through changed, which follows alias links. a's pages are opened as well, and their trackers are marked changed with nothing saved, although a still shows the same bytes.

If a host copy over a is armed for marked writes in a submission that is running (Shadow::writing(.., true)), copy_back_marked then finds saved.is_none() && t.changed(page) and keeps the title's bytes, which drops the shaders' writes to those pages. A title write to a afterwards does not fault either, so it saves nothing. copy_back_page drops page-table writes there for the same reason.

Expected

title_memory_remapped's own description: "The runtime mapped or unmapped title memory [at, at + len): what it shows is new". Other addresses showing the same physical pages show what they did before. They should stay guarded and unchanged for their trackers. A page guarded only because of the removed link, which no tracker holds itself or through a remaining alias, can be opened.

Where

crates/victory-gpu/src/watch.rs, title_memory_remapped (it calls changed, not changed_here). Effects in crates/victory-gpu/src/shadow.rs (copy_back_marked, copy_back_page).

AI-assisted (Gemini 4 Neon found it, Claude Code reviewed and verified it); synthetic test only, no game data.

**@⁠BastienRodz** on GitHub · 2026-11-25 13:07 UTC · [original](https://github.com/Marvisak/VIctory/issues/2414) ### What happens When physical pages show at two addresses `a` and `b` (linked by `title_memory_aliased`) and the runtime remaps or unmaps `b` (`title_memory_remapped(b, len)`, called from `xmem::unmap` and the mapping paths), `watch.rs` marks `[b, b + len)` changed through `changed`, which follows alias links. `a`'s pages are opened as well, and their trackers are marked changed with nothing saved, although `a` still shows the same bytes. If a host copy over `a` is armed for marked writes in a submission that is running (`Shadow::writing(.., true)`), `copy_back_marked` then finds `saved.is_none() && t.changed(page)` and keeps the title's bytes, which drops the shaders' writes to those pages. A title write to `a` afterwards does not fault either, so it saves nothing. `copy_back_page` drops page-table writes there for the same reason. ### Expected `title_memory_remapped`'s own description: "The runtime mapped or unmapped title memory `[at, at + len)`: what it shows is new". Other addresses showing the same physical pages show what they did before. They should stay guarded and unchanged for their trackers. A page guarded only because of the removed link, which no tracker holds itself or through a remaining alias, can be opened. ### Where `crates/victory-gpu/src/watch.rs`, `title_memory_remapped` (it calls `changed`, not `changed_here`). Effects in `crates/victory-gpu/src/shadow.rs` (`copy_back_marked`, `copy_back_page`). AI-assisted (Gemini 4 Neon found it, Claude Code reviewed and verified it); synthetic test only, no game data.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:04:59 +00:00
Author
Owner

@⁠shawshanker18 on GitHub · 2026-11-25 16:41 UTC · original

Tested both fixes for this, each merged onto main (67e8ae1), on Windows 11 with an RTX 4050 Laptop. Command: cargo test -p victory-gpu --lib.

  • #2415: merges clean; remapping_an_alias_does_not_drop_marked_writes_on_the_surviving_copy passes; no failures beyond main's 2 (NVIDIA view-heap cap).
  • #2549: merges clean; remapping_one_mapping_leaves_the_other_unchanged passes; same 2.
  • The two conflict with each other.

Both make the same core change: title_memory_remapped calls changed_here, not changed. #2415 additionally opens alias pages that were guarded only through the removed link when no tracker holds them, either directly or through a remaining link. That is the issue's "Expected". With #2549 such a page stays guarded, so the next write to it takes a fault and opens it: a cost, not a lost write.

#2415's test goes end to end through copy_back_marked with real twin views; #2549's links two separate pool pages.

#2415 also merges cleanly with #2455 and with #2561 (#2454).

**@⁠shawshanker18** on GitHub · 2026-11-25 16:41 UTC · [original](https://github.com/Marvisak/VIctory/issues/2414#issuecomment-7168375794) Tested both fixes for this, each merged onto `main` (`67e8ae1`), on Windows 11 with an RTX 4050 Laptop. Command: `cargo test -p victory-gpu --lib`. - **#2415:** merges clean; `remapping_an_alias_does_not_drop_marked_writes_on_the_surviving_copy` passes; no failures beyond `main`'s 2 (NVIDIA view-heap cap). - **#2549:** merges clean; `remapping_one_mapping_leaves_the_other_unchanged` passes; same 2. - The two conflict with each other. Both make the same core change: `title_memory_remapped` calls `changed_here`, not `changed`. #2415 additionally opens alias pages that were guarded only through the removed link when no tracker holds them, either directly or through a remaining link. That is the issue's "Expected". With #2549 such a page stays guarded, so the next write to it takes a fault and opens it: a cost, not a lost write. #2415's test goes end to end through `copy_back_marked` with real twin views; #2549's links two separate pool pages. #2415 also merges cleanly with #2455 and with #2561 (#2454).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 18:49 UTC · original · edited 2026-11-26 06:48 UTC

Automated triage for the maintainers.

Confirmed in main. In crates/victory-gpu/src/watch.rs, title_memory_remapped marks the remapped pages changed, and the change is also applied to every page linked in alias_of, which opens the other mappings and marks them changed with nothing saved. In Shadow::copy_back_marked (shadow.rs), a page that is changed with nothing saved keeps the title's bytes.

There are two open PRs, and they conflict with each other:

  • #2415, which also opens alias pages that were guarded only through the removed link.
  • #2549, which makes only the core change.

New since the last triage: a comparison on an RTX 4070 against main 63bcca4 found both regression tests fail on main and pass with their fix, but #2549 no longer compiles on current main: changed_here was split into mark_changed and open_guarded (#2239), so it needs a rebase. #2415 builds and is a superset of #2549, though no test covers its extra branch.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 18:49 UTC · [original](https://github.com/Marvisak/VIctory/issues/2414#issuecomment-7171452520) · edited 2026-11-26 06:48 UTC <!-- victory-issue-triage v1 verdict=confirmed seen=2026-11-26T04:06:42Z at=2026-11-26T07:21:00Z --> Automated triage for the maintainers. Confirmed in `main`. In `crates/victory-gpu/src/watch.rs`, `title_memory_remapped` marks the remapped pages changed, and the change is also applied to every page linked in `alias_of`, which opens the other mappings and marks them changed with nothing saved. In `Shadow::copy_back_marked` (`shadow.rs`), a page that is changed with nothing saved keeps the title's bytes. There are two open PRs, and they conflict with each other: - #2415, which also opens alias pages that were guarded only through the removed link. - #2549, which makes only the core change. **New since the last triage:** a comparison on an RTX 4070 against `main` `63bcca4` found both regression tests fail on `main` and pass with their fix, but **#2549 no longer compiles on current `main`**: `changed_here` was split into `mark_changed` and `open_guarded` (#2239), so it needs a rebase. #2415 builds and is a superset of #2549, though no test covers its extra branch. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠pawrenity on GitHub · 2026-11-26 04:06 UTC · original

Comparative check of the two open PRs for this issue. All runs were against main at 63bcca4 on an NVIDIA GeForce RTX 4070 with Windows 11, using cargo test -p victory-gpu --lib -- --test-threads=1 and cargo clippy -p victory-gpu --all-targets -- -D warnings. On this card main itself has 2 failures (descriptor::host::tests::dynamic_slots_are_held_until_released and memory::tests::lists_share_a_table_and_copies_keep_their_views, the NVIDIA view-heap cap). Every run below has those same 2 and no others.

For the cross-tests, each PR's test was copied word for word into the other tree, with the early "no device" return changed to a panic!.

PR Head Own test Own test fails on main without the fix Other PR's test on this fix Clippy -D warnings Merges into main Defects found
#2415 5661933 shadow::tests::remapping_an_alias_does_not_drop_marked_writes_on_the_surviving_copy passes (230 passed after merge) yes: page 0's shader write goes back #2549's test passes, on the head and after merging into main clean clean, and builds none
#2549 50c4355 watch::tests::remapping_one_mapping_leaves_the_other_unchanged passes at its own head (194 passed) yes: the other mapping still shows what it did #2415's test passes at #2549's head clean at its head merges without a text conflict, but does not compile build failure on main, see below

The two PRs conflict with each other in crates/victory-gpu/src/watch.rs.

#2549 does not build on current main. #2239 split changed_here into mark_changed and open_guarded. After merging, title_memory_remapped still calls changed_here(&mut g, first, last, false), which fails with error[E0425]: cannot find function 'changed_here' in this scope (crates/victory-gpu/src/watch.rs:819 in the merged tree). I replaced that line locally with mark_changed(..); open_guarded(..);, the same change #2415 already carries. With it, the merged tree passes the full suite (230 passed), clippy is clean, and #2415's test passes.

Core change. Both PRs make the same core change: title_memory_remapped marks only [first, last) and no longer marks every aliased page through changed. #2415 also opens a formerly linked page when nothing holds it, either directly or through a remaining link. Otherwise that page stays guarded with no tracker, so the next write to it takes a fault (a cost, not a lost write). I found no defect in that branch, but neither PR's test exercises it: in #2415's test the surviving mapping is held, so the page is not opened.

Recommendation. #2415. It is rebased onto current main and builds there. Its end-to-end test fails on main and passes with the fix, and the other PR's test also passes on it. It is a superset of #2549's change. #2549 needs the changed_here → mark_changed + open_guarded update before it can merge.

AI-assisted (Claude Code).

**@⁠pawrenity** on GitHub · 2026-11-26 04:06 UTC · [original](https://github.com/Marvisak/VIctory/issues/2414#issuecomment-7182303652) Comparative check of the two open PRs for this issue. All runs were against `main` at `63bcca4` on an NVIDIA GeForce RTX 4070 with Windows 11, using `cargo test -p victory-gpu --lib -- --test-threads=1` and `cargo clippy -p victory-gpu --all-targets -- -D warnings`. On this card `main` itself has 2 failures (`descriptor::host::tests::dynamic_slots_are_held_until_released` and `memory::tests::lists_share_a_table_and_copies_keep_their_views`, the NVIDIA view-heap cap). Every run below has those same 2 and no others. For the cross-tests, each PR's test was copied word for word into the other tree, with the early "no device" `return` changed to a `panic!`. | PR | Head | Own test | Own test fails on `main` without the fix | Other PR's test on this fix | Clippy `-D warnings` | Merges into `main` | Defects found | |---|---|---|---|---|---|---|---| | #2415 | `5661933` | `shadow::tests::remapping_an_alias_does_not_drop_marked_writes_on_the_surviving_copy` passes (230 passed after merge) | **yes**: `page 0's shader write goes back` | #2549's test passes, on the head and after merging into `main` | clean | clean, and builds | none | | #2549 | `50c4355` | `watch::tests::remapping_one_mapping_leaves_the_other_unchanged` passes at its own head (194 passed) | **yes**: `the other mapping still shows what it did` | #2415's test passes at #2549's head | clean at its head | merges without a text conflict, but **does not compile** | build failure on `main`, see below | The two PRs conflict with each other in `crates/victory-gpu/src/watch.rs`. **#2549 does not build on current `main`.** #2239 split `changed_here` into `mark_changed` and `open_guarded`. After merging, `title_memory_remapped` still calls `changed_here(&mut g, first, last, false)`, which fails with `error[E0425]: cannot find function 'changed_here' in this scope` (`crates/victory-gpu/src/watch.rs:819` in the merged tree). I replaced that line locally with `mark_changed(..); open_guarded(..);`, the same change #2415 already carries. With it, the merged tree passes the full suite (230 passed), clippy is clean, and #2415's test passes. **Core change.** Both PRs make the same core change: `title_memory_remapped` marks only `[first, last)` and no longer marks every aliased page through `changed`. #2415 also opens a formerly linked page when nothing holds it, either directly or through a remaining link. Otherwise that page stays guarded with no tracker, so the next write to it takes a fault (a cost, not a lost write). I found no defect in that branch, but neither PR's test exercises it: in #2415's test the surviving mapping is held, so the page is not opened. **Recommendation.** #2415. It is rebased onto current `main` and builds there. Its end-to-end test fails on `main` and passes with the fix, and the other PR's test also passes on it. It is a superset of #2549's change. #2549 needs the `changed_here` → `mark_changed` + `open_guarded` update before it can merge. AI-assisted (Claude Code).
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#2414
No description provided.