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

Open
towiice wants to merge 1 commit from upstream-pr/700 into main
towiice commented 2026-11-24 03:47:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by towiice on 2026-11-24T03:47:47Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:5465704043 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/700). Originally posted by [towiice](https://github.com/towiice) on 2026-11-24T03:47:47Z. --- 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.
Anon64 commented 2026-11-24 07:06:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Anon64 on 2026-11-24T07:01:24Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7124531517 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/700#issuecomment-7124531517). Originally posted by [Anon64](https://github.com/Anon64) on 2026-11-24T07:01:24Z. --- 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.
futurepro62 commented 2026-11-24 07:06:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T07:06:00Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7124614670 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/700#issuecomment-7124614670). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T07:06:00Z. --- 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.
DavidM1911 commented 2026-11-25 12:06:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T11:54:27Z.


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!

<!-- greyfinch-sync:ivall/xcl:comment:7161663009 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/700#issuecomment-7161663009). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T11:54:27Z. --- 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!
github-actions[bot] commented 2026-11-29 07:42:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T07:42:03Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7252635732 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/700#issuecomment-7252635732). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T07:42:03Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 03:58:16 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:58:16Z.


Triage (#1607) – head 95aab05

#1534 made the same checked add on the ordinal and was closed as a duplicate of this PR. Main still computes ex.ordinal_base + i as u32 in OwnedExports::from_pe.
No problems found in the diff; the test overflows the add (base u32::MAX, two functions), so it fails without the fix in a debug build.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7300246015 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/700#issuecomment-7300246015). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T03:58:16Z. --- **Triage (#1607)** – head 95aab05 #1534 made the same checked add on the ordinal and was closed as a duplicate of this PR. Main still computes `ex.ordinal_base + i as u32` in `OwnedExports::from_pe`. No problems found in the diff; the test overflows the add (base u32::MAX, two functions), so it fails without the fix in a debug build. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
BBareth commented 2026-12-01 09:38:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by BBareth on 2026-12-01T09:38:50Z.


merge-check claim
head: 95aab05e91

<!-- greyfinch-sync:ivall/xcl:comment:7307001371 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/700#issuecomment-7307001371). Originally posted by [BBareth](https://github.com/BBareth) on 2026-12-01T09:38:50Z. --- merge-check claim head: 95aab05e915c17e3076b7fa329a3f1e4c9cf1721
brainhay5 commented 2026-12-01 09:44:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T09:44:46Z.


merge-check claim
head: 95aab05e91

<!-- greyfinch-sync:ivall/xcl:comment:7307143430 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/700#issuecomment-7307143430). Originally posted by [brainhay5](https://github.com/brainhay5) on 2026-12-01T09:44:46Z. --- merge-check claim head: 95aab05e915c17e3076b7fa329a3f1e4c9cf1721
brainhay5 commented 2026-12-01 09:46:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T09:46:50Z.


merge-check claim
head: 95aab05e91

<!-- greyfinch-sync:ivall/xcl:comment:7307195496 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/700#issuecomment-7307195496). Originally posted by [brainhay5](https://github.com/brainhay5) on 2026-12-01T09:46:50Z. --- merge-check claim head: 95aab05e915c17e3076b7fa329a3f1e4c9cf1721
brainhay5 commented 2026-12-01 09:59:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T09:59:11Z.


merge-check
base: 493dbd3dd0
head: 95aab05e91
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2900 passed, 1 failed, 51 ignored; 29 SKIPPED lines
failing: test_title_runs_and_game_folder_is_untouched
review: automated overnight check — diff inspected for safety only (no build/CI/toolchain/script changes, no process/network/runtime-loading code); no duplicate search performed; no line-by-line code review.
performance: not assessed beyond the suite.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 610.88 (32.0.16.1088); Ryzen 7 5800X3D, 64 GB; Windows 11 22631; OpenCode agent, DeepSeek V4.1 Flash 1017

<!-- greyfinch-sync:ivall/xcl:comment:7307497770 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/700#issuecomment-7307497770). Originally posted by [brainhay5](https://github.com/brainhay5) on 2026-12-01T09:59:11Z. --- merge-check base: 493dbd3dd0cd50b4c3e8d28f73ab9b504fcd8158 head: 95aab05e915c17e3076b7fa329a3f1e4c9cf1721 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2900 passed, 1 failed, 51 ignored; 29 SKIPPED lines failing: test_title_runs_and_game_folder_is_untouched review: automated overnight check — diff inspected for safety only (no build/CI/toolchain/script changes, no process/network/runtime-loading code); no duplicate search performed; no line-by-line code review. performance: not assessed beyond the suite. verdict: safe to merge hardware / tool and model: RTX 5070 Ti 16 GB, driver 610.88 (32.0.16.1088); Ryzen 7 5800X3D, 64 GB; Windows 11 22631; OpenCode agent, DeepSeek V4.1 Flash 1017
BBareth commented 2026-12-01 09:59:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by BBareth on 2026-12-01T09:59:57Z.


merge-check
base: 493dbd3dd0
head: 95aab05e91
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2901 passed, 0 failed, 51 ignored; 28 SKIPPED lines, as on the base; failing: none. The base alone, same machine, same commit: 2900 passed, 0 failed, 51 ignored, 28 SKIPPED lines (22 no wave64, 2 no heap windows, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 cannot disable the driver cache). The new test export_ordinals_past_u32_max_are_skipped ran and passed.
review: no blocking finding; one file (+22/-1), every line read. OwnedExports::from_pe computes each ordinal with checked_add and stops at the first one past u32::MAX (every later index overflows too), where a debug build panicked and a release build wrapped to ordinal 0. For a well-formed image nothing changes. The test builds an export directory with base u32::MAX and two functions and checks that only the first is kept. Not tested here: nothing further; this is parser hardening for malformed images.
performance: none: one checked addition per export.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.

<!-- greyfinch-sync:ivall/xcl:comment:7307515612 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/700#issuecomment-7307515612). Originally posted by [BBareth](https://github.com/BBareth) on 2026-12-01T09:59:57Z. --- merge-check base: 493dbd3dd0cd50b4c3e8d28f73ab9b504fcd8158 head: 95aab05e915c17e3076b7fa329a3f1e4c9cf1721 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2901 passed, 0 failed, 51 ignored; 28 SKIPPED lines, as on the base; failing: none. The base alone, same machine, same commit: 2900 passed, 0 failed, 51 ignored, 28 SKIPPED lines (22 no wave64, 2 no heap windows, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 cannot disable the driver cache). The new test `export_ordinals_past_u32_max_are_skipped` ran and passed. review: no blocking finding; one file (+22/-1), every line read. `OwnedExports::from_pe` computes each ordinal with `checked_add` and stops at the first one past `u32::MAX` (every later index overflows too), where a debug build panicked and a release build wrapped to ordinal 0. For a well-formed image nothing changes. The test builds an export directory with base `u32::MAX` and two functions and checks that only the first is kept. Not tested here: nothing further; this is parser hardening for malformed images. performance: none: one checked addition per export. verdict: safe to merge hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/700:upstream-pr/700'
git switch 'upstream-pr/700'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/700'
git switch 'upstream-pr/700'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/700'
git switch 'upstream-pr/700'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/700'
git switch 'main'
git merge --squash 'upstream-pr/700'
git switch 'main'
git merge --ff-only 'upstream-pr/700'
git switch 'main'
git merge 'upstream-pr/700'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!695
No description provided.