PE loader: skip export ordinals past u32::MAX (#691) #700

Open
github-bot wants to merge 1 commit from github-bot/gh-700 into main AGit
Owner

@⁠towiice on GitHub · 2026-11-24 03:47 UTC · original
towiice:pe-export-ordinal-overflow → main · +22 −1 · 1 files · 1 commits · open

Fixes #691. OwnedExports::from_pe added the export directory's Base (read from the file) to each function index with plain u32 addition. A Base near u32::MAX panicked on overflow in debug builds and wrapped to low ordinals in release builds, where the entry could shadow a real ordinal. The entry past u32::MAX has no ordinal, so it is now skipped (checked_add, break, since every later index overflows too). This is the fix proposed in #691; the test is the one from the issue, which I reran.

What is in it

  • crates/xcl/src/pe.rs: checked_add for the ordinal in OwnedExports::from_pe, plus the unit test export_ordinals_past_u32_max_are_skipped.

Tested

  • NVIDIA GeForce GTX 1650 SUPER, Windows 11 build 26300, Rust 1.98.1 x86_64-pc-windows-gnullvm (llvm-mingw 20261117), debug
  • the new test fails without the fix (attempt to add with overflow) and passes with it
  • cargo build --workspace then cargo test --workspace --no-fail-fast -- --test-threads=4: 702 passed, 0 failed, 41 ignored
  • SKIPPED: 80 GPU tests, all "no DXC" (this machine has no DXC)

Also tested by others

  • futurepro62 ran the whole suite on this head (RTX 5070 Ti): 686 passed, 0 failed, 41 ignored; the new test ran and passed.

Regression run
Not made by me (I have no title). Anon64 made both runs with scripts/smoke.ps1, same title and time, and posted them in a comment on this PR for this section; they are pasted unedited (RTX 3060, driver 581.80). The main run is on cb868b2, the base of this PR.

main:

xcl-smoke v1
commit: cb868b200517d7b11bbfcb0146bf0c787ce632b6
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1611 (PresentX 1611)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14564 MB

PR:

xcl-smoke v1
commit: 95aab05e915c17e3076b7fa329a3f1e4c9cf1721
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1598 (PresentX 1598)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14581 MB

Not tested

  • the MSVC toolchain (gnullvm only), AMD GPUs, any GPU test (no DXC here)

AI use

  • Claude Code (Claude Sonnet 5.5) applied the fix from #691, ran the tests and wrote this description. I did not write the original fix or test; they are from the issue.
**@⁠towiice** on GitHub · 2026-11-24 03:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/700) `towiice:pe-export-ordinal-overflow` → `main` · +22 −1 · 1 files · 1 commits · open Fixes #691. `OwnedExports::from_pe` added the export directory's `Base` (read from the file) to each function index with plain `u32` addition. A `Base` near `u32::MAX` panicked on overflow in debug builds and wrapped to low ordinals in release builds, where the entry could shadow a real ordinal. The entry past `u32::MAX` has no ordinal, so it is now skipped (`checked_add`, `break`, since every later index overflows too). This is the fix proposed in #691; the test is the one from the issue, which I reran. **What is in it** - `crates/xcl/src/pe.rs`: `checked_add` for the ordinal in `OwnedExports::from_pe`, plus the unit test `export_ordinals_past_u32_max_are_skipped`. **Tested** - NVIDIA GeForce GTX 1650 SUPER, Windows 11 build 26300, Rust 1.98.1 `x86_64-pc-windows-gnullvm` (llvm-mingw 20261117), debug - the new test fails without the fix (`attempt to add with overflow`) and passes with it - `cargo build --workspace` then `cargo test --workspace --no-fail-fast -- --test-threads=4`: 702 passed, 0 failed, 41 ignored - SKIPPED: 80 GPU tests, all "no DXC" (this machine has no DXC) **Also tested by others** - futurepro62 ran the whole suite on this head (RTX 5070 Ti): 686 passed, 0 failed, 41 ignored; the new test ran and passed. **Regression run** Not made by me (I have no title). Anon64 made both runs with `scripts/smoke.ps1`, same title and time, and posted them in a comment on this PR for this section; they are pasted unedited (RTX 3060, driver 581.80). The `main` run is on `cb868b2`, the base of this PR. main: ``` xcl-smoke v1 commit: cb868b200517d7b11bbfcb0146bf0c787ce632b6 gpu: NVIDIA GeForce RTX 3060 title: retail-title seconds: 60 exit: 0x0 frames shown: 1611 (PresentX 1611) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14564 MB ``` PR: ``` xcl-smoke v1 commit: 95aab05e915c17e3076b7fa329a3f1e4c9cf1721 gpu: NVIDIA GeForce RTX 3060 title: retail-title seconds: 60 exit: 0x0 frames shown: 1598 (PresentX 1598) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14581 MB ``` **Not tested** - the MSVC toolchain (gnullvm only), AMD GPUs, any GPU test (no DXC here) **AI use** - Claude Code (Claude Sonnet 5.5) applied the fix from #691, ran the tests and wrote this description. I did not write the original fix or test; they are from the issue.
The export directory's Base comes from the file. Adding it to the function index
with plain u32 addition panicked on overflow in debug builds and wrapped to low
ordinals in release ones, where the entry could shadow a real ordinal 0, 1, ...
Skip the entries that have no ordinal; the rest of pe.rs already uses checked
arithmetic for file values (#106).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:29:56 +00:00
Author
Owner

@⁠Anon64 on GitHub · 2026-11-24 07:01 UTC · original

Regression runs for this PR's head 95aab05 and for its base main cb868b2, on a retail title (same title, 60 s each), made with scripts/smoke.ps1 (release, clean tree at each commit) and pasted unedited, for Regression run.

main:

xcl-smoke v1
commit: cb868b200517d7b11bbfcb0146bf0c787ce632b6
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1611 (PresentX 1611)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14564 MB

this PR:

xcl-smoke v1
commit: 95aab05e915c17e3076b7fa329a3f1e4c9cf1721
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1598 (PresentX 1598)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14581 MB

Tested

  • NVIDIA GeForce RTX 3060 12 GB (driver 581.80, wave32), Intel Core i9-14900KF, Windows 11 25H2 26200.9974, Rust 1.90.0

Not tested

  • the unit tests on this machine
  • an image with such an export base; the title's DLLs load as before, so this is a regression check only

Report written with Claude Code (Claude Opus 5.5) from runs on this machine.

**@⁠Anon64** on GitHub · 2026-11-24 07:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/700#issuecomment-7124531517) Regression runs for this PR's head `95aab05` and for its base `main` `cb868b2`, on a retail title (same title, 60 s each), made with `scripts/smoke.ps1` (release, clean tree at each commit) and pasted unedited, for **Regression run**. main: ``` xcl-smoke v1 commit: cb868b200517d7b11bbfcb0146bf0c787ce632b6 gpu: NVIDIA GeForce RTX 3060 title: retail-title seconds: 60 exit: 0x0 frames shown: 1611 (PresentX 1611) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14564 MB ``` this PR: ``` xcl-smoke v1 commit: 95aab05e915c17e3076b7fa329a3f1e4c9cf1721 gpu: NVIDIA GeForce RTX 3060 title: retail-title seconds: 60 exit: 0x0 frames shown: 1598 (PresentX 1598) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14581 MB ``` **Tested** - NVIDIA GeForce RTX 3060 12 GB (driver 581.80, wave32), Intel Core i9-14900KF, Windows 11 25H2 26200.9974, Rust 1.90.0 **Not tested** - the unit tests on this machine - an image with such an export base; the title's DLLs load as before, so this is a regression check only Report written with Claude Code (Claude Opus 5.5) from runs on this machine.
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 07:06 UTC · original

Full-suite run to go with the smoke runs above, so the new test has a result on hardware. Tested exact head 95aab05 (on its base cb868b2).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 686 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: export_ordinals_past_u32_max_are_skipped.

Not tested

  • AMD, a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-24 07:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/700#issuecomment-7124614670) Full-suite run to go with the smoke runs above, so the new test has a result on hardware. Tested exact head `95aab05` (on its base `cb868b2`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4`: **686 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `export_ordinals_past_u32_max_are_skipped`. **Not tested** - AMD, a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 11:54 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 11:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/700#issuecomment-7161663009) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/700/head:github-bot/gh-700'
git switch 'github-bot/gh-700'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-700'
git switch 'github-bot/gh-700'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-700'
git switch 'github-bot/gh-700'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-700'
git switch 'main'
git merge --squash 'github-bot/gh-700'
git switch 'main'
git merge --ff-only 'github-bot/gh-700'
git switch 'main'
git merge 'github-bot/gh-700'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.