GPU: avoid faulting when zero-filling protected title memory #1466
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1466
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@fluffyflattershy-afk on GitHub · 2026-11-24 18:15 UTC · original
fluffyflattershy-afk:fix/title-copy-protected-destination→main· +89 −2 · 1 files · 1 commits · opencopy_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.
@acetonahard-code on GitHub · 2026-11-24 19:17 UTC · original
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.
@Marvisak on GitHub · 2026-11-25 01:29 UTC · original
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
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.