XGameSave: a bad escape in a save name stays literal instead of panicking (#325) #448

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

@⁠Amzi-01 on GitHub · 2026-11-24 00:25 UTC · original
Amzi-01:fix-325-gamesave-dec → main · +46 −2 · 1 files · 1 commits · open

dec in hle/xgameruntime/gamesave.rs sliced the &str by byte index. A save name with %, one ASCII byte and then a multi-byte character, such as a folder copied in by hand or restored from a backup, panicked. Because dec runs from the extern "system" enumeration calls, that aborted the whole title with 0xC0000409 (confirmed on Windows by @⁠jleybourne in the issue). It now decodes %XY from the bytes, and only when both are ASCII hex digits. That also stops %+1 decoding to 0x01, because from_str_radix accepted a sign.

Fixes #325

What is in it

  • dec: a hex_digit helper (char::to_digit(16), ASCII only, no sign) instead of u8::from_str_radix on a slice. Names enc writes decode as before.
  • dec_keeps_bad_escapes_literal: %a\u{e9}, %\u{e9}a, %+1, %-1x and a truncated a%4 stay literal, %41%42c and %c3%A9 still decode, and dec(enc(name)) == name holds for multi-byte, % and Windows-special names.
  • enumerating_a_container_with_a_bad_escape_does_not_abort: the issue's repro. A %a\u{e9} container folder is made by hand, then XGameSaveEnumerateContainerInfo lists it.
  • On main's dec, the first test panics at the slice and the second aborts with "thread caused non-unwinding panic"; with this PR both pass.

Tested

  • hardware: NVIDIA GeForce RTX 3060 (driver 610.88), AMD Ryzen 9 5900X, Windows 11; Rust 1.100.0 (x86_64-pc-windows-msvc); tests in debug, smoke runs in release
  • cargo build --workspace then cargo test --workspace --no-fail-fast -- --test-threads=4: 678 passed, 0 failed, 41 ignored (SKIPPED GPU tests: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware, both "no wave64")
  • cargo test -p xcl --lib gamesave: 12 passed

Regression run

main:

xcl-smoke v1
commit: a6f5f7a74cc620c1f88a9e3669a633d10c3c8212
gpu: NVIDIA GeForce RTX 3060
title: RPFS
seconds: 60
exit: 0x0
frames shown: 409 (PresentX 410)
presents per 2 s (last 3): 19 18 17
device removals: 0
crashes: 0
peak commit: 15538 MB

PR:

xcl-smoke v1
commit: df34b7ea057fe570cc30eeb1bf3fb209014843b7
gpu: NVIDIA GeForce RTX 3060
title: RPFS
seconds: 60
exit: 0x0
frames shown: 406 (PresentX 406)
presents per 2 s (last 3): 16 16 18
device removals: 0
crashes: 0
peak commit: 15512 MB

Not tested

  • The title in the regression run never meets a save name of this shape, so the smoke run covers "no regression", not the fix itself; the unit tests cover the fix.
  • An AMD GPU (the two wave64 GPU tests are skipped on NVIDIA).

AI use

  • Claude Code (Claude Opus 5.5): wrote the change and the tests, ran the builds, the suite and the smoke runs on the hardware above; the results are pasted from those runs.
**@⁠Amzi-01** on GitHub · 2026-11-24 00:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/448) `Amzi-01:fix-325-gamesave-dec` → `main` · +46 −2 · 1 files · 1 commits · open `dec` in `hle/xgameruntime/gamesave.rs` sliced the `&str` by byte index. A save name with `%`, one ASCII byte and then a multi-byte character, such as a folder copied in by hand or restored from a backup, panicked. Because `dec` runs from the `extern "system"` enumeration calls, that aborted the whole title with 0xC0000409 (confirmed on Windows by @⁠jleybourne in the issue). It now decodes `%XY` from the bytes, and only when both are ASCII hex digits. That also stops `%+1` decoding to 0x01, because `from_str_radix` accepted a sign. Fixes #325 **What is in it** - `dec`: a `hex_digit` helper (`char::to_digit(16)`, ASCII only, no sign) instead of `u8::from_str_radix` on a slice. Names `enc` writes decode as before. - `dec_keeps_bad_escapes_literal`: `%a\u{e9}`, `%\u{e9}a`, `%+1`, `%-1x` and a truncated `a%4` stay literal, `%41%42c` and `%c3%A9` still decode, and `dec(enc(name)) == name` holds for multi-byte, `%` and Windows-special names. - `enumerating_a_container_with_a_bad_escape_does_not_abort`: the issue's repro. A `%a\u{e9}` container folder is made by hand, then `XGameSaveEnumerateContainerInfo` lists it. - On `main`'s `dec`, the first test panics at the slice and the second aborts with "thread caused non-unwinding panic"; with this PR both pass. **Tested** - hardware: NVIDIA GeForce RTX 3060 (driver 610.88), AMD Ryzen 9 5900X, Windows 11; Rust 1.100.0 (x86_64-pc-windows-msvc); tests in debug, smoke runs in release - `cargo build --workspace` then `cargo test --workspace --no-fail-fast -- --test-threads=4`: 678 passed, 0 failed, 41 ignored (SKIPPED GPU tests: `gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware`, both "no wave64") - `cargo test -p xcl --lib gamesave`: 12 passed **Regression run** main: ``` xcl-smoke v1 commit: a6f5f7a74cc620c1f88a9e3669a633d10c3c8212 gpu: NVIDIA GeForce RTX 3060 title: RPFS seconds: 60 exit: 0x0 frames shown: 409 (PresentX 410) presents per 2 s (last 3): 19 18 17 device removals: 0 crashes: 0 peak commit: 15538 MB ``` PR: ``` xcl-smoke v1 commit: df34b7ea057fe570cc30eeb1bf3fb209014843b7 gpu: NVIDIA GeForce RTX 3060 title: RPFS seconds: 60 exit: 0x0 frames shown: 406 (PresentX 406) presents per 2 s (last 3): 16 16 18 device removals: 0 crashes: 0 peak commit: 15512 MB ``` **Not tested** - The title in the regression run never meets a save name of this shape, so the smoke run covers "no regression", not the fix itself; the unit tests cover the fix. - An AMD GPU (the two wave64 GPU tests are skipped on NVIDIA). **AI use** - Claude Code (Claude Opus 5.5): wrote the change and the tests, ran the builds, the suite and the smoke runs on the hardware above; the results are pasted from those runs.
dec() sliced the &str by byte index, so a name with '%', one ASCII byte and
then a multi-byte character (a folder made outside XCL) panicked, and from the
extern "system" enumeration calls that aborts the title (0xC0000409). It now
decodes %XY from the bytes, only when both are ASCII hex digits, which also
stops '%+1' from decoding to 0x01.

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

