Loader: skip empty executable sections in tls::redirect and add tls.rs unit tests #1192
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!1192
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1192"
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:23 UTC · original
geiyiliyabumo:test/loader-tls-and-stacks→main· +312 −1 · 1 files · 1 commits · openSummary
Closes #938
Full verification details and change notes are documented in #938 (commit
02ea74c, 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.
@Kal0s-design on GitHub · 2026-11-24 16:27 UTC · original
Independent check of
02ea74c, merged locally ontomainffe310e(merge was clean). Windows 11, MSVC, Rust 1.98.1 as pinned.cargo test -p victory-loader --locked: lib 35 passed, 0 failed; 2 + 1 integration tests pass. The lib suite was run 15 more times: 15/15 green.cargo clippy -p victory-loader --all-targets --locked -- -D warnings, with and without--all-features: clean.tls.rstest module on top ofmain's production code (nothing else changed). 4 tests fail on 3 of 3 runs:a_directory_outside_the_image_is_an_error,an_index_no_loader_assigns_is_an_error,an_index_outside_the_image_is_not_written,an_empty_executable_section_does_not_stop_the_rest. All pass with the PR's code.Not covered: the
stacks.rschange (delaysis a new function, so its test cannot run againstmain; I only ran it on the PR); nothing was run against a real title.AI-assisted: yes. Every number above is from my own runs.
@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 02ea74c:
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:18 UTC · original · edited 2026-11-25 08:16 UTC
Automated triage for the maintainers.
Merge candidate. Update after your latest push (
ee9defc): the point from the last triage is addressed.tls::redirect(crates/victory-loader/src/tls.rs) now takes the section length asvirtual_size, orfile_sizewhen that is 0, matching howvictory_pemaps sections (crates/victory-pe/src/image.rs), and skips a section only when both are 0. The new testan_executable_section_with_zero_virtual_size_uses_its_file_sizecovers the raw-data-with-VirtualSize-0 case, and the SIB nit inother_nine_byte_windows_are_left_aloneis fixed ([rsi], no displacement).The rest is unit tests for
patch,thunks,nearandredirecton a synthetic image, which check the right things (per-register call targets, near-misses, thunk bytes, the slot the patched load returns). Onlytls.rschanges; no dependencies.CI: passing (
check).Generated by Claude Code
@geiyiliyabumo on GitHub · 2026-11-25 01:55 UTC · original
Rebased cleanly onto \main\ (\
ccfb029). \cargo test -p victory-loader --locked\ (51 passed, 0 failed), \cargo test -p victory-loader --locked --features diagnostics --lib stacks::tests\ (3 passed, 0 failed), \cargo clippy -p victory-loader --all-targets --locked -- -D warnings, and \cargo xtask policy\ all pass.@geiyiliyabumo on GitHub · 2026-11-25 04:00 UTC · original
Updated per triage feedback: reverted \stacks.rs\ completely back to \main\ and dropped the three redundant
edirect\ range guards and their guard-only tests, keeping only the empty-executable-section (\len == 0) skip hardening and the \patch/\ hunks\ unit tests in \ ls.rs. Rebased onto \main\ (\
940d32f); \cargo test -p victory-loader --locked\ (48 passed, 0 failed), \cargo clippy -p victory-loader --all-targets --locked -- -D warnings, and \cargo xtask policy\ all pass.@geiyiliyabumo on GitHub · 2026-11-25 07:55 UTC · original
Updated \ ls::redirect\ per triage feedback (head $sha): fall back to \ile_size\ when \irtual_size == 0\ (matching \ictory_pe::image::rva_to_file_offset) and skip only when both are 0, added a synthetic regression test for \irtual_size == 0\ with non-zero \ile_size, and fixed the \
@fuzeofficlal on GitHub · 2026-11-26 01:25 UTC · original
Code review and Windows 11 verification at head
ee9defcd5490merged cleanly ontomain(63bcca43c6a0):crates/victory-loader/src/tls.rs:51-61, 182-530):virtual_sizeif non-zero elsefile_size) is0cleanly avoidsVirtualProtect(..., 0, ...)failing withERROR_INVALID_PARAMETERand aborting static TLS redirection.VirtualAlloctests thoroughly cover real relocated execution across GPRs, negative 9-byte windows, overlapping matches, thunk layout, 1 GiBnearbounds,virtual_size == 0fallback, and empty executable sections.#188also introduces#[cfg(test)] mod testsat the bottom oftls.rs(minor text-only merge conflict; production changes are orthogonal and compose cleanly).cargo xtask policy:191 files ok;cargo clippy --locked -p victory-loader --tests -- -D warnings: 0 warningscargo test --locked -p victory-loader: 50/50 passed (46 unit including all 10tls::tests+ 4 integration).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.