Tests: some_ranges in texture_upload wraps its generator instead of overflowing #2771

Open
github-bot wants to merge 1 commit from github-bot/gh-2771 into nvidia-dev AGit
Owner

@⁠inf1425 on GitHub · 2026-11-26 11:38 UTC · original
inf1425:tests/texture-upload-lcg-overflow → nvidia-dev · +1 −1 · 1 files · 1 commits · draft

The some_ranges helper in texture_upload's tests advances a linear congruential generator with n = n * 1103515245 + 12345, and n grows without bound. By the third loop pass it exceeds u64, and debug builds (cargo test) panic with "attempt to multiply with overflow". Both GPU tests that use the helper fail on a GPU. CI has no GPU, so they return before reaching it. The step now wraps, as such a generator should. Royalflamejlh reported this in #42 (comment) and proposed exactly this line. This PR applies it.

What is in it

  • crates/xcl/src/hle/d3d12x/texture_upload.rs (in mod tests): n = n.wrapping_mul(1103515245).wrapping_add(12345). Test code only. The helper came in with 73fc616f.

Tested

  • NVIDIA GeForce RTX 4060 Laptop GPU (8 GB, driver 616.64), Ryzen 7 7840HS, Windows 11 build 26300, Rust 1.95.0, debug build.
  • cargo test -p xcl --lib texture_upload: 8 passed, 0 failed, in 3 runs. Without this PR, pieces_hold_the_texels_of_their_levels and gpu_parts_of_a_texture_go_up_and_the_rest_stays fail.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 at this PR's head: 1746 passed, 4 failed, 48 ignored. The failures are not touched here: the 2 late-release tests (#2770), d3d12_mesh_stream::console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly (#2632), and the flaky hle::kernelx::tests::memory_under_a_shown_page_is_told_to_sparse_before_it_goes, a race that #2772 fixes. That last test passed in 3 further lib runs and 10 runs on its own.
  • SKIPPED GPU tests (26): 21 need wave64; 3 are f16 ops the per-lane form refuses (#1426); 2 need XCL_HEAP_WINDOWS=1.

Regression run

  • The change is inside #[cfg(test)] mod tests and never reaches xcl.exe, but scripts/pr_check.py counts any file under crates/xcl/src/ as runtime. Smoke blocks from nvidia-dev and from this head will be added once a title is available, unless a maintainer prefers the test-only label.

main:

PR:

Not tested

  • AMD, other NVIDIA cards, Linux/Wine, a release build, any retail title (smoke run pending).

AI use

  • Claude Code (Claude Opus 5.5) found the overflow, wrote the change and ran the tests. I read every line of the diff.
**@⁠inf1425** on GitHub · 2026-11-26 11:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/2771) `inf1425:tests/texture-upload-lcg-overflow` → `nvidia-dev` · +1 −1 · 1 files · 1 commits · draft The `some_ranges` helper in `texture_upload`'s tests advances a linear congruential generator with `n = n * 1103515245 + 12345`, and `n` grows without bound. By the third loop pass it exceeds u64, and debug builds (`cargo test`) panic with "attempt to multiply with overflow". Both GPU tests that use the helper fail on a GPU. CI has no GPU, so they return before reaching it. The step now wraps, as such a generator should. Royalflamejlh reported this in #42 ([comment](https://git.gtahub.st/github/xcl-dev--xcl/issues/42)) and proposed exactly this line. This PR applies it. **What is in it** - `crates/xcl/src/hle/d3d12x/texture_upload.rs` (in `mod tests`): `n = n.wrapping_mul(1103515245).wrapping_add(12345)`. Test code only. The helper came in with 73fc616f. **Tested** - NVIDIA GeForce RTX 4060 Laptop GPU (8 GB, driver 616.64), Ryzen 7 7840HS, Windows 11 build 26300, Rust 1.95.0, debug build. - `cargo test -p xcl --lib texture_upload`: 8 passed, 0 failed, in 3 runs. Without this PR, `pieces_hold_the_texels_of_their_levels` and `gpu_parts_of_a_texture_go_up_and_the_rest_stays` fail. - `cargo test --workspace --no-fail-fast -- --test-threads=4` at this PR's head: 1746 passed, 4 failed, 48 ignored. The failures are not touched here: the 2 late-release tests (#2770), `d3d12_mesh_stream::console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly` (#2632), and the flaky `hle::kernelx::tests::memory_under_a_shown_page_is_told_to_sparse_before_it_goes`, a race that #2772 fixes. That last test passed in 3 further lib runs and 10 runs on its own. - SKIPPED GPU tests (26): 21 need wave64; 3 are f16 ops the per-lane form refuses (#1426); 2 need `XCL_HEAP_WINDOWS=1`. **Regression run** - The change is inside `#[cfg(test)] mod tests` and never reaches `xcl.exe`, but `scripts/pr_check.py` counts any file under `crates/xcl/src/` as runtime. Smoke blocks from `nvidia-dev` and from this head will be added once a title is available, unless a maintainer prefers the `test-only` label. main: PR: **Not tested** - AMD, other NVIDIA cards, Linux/Wine, a release build, any retail title (smoke run pending). **AI use** - Claude Code (Claude Opus 5.5) found the overflow, wrote the change and ran the tests. I read every line of the diff.
The helper's linear congruential step `n = n * 1103515245 + 12345`
grows without bound: from the third loop pass it is past u64, and debug
builds (cargo test) panic with "attempt to multiply with overflow".
Both GPU tests that use it failed on a GPU (CI has none, so they return
before reaching it):

- texture_upload::tests::pieces_hold_the_texels_of_their_levels
- texture_upload::tests::gpu_parts_of_a_texture_go_up_and_the_rest_stays

The step now wraps, as such a generator is meant to. Test code only; on
an RTX 4060 Laptop GPU all 8 texture_upload tests pass (3 runs).

Assisted-by: Claude Code (Claude Opus 5.5)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:40:50 +00:00
This pull request can be merged automatically.
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/2771/head:github-bot/gh-2771'
git switch 'github-bot/gh-2771'

Merge

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