GPU: avoid faulting when zero-filling protected title memory #1465
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1466"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by fluffyflattershy-afk on 2026-11-24T18:15:14Z.
copy_mapped checks whether a title destination is committed, but committed memory may still be read-only. If ReadProcessMemory fails on that destination, the 4 KiB fallback currently calls write_bytes directly and faults with 0xC0000005. The same raw write is unsafe if the mapping changes after the check.
For title destinations only, zero-fill through the existing kernel copy helper using a fixed 4 KiB zero buffer. The kernel checks the destination at the point of the write. The successful-copy path and the direct zero-fill for host-owned writable destinations are unchanged.
Regression: an isolated child test allocates and initializes one page, marks it PAGE_READONLY, then calls copy_mapped with title_dst=true. On upstream
ffe310eit exits -1073741819 (0xC0000005); with this change it succeeds and retains every original byte. A second test confirms an unreadable source still produces zeros in a writable destination. The child suppresses interactive fault dialogs.Validation: victory-gpu diagnostics tests: 55 passed, 0 failed, 1 ignored benchmark. Clippy all targets with diagnostics and warnings denied passed (Rust separately warned that incremental-cache hard links are unavailable in this environment). Staged asset-policy and whitespace checks passed. Also composed with #322 and #334 on a local test stack: its 65 GPU tests passed, 1 benchmark ignored.
Related to #322, but independently reproduced on main and submitted against main. This addresses a synthetic memory-safety failure; it is not established as the cause of an observed title crash or black world. No game data is included. AI-assisted implementation and testing with Codex.
Imported from Marvisak/VIctory. Originally posted by acetonahard-code on 2026-11-24T19:17:14Z.
Tested on Windows 11 (26200), RTX 4070 SUPER, driver 621.14, Rust 1.98.1. Base
mainatffe310e, PR head3ee8820.Reproduced the bug on
main: I copied only the newprotected_title_copytest module ontomain, without the fix.unreadable_source_still_zeroes_a_writable_title_destinationpasses.copy_to_readonly_title_memory_does_not_faultfails:child exited Some(-1073741819)(0xC0000005), as described.With this PR:
cargo test -p victory-gpumain--features diagnosticscargo clippy -p victory-gpu --all-targets -- -D warnings, with and without--features diagnostics: clean.cargo xtask policy: ok.cargo fmt --check -p victory-gpugives the same diffs as onmain. Only the lines after the new test module shift down. This PR adds no new ones.Overlap with other PRs: this merges cleanly with #1215. It conflicts with #322 in
copy_mapped, which you mention you resolved locally. Whichever lands second will need a rebase.Small notes, none blocking:
copystat::C::Unmapped, but the source was readable. A separate counter, or a comment, would keep the diagnostics honest.SAFETYcomment onread()still says "the destination is mapped writable memory".copy_mappednow relies on the kernel checking the destination too, so that comment could say so.I didn't test with game data.
Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:29:12Z.
Automated triage for the maintainers.
Needs rebase. This pull request conflicts with
main(conflicting:crates/victory-gpu/src/host.rs). It will be reviewed once it is rebased onto the currentmain.Generated by Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.