Skip to content

PE tests: cover section RVA boundaries on every host - #2740

Open
XeNS1 wants to merge 1 commit into
Marvisak:mainfrom
XeNS1:codex/pe-section-rva-boundaries-20261126
Open

XeNS1 wants to merge 1 commit into
Marvisak:mainfrom
XeNS1:codex/pe-section-rva-boundaries-20261126

Conversation

@XeNS1

@XeNS1 XeNS1 commented Nov 25, 2026 •

Copy link
Copy Markdown

The section RVA overflow regression parsed the host test executable, so it failed on Linux before reaching the mapper. The remaining section boundary behavior had no focused coverage for raw padding, zero-filled virtual tails, or multiple sections.

Use the existing source-generated PE fixture for that regression and check the last representable file offset and the first overflowing offset. Add four tests with explicit expected mappings for the smaller of virtual/raw size, zero VirtualSize, empty sections and gaps in both section orders, and RVAs near u32::MAX. Production code is unchanged. Header RVA/TLS work in #1639 and delay-import coverage in #2731 remain separate.

Validation (native Linux x86-64, Rust 1.100.0, two build jobs):

  • cargo test -p victory-pe --locked --offline -- --skip parses_own_test_binary --skip rva_to_file_offset_maps_entry_point --skip rejects_iat_outside_image: 37 passed, 0 failed. Those three unchanged tests need a Windows PE host executable; the baseline had 32 pass / 4 fail, including the now-portable overflow regression.
  • Strict all-target/all-feature Clippy, changed-file rustfmt, repository/staged asset policy and diff checks pass.
  • In a separate temporary crate, all six mutations are caught: min -> max extent, inclusive end, missing zero-VirtualSize fallback, wrapping file offset, wrapping RVA subtraction, and first-section-only lookup. The unmodified snapshot passes all 37 portable tests.
  • Full Windows workspace CI passes both Clippy configurations and workspace tests on f0d5342 (run).

Integration with #2731 at 694baa3 also applies without conflicts: 41 portable PE tests pass, strict Clippy and staged policy pass (independent Linux report).

All fixtures are generated from source. No game files, binaries or GPU execution used. AI-assisted: OpenAI Codex.

Coordination claim.

@fuzeofficlal

Copy link
Copy Markdown
Contributor

Reviewed and verified f0d53421 on Windows 11 (rustc 1.98.1 MSVC) against main (13f91ca).

  • Replacing own_image() with the synthetic section_image(virtual_size, raw_size) fixture makes the 4 GiB boundary test portable across hosts, and the 4 new tests thoroughly cover min(VirtualSize, SizeOfRawData), VirtualSize == 0, empty sections/gaps (both forward and reverse section orders), and u32::MAX wraparound avoidance.
  • cargo test -p victory-pe --locked: 40 passed, 0 failed; cargo clippy -p victory-pe --all-targets --locked -- -D warnings: 0 warnings; cargo xtask policy: 184 files ok.
  • Clean git merge-tree against 13f91ca and #2741 (complementary: #2740 covers section RVA boundaries, #2741 rejects null IAT RVAs in non-empty import descriptors).

@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown

Independent WARP/CPU verification of f0d53421 (#2740).

Review: Test-only change in victory-pe/src/image.rs (no production change). The new section_image helper builds a synthetic section, and the tests cover the shorter-of-virtual/raw-size rule, VirtualSize == 0, empty sections and gaps, section-table order, and RVAs near u32::MAX. It no longer relies on own_image(). I found no problems.

Results (WARP/CPU):

  • origin/main: cargo test -p victory-pe --lib: 36 passed.
  • PR: 40 passed, 0 failed.
  • cargo clippy --locked -p victory-pe --all-targets [--all-features] -- -D warnings: clean. cargo test -p xtask (policy): 6 passed.

Negative control (mutating rva_to_file_offset on the PR head):

  • vs.min(file_size) changed to vs: section_rvas_stop_at_the_shorter_of_virtual_and_raw_data and section_rvas_skip_empty_sections_and_gaps fail.
  • checked_add changed to wrapping_add: rva_to_file_offset_rejects_offsets_past_4_gib fails.
  • 0 => file_size changed to 0 => 0: section_rvas_use_raw_size_when_virtual_size_is_zero fails.

Each mutation is caught, so the tests do guard the behaviour.

Method: no physical GPU. VICTORY_WARP=1, VICTORY_D3D12_WARP=1, Windows SDK 10.0.26100 dxil.dll on PATH, Windows 11, rustc 1.98.1 MSVC, --locked. Compared origin/main (13f91ca) with the PR head. The PR merges cleanly onto that main. No game files, dumps, shader names or retail hashes were used or are needed.

AI disclosure: this verification was done by Claude Code / Claude Sonnet 5.5.

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Test-only change in crates/victory-pe/src/image.rs: rva_to_file_offset_rejects_offsets_past_4_gib now uses a source-built fixture (section_image) instead of the test executable and checks the exact last representable offset and the first overflowing one, and four new tests pin ImageInfo::rva_to_file_offset on the shorter of VirtualSize/SizeOfRawData, VirtualSize 0, empty sections and gaps in both section orders, and RVAs near u32::MAX. I worked the expected values through the current rva_to_file_offset (the backed extent and checked_add) and they match; no production code changes, and it does not overlap the delay-import tests in #2731. CI (check) passes.

This is a recommendation for a maintainer to look, not an approval.


Generated by Claude Code

@fuzeofficlal fuzeofficlal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed and verified at head f0d53421 and merged onto origin/main (63bcca43) on Windows 11 (debug & --release):

  • Design & correctness: test-only change in crates/victory-pe/src/image.rs:477-490, 547-626 with zero production edits. Replacing own_image() with the source-built section_image(virtual_size, raw_size) helper makes rva_to_file_offset_rejects_offsets_past_4_gib portable across non-Windows hosts while pinning the exact u32::MAX boundary (0x1010 -> Some(u32::MAX), 0x1011 -> None). The four new tests thoroughly cover min(VirtualSize, SizeOfRawData), VirtualSize == 0 fallback to SizeOfRawData, empty sections and inter-section gaps in both forward and reversed section-table order, and wraparound near u32::MAX.
  • Verification:
    • Clean git merge-tree against origin/main (63bcca43); cargo xtask policy (184 files ok); cargo clippy -p victory-pe --all-targets --locked -- -D warnings clean with default features and --all-features.
    • cargo test -p victory-pe --locked: 40/40 passed in debug, --release, and merged onto origin/main (63bcca43).

LGTM.

@futurepro62

Copy link
Copy Markdown

NVIDIA full-suite run, to go with the reports above by fuzeofficlal, oni-swr, since none of them names a GPU run. Tested exact head f0d5342 (on its base 13f91ca).

Tested

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants