Loader: free mapped module on TLS redirect error and add windows.rs unit tests #1201
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!1201
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1201"
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?
@geiyiliyabumo on GitHub · 2026-11-24 16:24 UTC · original
geiyiliyabumo:test/loader-windows→main· +413 −1 · 1 files · 1 commits · openSummary
Closes #1047
Full verification details and change notes are documented in #1047 (commit
98b761b, based onmainffe310e).Verification (Windows 11 x64 MSVC)
rustfmt --edition 2024 --checkon edited files: PASScargo xtask policy: PASS (zero game files/data)cargo clippy --all-targets --locked -- -D warnings(default +--features diagnosticswhere applicable): PASSAI-assisted; synthetic tests only, no game files.
@Zipettte on GitHub · 2026-11-24 18:00 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 98b761b:
cargo test -p victory-loaderpasses, 38 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@Marvisak on GitHub · 2026-11-25 01:26 UTC · original · edited 2026-11-25 02:29 UTC
Automated triage for the maintainers.
Merge candidate. Recommended for a maintainer's look. Thanks for trimming this as asked. The range guards and their tests are gone. What remains is the
FreeLibrary(module)inload(crates/victory-loader/src/windows.rs) whentls::redirectfails, so a load that fails after mapping no longer leaves the copy mapped.LoadedImagehas noDrop, andthreads::mappedhas not run yet at that point, so freeing it there is safe.The added tests cover existing behaviour: provenance-based binding, protection restore, unresolved-import stubs, export lookup, title DLL mapping, and the new unmap-on-failure path. That last test forces the failure through
tls::near's 1 GiB size refusal. The PR body still describes the old 596-line version and points to #1047. Updating it would help the reviewer.CI: passing.
Generated by Claude Code
@geiyiliyabumo on GitHub · 2026-11-25 01:39 UTC · original
Updated per triage feedback: dropped the three range guards (IAT bound, TLS callback range, and DLL/EXE entry-point range checks) along with their tests, keeping only the \FreeLibrary\ cleanup on \ ls::redirect\ failure and the existing-behavior unit tests. Rebased onto \main; \cargo test -p victory-loader --locked\ (47 passed, 0 failed), \cargo clippy -p victory-loader --all-targets --locked -- -D warnings, and \cargo xtask policy\ all pass.
@fuzeofficlal on GitHub · 2026-11-26 01:14 UTC · original
Code review and Windows 11 verification at head
5edb22b53a17merged cleanly ontomain(63bcca43c6a0):crates/victory-loader/src/windows.rs:85-92, 436-839):FreeLibrary(module)before returning ontls::redirectfailure cleanly eliminates the leakedHMODULE(sinceLoadedImagehas noDropimpl). Runs strictly beforethreads::mapped(&loaded)and afterprepare()strips entrypoints/imports, so there is no double-free or dangling registry pointer.windows.rsunit tests thoroughly coverload/unload,write_if_changed,bind_imports, section protections, unresolved stubs,a_failed_tls_redirect_unmaps_the_image(verified viaGetModuleHandleW),export, andload_title_dlls.cargo xtask policy:191 files ok;cargo clippy -p victory-loader --all-targets -- -D warnings: 0 warningsvictory-loader: 44/44 unit + 4/4 integration (crash_log,load_probe,title_dlls) passed.LGTM.
@potatoe0100 on GitHub · 2026-11-26 14:21 UTC · original
Heads-up for the merge batch: this PR and #1059 are both merge candidates and each merges cleanly onto
main(63bcca4), but together they don't compile. #1059 changesvictory_loader::windows::loadto take a thirdoriginal_name: &strargument, and the two new tests here callload(&prepared, dir.path())(windows.rs, around lines 594 and 769 after both merge). I checkedmain+ #1059 + #1201:cargo test -p victory-loader --no-runfails with E0061 twice. Whichever lands second needs the extra argument.AI-assisted (Claude).
@fuzeofficlal on GitHub · 2026-11-26 14:39 UTC · original · approved these changes
Reviewed
5edb22b53a17d3025a43ddac4d407aad60c250d7merged cleanly ontomain(63bcca43c6a0) and verified on Windows 11 x64 (Rust1.98.1, debug and--release).Code Review
crates/victory-loader/src/windows.rs:85-92): Callingunsafe { FreeLibrary(module) }ontls::redirectfailure cleanly unmaps the module (along with its OS unwind table and static TLS slot) before returning the error. Becauseprepare()strips entry points and imports, no title code runs duringLoadLibraryExW;threads::mapped(&loaded)runs aftertls::redirectsucceeds (so no dangling module registration exists), andLoadedImagehas noDropimpl (so there is no double-free risk).crates/victory-loader/src/windows.rs:577-839): The 9 new unit tests thoroughly exerciseload/unload,write_if_changedon unchanged read-only files, provenance-based import/delay-import binding, per-section memory protection restoration, callable stubs for unresolved imports, export lookups, deduplicated lowercase title DLL loading, anda_failed_tls_redirect_unmaps_the_image(verifyingGetModuleHandleW == 0after the forcedtls::nearfailure).#1059(which adds a thirdoriginal_name: &strparameter towindows::load) lands before this PR, the two newload(&prepared, dir.path())test calls here will need the extra argument.Verification (Windows 11 x64, Rust
1.98.1)cargo run --locked -p xtask -- policy:191 files ok.cargo clippy --locked -p victory-loader -p victory-pe --all-targets -- -D warnings(default and--all-features): 0 warnings.cargo test --locked -p victory-loader -p victory-pe -- --test-threads=1(bothdevand--release): 84/84 passed in each profile (victory-loader: 44 unit + 1crash_log+ 2load_probe+ 1title_dlls;victory-pe: 36 unit).LGTM.
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.