Shaders: scan short archive records at the end of the input #1098

Open
anakatt wants to merge 1 commit from upstream-pr/1107 into main
anakatt commented 2026-11-24 11:40:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by anakatt on 2026-11-24T11:40:42Z.


I fixed pack::scan dropping valid short records at the end of its input. The loop required more than 32 bytes remaining, but the accepted record format needs only 23 bytes at minimum. A synthetic 28-byte record was ignored without trailing padding.

What is in it

  • Use the actual minimum candidate size; keep the existing name, header, payload and overflow checks.
  • Add a regression for 28- and 32-byte final records, both at offset zero and after a prefix, including inflation of their payloads.
  • Document unpadded final-record support in the RPF tool guidance.

Tested

  • macOS Darwin 24.6.0, arm64; rustc 1.99.1, miniz_oxide 0.9.1; debug. No GPU used.

  • A temporary Cargo harness linked the actual repository crates/xcl/src/gpu/pack.rs as its library, without compiling the Windows runtime or mocking the scanner.

  • Before the fix, cargo test --offline --manifest-path /tmp/xcl-pack-probe.ANtIu4/Cargo.toml --test short_records failed: the 28-byte record returned no records.

  • After the fix, cargo test --offline --manifest-path /tmp/xcl-pack-probe.ANtIu4/Cargo.toml --test short_records --test bounds: 2 passed, 0 failed, 0 ignored, 0 skipped. The harness checked four short-record/prefix combinations plus short buffers and out-of-range offsets, and was removed afterward.

  • Windows 11 Pro ARM64 10.0.26100.1742 in UTM (4 GiB VM RAM, Red Hat VirtIO GPU DOD), running x64 binaries through Windows emulation; rustc 1.100.0 x86_64-pc-windows-msvc, Windows SDK 26100. Debug build with CARGO_PROFILE_DEV_DEBUG=0, CARGO_PROFILE_TEST_DEBUG=0, CARGO_BUILD_JOBS=1; no GPU tests selected.

  • Exact source archive 5ab17d4fc701aecb1b3b017229b08a908114a5ee, after cargo clean -p xcl: cargo test --locked -p xcl --lib gpu::pack -- --test-threads=4: 5 passed, 0 failed, 0 ignored, 715 filtered out; no SKIPPED lines. The new short_records_do_not_need_trailing_padding test ran and passed. An earlier shared-cache run reused the prior test executable and is not counted as verification of this revision.

Regression run

  • Not run. Required main/head Windows title smoke blocks remain outstanding; this PR is a draft.

Not tested

  • Full Windows/GPU suite, native x64 hardware, CLI extraction path and real game archives. The focused Windows run is not a full workspace or title run.

AI use

  • I used omp (openai-codex/gpt-6-astra) to find and reproduce the boundary bug, write the fix and regression, run the isolated native harness and focused Windows tests, and prepare this description.
