PE loader: export ordinal base + index overflows (panic in debug, wraps in release) #691
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#691
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@lordon1a on GitHub · 2026-11-24 03:32 UTC · original
OwnedExports::from_pe(crates/xcl/src/pe.rs) adds the export directory'sBase, read from the file, to each function index with plainu32addition:With a
Basenearu32::MAXthis panics with an overflow in debug builds. The loader calls it for every mapped game DLL (loader.rs:133,OwnedExports::from_pe(&pe).unwrap_or_default()), sounwrap_or_defaultdoes not help. In release builds the sum wraps to low ordinals, and the entry can shadow a real ordinal 0, 1, … The rest ofpe.rsalready uses checked arithmetic for values from the file (#106). This one was missed.Only a malformed or unusual export table hits this. Valid images keep
Base + NumberOfFunctionsinside 16 bits.Failing test (in
pe.rs'smod tests, uses the existingdirectory_at_rvahelper):On
main(91f9a5e):cargo test -p xcl --lib pe::tests::exportfails withattempt to add with overflowatcrates\xcl\src\pe.rs:610:43.Proposed fix: skip entries past
u32::MAXand keep the others:With the fix:
cargo test -p xcl --lib -- --test-threads=4gave 653 passed, 0 failed, 21 ignored (652 onmainwithout the new test).Tested
x86_64-pc-windows-gnullvm, debug. This is not the MSVC toolchain the project uses.--libtests were run.Not tested
cargo test --workspace(integration, e2e and GPU tests), the MSVC toolchainscripts/smoke.ps1: I have no title to run it on. The fix is a runtime change, so a PR needs someone with a title for the twoxcl-smokeblocks. Branch with the test and the fix (one commit on91f9a5e): https://github.com/lordon1a/xcl/tree/pe-export-ordinal-overflowAI use
github-bot referenced this issue2026-11-26 04:29:54 +00:00
@Anon64 on GitHub · 2026-11-24 03:46 UTC · original
Test report for the branch
lordon1a/xclpe-export-ordinal-overflowat88311e4, which is based onmain91f9a5e: the MSVC toolchain, the whole workspace, and the two regression runs. If you open the PR from this commit, you can paste both blocks into Regression run.Tested
x86_64-pc-windows-msvccargo test --workspace --no-fail-fast -- --test-threads=4(debug) on88311e4: 692 passed, 1 failed, 41 ignored.pe::tests::export_ordinals_past_u32_max_are_skippedpasses. The one failure ishle::kernelx::tests::xmem_virtual_query_marks_cpu_readable_memory, which fails the same way onmainon this machine (#650 / #656).checked_addchange the new test panics:attempt to add with overflowatcrates\xcl\src\pe.rs:611:43SKIPPED:gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64)Regression run (
scripts/smoke.ps1, release, same title, 60 s each; pasted unedited)main:
88311e4:Not tested
Report written with Claude Code (Claude Opus 5.5) from runs on this machine.
@towiice on GitHub · 2026-11-24 03:48 UTC · original
PR with the fix and the test from this issue, rebased on current main: #700 (draft until someone with a title adds the
xcl-smokeblocks — I have none). Claude Code (Claude Sonnet 5.5).