run: free the executable's bytes once its image is mapped #2071
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!2071
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2071/head"
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?
@0xkn0wh3r3 on GitHub · 2026-11-25 04:22 UTC · original
0xkn0wh3r3:app/free-image-bytes-after-load→main· +5 −0 · 1 files · 1 commits · closed without mergingThe problem
runheld two copies of the title's executable in memory for the whole run, though neither is needed once the title is loaded. For Grand Theft Auto VI that held about 115 MB twice.The mechanism:
runreads the executable into memory (original) and prepares a patched copy of it for the loader (prepared, fromvictory_loader::prepare). It kept both until the title exited. The program runs from the imagevictory_loader::loadmaps, and neither buffer is read after that.The fix
Both buffers are now dropped right after
victory_loader::load(apps/victory/src/run.rs). The compiler checks that nothing uses them later. Nothing else changes.Ported from fxceless/victory-fork (commit
578d459), where the two blocks were found in a run's memory map.Testing
cargo build -p victory: the borrow checker confirms neither buffer is used after the load.cargo test -p victory: all pass.cargo clippy -p victory --all-targets: clean.Not covered
@0xkn0wh3r3 on GitHub · 2026-11-25 06:35 UTC · original
@catminou4: relocations are applied before the drop. \victory_loader::load` writes the prepared bytes to a file and maps it with `LoadLibraryExW`, and Windows applies the relocations while mapping it. The loaded image keeps its own copy of the image info and borrows neither buffer, which the compiler confirms. Once `load` returns, the file's bytes and the prepared copy aren't read again, so they're dropped right there.@Marvisak on GitHub · 2026-11-25 10:26 UTC · original · edited 2026-11-25 15:55 UTC
Automated triage for the maintainers.
This pull request no longer merges cleanly into
main(conflicts inapps/victory/src/run.rs). It will be reviewed once it is rebased onto the currentmain. The earlier verdict (merge-candidate) was for an older state ofmain.Generated by Claude Code
@0xkn0wh3r3 on GitHub · 2026-11-25 18:51 UTC · original
Closing: upstream
5c4c685(the exe's bytes are dropped once the image is mapped) does exactly this. The read is passed straight tovictory_loader::prepare, andpreparedis dropped right afterload.Pull request closed