<!-- greyfinch-sync:ivall/xcl:issue:5471432680 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1107). Originally posted by [anakatt](https://github.com/anakatt) on 2026-11-24T11:40:42Z. --- I fixed `pack::scan` dropping valid short records at the end of its input. The loop required more than 32 bytes remaining, but the accepted record format needs only 23 bytes at minimum. A synthetic 28-byte record was ignored without trailing padding. **What is in it** - Use the actual minimum candidate size; keep the existing name, header, payload and overflow checks. - Add a regression for 28- and 32-byte final records, both at offset zero and after a prefix, including inflation of their payloads. - Document unpadded final-record support in the RPF tool guidance. **Tested** - macOS Darwin 24.6.0, arm64; rustc 1.99.1, miniz_oxide 0.9.1; debug. No GPU used. - A temporary Cargo harness linked the actual repository `crates/xcl/src/gpu/pack.rs` as its library, without compiling the Windows runtime or mocking the scanner. - Before the fix, `cargo test --offline --manifest-path /tmp/xcl-pack-probe.ANtIu4/Cargo.toml --test short_records` failed: the 28-byte record returned no records. - After the fix, `cargo test --offline --manifest-path /tmp/xcl-pack-probe.ANtIu4/Cargo.toml --test short_records --test bounds`: 2 passed, 0 failed, 0 ignored, 0 skipped. The harness checked four short-record/prefix combinations plus short buffers and out-of-range offsets, and was removed afterward. - Windows 11 Pro ARM64 10.0.26100.1742 in UTM (4 GiB VM RAM, Red Hat VirtIO GPU DOD), running x64 binaries through Windows emulation; rustc 1.100.0 `x86_64-pc-windows-msvc`, Windows SDK 26100. Debug build with `CARGO_PROFILE_DEV_DEBUG=0`, `CARGO_PROFILE_TEST_DEBUG=0`, `CARGO_BUILD_JOBS=1`; no GPU tests selected. - Exact source archive `5ab17d4fc701aecb1b3b017229b08a908114a5ee`, after `cargo clean -p xcl`: `cargo test --locked -p xcl --lib gpu::pack -- --test-threads=4`: 5 passed, 0 failed, 0 ignored, 715 filtered out; no SKIPPED lines. The new `short_records_do_not_need_trailing_padding` test ran and passed. An earlier shared-cache run reused the prior test executable and is not counted as verification of this revision. **Regression run** - Not run. Required main/head Windows title smoke blocks remain outstanding; this PR is a draft. **Not tested** - Full Windows/GPU suite, native x64 hardware, CLI extraction path and real game archives. The focused Windows run is not a full workspace or title run. **AI use** - I used omp (`openai-codex/gpt-6-astra`) to find and reproduce the boundary bug, write the fix and regression, run the isolated native harness and focused Windows tests, and prepare this description.
futurepro62 commented 2026-11-24 15:05:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T14:25:19Z.


Full-suite run, since this PR has no test report yet. Tested exact head 5ab17d4 (on its base 47efa2e).

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: 742 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: short_records_do_not_need_trailing_padding.

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:7134346847 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1107#issuecomment-7134346847). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T14:25:19Z. --- Full-suite run, since this PR has no test report yet. Tested exact head `5ab17d4` (on its base `47efa2e`). **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`: **742 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: `short_records_do_not_need_trailing_padding`. **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.
Toons29 commented 2026-11-25 04:10:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T03:11:52Z.


Regression run of 5ab17d4f on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 5ab17d4fc701aecb1b3b017229b08a908114a5ee
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1628 (PresentX 1628)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14817 MB

Against the limits in CONTRIBUTING.md: 101 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7151684372 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1107#issuecomment-7151684372). Originally posted by [Toons29](https://github.com/Toons29) on 2026-11-25T03:11:52Z. --- Regression run of `5ab17d4f` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `4178e888`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` ``` xcl-smoke v1 commit: 5ab17d4fc701aecb1b3b017229b08a908114a5ee gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1628 (PresentX 1628) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14817 MB ``` Against the limits in CONTRIBUTING.md: 101 % of `main`'s frames, 100 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; I checked the blocks before posting.
DavidM1911 commented 2026-11-25 09:08:13 +00:00 (Migrated from github.com)

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


Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

<!-- greyfinch-sync:ivall/xcl:comment:7156934340 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1107#issuecomment-7156934340). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T08:21:54Z. --- Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
github-actions[bot] commented 2026-11-29 07:40:36 +00:00 (Migrated from github.com)

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


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:7252620688 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1107#issuecomment-7252620688). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T07:40:36Z. --- 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 04:50:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:50:21Z.


Triage (#1607) – head 5ab17d4

No open or merged PR changes pack::scan's loop bound. The other PRs that touched pack.rs (#4, #8, #2906) are closed and kept the - 32 bound. The new bound is right: a candidate needs at least 1 + 3 + 18 + 1 = 23 bytes. Every read in the loop body is still guarded by header_end <= d.len() before d[p] and rd32(.., p + 14), so no index can go out of range. No problems found in the diff.
Minor: the README line sits between the command block and the launcher-menu bullet, and it would read better in the xcl rpf description.
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:7301153614 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1107#issuecomment-7301153614). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T04:50:21Z. --- **Triage (#1607)** – head 5ab17d4 No open or merged PR changes `pack::scan`'s loop bound. The other PRs that touched pack.rs (#4, #8, #2906) are closed and kept the `- 32` bound. The new bound is right: a candidate needs at least 1 + 3 + 18 + 1 = 23 bytes. Every read in the loop body is still guarded by `header_end <= d.len()` before `d[p]` and `rd32(.., p + 14)`, so no index can go out of range. No problems found in the diff. Minor: the README line sits between the command block and the launcher-menu bullet, and it would read better in the `xcl rpf` description. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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/1107:upstream-pr/1107'
git switch 'upstream-pr/1107'

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/1107'
git switch 'upstream-pr/1107'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1107'
git switch 'upstream-pr/1107'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1107'
git switch 'main'
git merge --squash 'upstream-pr/1107'
git switch 'main'
git merge --ff-only 'upstream-pr/1107'
git switch 'main'
git merge 'upstream-pr/1107'
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!1098
No description provided.