fix(gpu): stop copy_mapped on non-writable title destinations instead of faulting #3358
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!3358
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3358"
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?
@reeledMarek on GitHub · 2026-11-26 20:25 UTC · original
reeledMarek:fix/gpu-copy-mapped-readonly-dst→main· +79 −6 · 1 files · 1 commits · openSummary
copy_mapped(dst, src, len, title_dst = true)fails its initialReadProcessMemorycall because the destination contains committedPAGE_READONLY(or execute-only) pages,crate::texture::committed(dst, len)previously returnedtrue(sincecommittedonly rejectsPAGE_NOACCESS | PAGE_GUARDfor readable sources).read()on each 4 KiB piece and executedunsafe { to.write_bytes(0, n) }, causing an immediate access violation on the read-only title destination.writable(dst, len)check (requiringMEM_COMMIT, noPAGE_NOACCESS | PAGE_GUARD, and a writable base protection) before entering the fallback fortitle_dst, and routestitle_dstzero-fills throughread(ZERO_4K.as_ptr(), to, n)so concurrent protection changes cannot fault either.title_copies::title_copies_do_not_fault_on_read_only_destinationsusingVirtualProtect(..., PAGE_READONLY).Verification
cargo clippy -p victory-gpu --all-targets --target x86_64-pc-windows-msvc --locked -- -D warningscargo test -p xtask --locked@Dukestar69 on GitHub · 2026-11-26 20:29 UTC · original · approved these changes
LGTM — verified on Windows against
origin/main(63bcca4).writable(dst, len)(instead of onlycommitted) and usingread(ZERO_4K.as_ptr(), to, n)ontitle_dstpreventscopy_mappedfrom faulting on read-only title destination pages during the fallback path.cargo test -p victory-gpu --lib host::title_copies:: -- --test-threads=1: 3 passed, 0 failed (includingtitle_copies_do_not_fault_on_read_only_destinations).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.