Watch: mapped image memory is not tracked as GPU memory #2235

Closed
denkencar-sketch wants to merge 1 commit from upstream-pr/2237 into main
denkencar-sketch commented 2026-11-25 08:31:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by denkencar-sketch on 2026-11-25T08:31:40Z.


Summary

runtime_memory(at, true) accepts "anything but plain committed private memory", which includes committed MEM_IMAGE memory: the title's own .rdata or .data. From reading shadow::loose (a 4 MiB-aligned shadow) I expect it can reach such memory, and span .text as well; I have not run that path. A tracked page is made PAGE_READONLY when taken, which also removes execute access from code that shares its 64 KiB page. The next instruction fetch there is an execute access violation, which the guard handler ignores (it only handles writes), and the process crashes.

Change

Mapped images are refused, as plain heap memory already is. It leaves MEM_FREE as it is (that is #1849's change), so the two do not overlap. An untracked shadow is refreshed as any plain memory is.

Testing

watch::tests::image_memory_is_not_tracked calls track on a static in this test binary's image and on one of its functions: on main both are tracked; with this change neither is. The test never takes the pages, so it cannot make code unexecutable. cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings is clean.

Not tried: the loose-shadow path in the game, so I have not seen a title's data actually land in a tracked page. The premise (image memory passes runtime_memory) is what the test shows. modules::dstorage::tests::a_page_list_filled_after_its_request_starts fails now and then on main too (5 of 20 runs of cargo test -p victory-hle --lib); it is unrelated.

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6600409588 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2237). Originally posted by [denkencar-sketch](https://github.com/denkencar-sketch) on 2026-11-25T08:31:40Z. --- ## Summary `runtime_memory(at, true)` accepts "anything but plain committed private memory", which includes committed `MEM_IMAGE` memory: the title's own `.rdata` or `.data`. From reading `shadow::loose` (a 4 MiB-aligned shadow) I expect it can reach such memory, and span `.text` as well; I have not run that path. A tracked page is made `PAGE_READONLY` when taken, which also removes execute access from code that shares its 64 KiB page. The next instruction fetch there is an execute access violation, which the guard handler ignores (it only handles writes), and the process crashes. ## Change Mapped images are refused, as plain heap memory already is. It leaves `MEM_FREE` as it is (that is #1849's change), so the two do not overlap. An untracked shadow is refreshed as any plain memory is. ## Testing `watch::tests::image_memory_is_not_tracked` calls `track` on a static in this test binary's image and on one of its functions: on `main` both are tracked; with this change neither is. The test never takes the pages, so it cannot make code unexecutable. `cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings` is clean. Not tried: the loose-shadow path in the game, so I have not seen a title's data actually land in a tracked page. The premise (image memory passes `runtime_memory`) is what the test shows. `modules::dstorage::tests::a_page_list_filled_after_its_request_starts` fails now and then on `main` too (5 of 20 runs of `cargo test -p victory-hle --lib`); it is unrelated. AI-assisted.
DenRakEiw commented 2026-11-25 09:05:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T08:42:38Z.

Review: APPROVED


Verified locally merged onto origin/main (940d32f, Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --lib watch:: — 7 passed, 0 failed (including image_memory_is_not_tracked)
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean guard excluding mapped MEM_IMAGE pages from GPU memory tracking with unit test coverage. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6054309328 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2237#pullrequestreview-6054309328). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T08:42:38Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu --lib watch::` — **7 passed, 0 failed** (including `image_memory_is_not_tracked`) - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean guard excluding mapped `MEM_IMAGE` pages from GPU memory tracking with unit test coverage. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-25 09:05:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T08:48:33Z.

Review: COMMENTED


Watch: mapped image memory (MEM_IMAGE) is not tracked as GPU memory — guarding it would strip execute access from code sharing a 64 KiB page. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Same cluster; one-line predicate change plus test.

<!-- greyfinch-sync:Marvisak/VIctory:review:6054381116 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2237#pullrequestreview-6054381116). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T08:48:33Z. **Review:** COMMENTED --- Watch: mapped image memory (MEM_IMAGE) is not tracked as GPU memory — guarding it would strip execute access from code sharing a 64 KiB page. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Same cluster; one-line predicate change plus test.
MamaLeVrai commented 2026-11-25 10:07:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MamaLeVrai on 2026-11-25T09:13:35Z.


Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head 74e33471 into main 940d32f in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings: clean; the same with --all-features: clean. cargo test --workspace --locked: 702 passed, 0 failed, 10 ignored, two runs (main alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158044155 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2237#issuecomment-7158044155). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-25T09:13:35Z. --- Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head `74e33471` into `main` `940d32f` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean; the same with `--all-features`: clean. `cargo test --workspace --locked`: 702 passed, 0 failed, 10 ignored, two runs (`main` alone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
Marvisak commented 2026-11-25 13:02:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T12:44:36Z.


Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-gpu/src/watch.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (merge-candidate) was for an older state of main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7162793036 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2237#issuecomment-7162793036). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T12:44:36Z. --- <!-- victory-triage v1 head=74e334710d2dfb829512e8514e73ca9eabeb47d1 verdict=needs-rebase at=2026-11-25T16:17:30Z --> Automated triage for the maintainers. This pull request no longer merges cleanly into `main` (conflicts in `crates/victory-gpu/src/watch.rs`). It will be reviewed once it is rebased onto the current `main`. The earlier verdict (merge-candidate) was for an older state of `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
denkencar-sketch commented 2026-11-26 00:03:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by denkencar-sketch on 2026-11-25T23:12:01Z.


Closing as superseded: commit 280b1505 added the \info.Type != MEM_IMAGE\ check to
untime_pages\ in \watch.rs\ on \main.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177257590 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2237#issuecomment-7177257590). Originally posted by [denkencar-sketch](https://github.com/denkencar-sketch) on 2026-11-25T23:12:01Z. --- Closing as superseded: commit 280b1505 added the \info.Type != MEM_IMAGE\ check to \ untime_pages\ in \watch.rs\ on \main\.

Pull request closed

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
Marvisak/VIctory!2235
No description provided.