Scripts: check NumberOfRvaAndSizes before reading PE exports #1484
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1494"
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 ivall/xcl. Originally posted by microwave805 on 2026-11-24T16:54:22Z.
scripts/re/pe_exports.pyunpacked the export data directory unconditionally at offset+96/+112of the optional header without checkingSizeOfOptionalHeaderorNumberOfRvaAndSizes. On a PE with zero data directories, it read the first section header name (such as.text) as the export table RVA and crashed withValueErrorinstead of printing(no exports).What is in it
scripts/re/pe_exports.py: readSizeOfOptionalHeaderandNumberOfRvaAndSizesand treat the export directory as(0, 0)whenNumberOfRvaAndSizes == 0or the optional header does not contain the first data directory entry.scripts/test_pe_exports.py: add synthetic PE32 and PE32+ fixtures withNumberOfRvaAndSizes = 0immediately followed by a.textsection header and verify(no exports)is printed.Tested
stable-x86_64-pc-windows-msvc, debug), Python 3.11.3python -I -m unittest discover -s scripts -p "test_pe_exports.py" -v: 1 passed, 2 subtest errors (both PE32 and PE32+ exited with status 1)130b1a8:python -I -m unittest discover -s scripts -p "test_*.py" -v: 17 passed, 0 failed.\scripts\test.ps1(cargo build --workspace && cargo test --workspace -- --test-threads=4): 770 passed, 0 failed, 41 ignoredgpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64)Regression run
scripts/re/pe_exports.pyandscripts/test_pe_exports.py(no runtime or build-input files).Not tested
AI use
NumberOfRvaAndSizescheck inscripts/re/pe_exports.py, wrote the fix, unit test, and PR description, and ran the verification commands above.Imported from ivall/xcl. Originally posted by gut0to on 2026-11-24T18:53:05Z.
Review: COMMENTED
The Python tests cover the new parser checks, but the workspace test command in this description was run on the base, not this PR head. CONTRIBUTING.md requires the full workspace suite on the PR head (on Windows, with GPU and skipped-test details). Please add that result before merge. AI-assisted review; I checked the commit and Tested section.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T18:53:33Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
Imported from ivall/xcl. Originally posted by microwave805 on 2026-11-24T19:01:56Z.
@gut0to Thanks for checking — I ran
.\scripts\test.ps1directly on PR head130b1a8(RTX 3070, Windows 11): 770 passed, 0 failed, 41 ignored (2SKIPPED:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware—no wave64), and updated Tested in the description.(Comment drafted with Antigravity (Gemini 4 Neon).)
Imported from ivall/xcl. Originally posted by RavenCurseBurg on 2026-11-26T03:27:31Z.
Tested
130b1a813d020731105a6deabfd20ac8fbececbdon Windows with valid PE32 and PE32+ files whose optional headers ended immediately after the zero directory count, and with zero-directory files retaining the padding. I interleaved export-free files with files that had exports, then added the installed 32-bit and 64-bit Windowsversion.dll. Runningpython -B scripts/re/pe_exports.py <files...>on this PR printed all eight expected listings in argument order and exited 0. Its two targeted unittest methods also passed.I then repeated the batch with two extra files whose exports reside in headers. The previous #1685/#1814 integration produced eight listings and returned 1 for the two compact files. This change ported to that reader produced all ten listings and exited 0. I checked the no-exports lines, ordinal 7 and RVA
0x1180for the synthetic named export, andGetFileVersionInfoWandVerQueryValueWin both system DLLs.On the integrated candidate,
python -B -m unittest discover -s scripts -p "test_*.py"passed all 25 tests, with no failures or skips. Windows build 26100, i7-13700, Python 3.14.3. OpenAI Codex (GPT-6) ported the change and ran these read-only tests. The DLLs were read from disk. The runtime, GPU and games were outside this run.Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-30T08:42:14Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:55:43Z.
Triage (#1607) – head
130b1a8#1685 (export directory inside the headers), #1814 (CLI/bounds hardening) and #2662 (file-backed RVA mapping) change scripts/re/pe_exports.py too; the shared lines are test-fixture boilerplate. None of them reads NumberOfRvaAndSizes, so with zero data directories they still take the section table as the export directory.
No problems found in the diff; the new test fails on main for both PE32 and PE32+.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.