@⁠futurepro62 on GitHub · 2026-11-24 03:04 UTC · original

Tested exact head df34b7e (on its base a6f5f7a).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves, 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: 678 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.

Not tested

  • A retail title or scripts/smoke.ps1 (no title on this machine), AMD, wave64 hardware, a release build.

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 03:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/448#issuecomment-7120739772) Tested exact head `df34b7e` (on its base `a6f5f7a`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves, 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`: **678 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. **Not tested** - A retail title or `scripts/smoke.ps1` (no title on this machine), AMD, wave64 hardware, a release build. **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠MesshM on GitHub · 2026-11-24 05:28 UTC · original

Test run of df34b7ea057fe570cc30eeb1bf3fb209014843b7 on AMD RDNA4. I merged it onto current main e50836b locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 706 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 665 passed, 0 failed, 21 ignored
  • 0 SKIPPED; dec_keeps_bad_escapes_literal and enumerating_a_container_with_a_bad_escape_does_not_abort pass.

Review: Duplicate of #514 (open), and #325 has had other PRs too; all decode %XX from bytes. This one also has the enumeration-level test (the issue's repro through XGameSaveEnumerateContainerInfo), which is the stronger of the two. Only one should land.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

**@⁠MesshM** on GitHub · 2026-11-24 05:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/448#issuecomment-7122986804) Test run of `df34b7ea057fe570cc30eeb1bf3fb209014843b7` on AMD RDNA4. I merged it onto current `main` `e50836b` locally (clean merge) and tested that tree. **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 `stable-x86_64-pc-windows-msvc`, debug - `cargo build --workspace` + `cargo test --workspace -- --test-threads=4` on the merge: **706 passed, 0 failed, 41 ignored**, exit code 0; `xcl` lib tests 665 passed, 0 failed, 21 ignored - **0 `SKIPPED`**; `dec_keeps_bad_escapes_literal` and `enumerating_a_container_with_a_bad_escape_does_not_abort` pass. **Review:** **Duplicate of #514** (open), and #325 has had other PRs too; all decode `%XX` from bytes. This one also has the enumeration-level test (the issue's repro through `XGameSaveEnumerateContainerInfo`), which is the stronger of the two. Only one should land. **Not tested:** no retail title or regression run (I have no unpacked game), no `XCL_SAMPLE_*` tests, release build; the PR's head on its old base was not run, only its merge onto `main`. Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 14:15 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 14:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/448#issuecomment-7165003067) 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/448/head:github-bot/gh-448'
git switch 'github-bot/gh-448'

Merge

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