run: free the executable's bytes once its image is mapped #2069
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2071"
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 0xkn0wh3r3 on 2026-11-25T04:22:44Z.
The 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
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T04:26:34Z.
Review: COMMENTED
Static review only: apps/victory is Windows-only (Win32/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Executable bytes freed once its image is mapped — memory-footprint fix on the launcher path; check the unmap ordering against PE relocation fixups.
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T04:41:46Z.
Review: APPROVED
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, Rust 1.98.1 MSVC):cargo test -p victory— 12 passed, 0 failedcargo clippy -p victory --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean drop of raw executable bytes immediately after mapping the image. Looks good.
AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T06:35:34Z.
@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.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:26:41Z.
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
Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T18:51:08Z.
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