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

Open
Amzi-01 wants to merge 1 commit from upstream-pr/448 into main
Amzi-01 commented 2026-11-24 00:25:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Amzi-01 on 2026-11-24T00:25:58Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:5463698720 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/448). Originally posted by [Amzi-01](https://github.com/Amzi-01) on 2026-11-24T00:25:58Z. --- `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.
futurepro62 commented 2026-11-24 07:05:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T03:04:03Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7120739772 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/448#issuecomment-7120739772). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T03:04:03Z. --- 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.
MesshM commented 2026-11-24 07:06:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by MesshM on 2026-11-24T05:28:50Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7122986804 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/448#issuecomment-7122986804). Originally posted by [MesshM](https://github.com/MesshM) on 2026-11-24T05:28:50Z. --- 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.
DavidM1911 commented 2026-11-25 15:07:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T14:15:39Z.


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:7165003067 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/448#issuecomment-7165003067). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T14:15:39Z. --- 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 20:41:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:41:55Z.


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:7262286656 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/448#issuecomment-7262286656). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T20:41:55Z. --- 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:08:54 +00:00 (Migrated from github.com)

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


Triage (#1607) – head df34b7e

Main still decodes with u8::from_str_radix(&file[i + 1..i + 3], 16) in gamesave.rs::dec, which panics on a '%' followed by a multi-byte character (#325). #1430 makes the same dec change (byte-wise hex digits) but bundles it with quota and blob-URL changes; this PR is the earlier, focused fix with tests. #442, #457 and #514 (same fix) are closed.
Nit: the two new tests are inserted between the doc comment of names_windows_would_change_round_trip and its #[test], so that doc comment now sits on dec_keeps_bad_escapes_literal.
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:7299377600 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/448#issuecomment-7299377600). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T03:08:54Z. --- **Triage (#1607)** – head df34b7e Main still decodes with `u8::from_str_radix(&file[i + 1..i + 3], 16)` in `gamesave.rs::dec`, which panics on a '%' followed by a multi-byte character (#325). #1430 makes the same `dec` change (byte-wise hex digits) but bundles it with quota and blob-URL changes; this PR is the earlier, focused fix with tests. #442, #457 and #514 (same fix) are closed. Nit: the two new tests are inserted between the doc comment of `names_windows_would_change_round_trip` and its `#[test]`, so that doc comment now sits on `dec_keeps_bad_escapes_literal`. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
fromthemoonx commented 2026-12-02 20:07:34 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-02T20:07:34Z.


merge-check
base: 5ad98adbc3
head: df34b7ea05
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3007 passed, 0 failed, 52 ignored (3004 / 0 / 52 on 817eb1f, plus this PR's 2 tests and 1 that main gained since); SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps); failing: none
review: read the whole diff (1 file, +46 -2). No blocking findings. Main still has the bug.

  1. With main's decoder put back, both new tests fail: the first with "end byte index 3 is not a char boundary", the second with a non-unwinding panic that ends the process, as in #325.
  2. Existing saves keep their names. I ran main's decoder and this one on 1,000,000 random short names made of %, hex digits, signs and multi-byte characters:
result names
same answer 935,098
main panics, this PR answers 57,822
different answer, name holds %+ 7,080
different answer otherwise 0

Every name enc writes came back unchanged in both, 1,000,000 of 1,000,000. The %+ case is the intended change, and enc never writes it.
3) Not a regression, for a later change: a folder named %aé by hand is now listed, but a title that opens the listed name gets the folder %25a%C3%A9, a new empty container. Before, the title aborted.
4) Small: the new test sits between the doc comment of names_windows_would_change_round_trip and that test, so the first two comment lines now belong to the wrong one.
5) This head shows only the PR description check. Build and test (Windows, no GPU) has not run on it, so it needs a CI run before the merge. It builds and passes here.
6) The PR is close to being closed as stale. It still merges cleanly and still fixes #325.
performance: none; a few byte comparisons per save name
verdict: safe to merge
hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)

<!-- greyfinch-sync:ivall/xcl:comment:7357248609 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/448#issuecomment-7357248609). Originally posted by [fromthemoonx](https://github.com/fromthemoonx) on 2026-12-02T20:07:34Z. --- merge-check base: 5ad98adbc360225ac8a57ad9661e16fe8df9d8dd head: df34b7ea057fe570cc30eeb1bf3fb209014843b7 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3007 passed, 0 failed, 52 ignored (3004 / 0 / 52 on 817eb1f, plus this PR's 2 tests and 1 that main gained since); SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps); failing: none review: read the whole diff (1 file, +46 -2). No blocking findings. Main still has the bug. 1) With main's decoder put back, both new tests fail: the first with "end byte index 3 is not a char boundary", the second with a non-unwinding panic that ends the process, as in #325. 2) Existing saves keep their names. I ran main's decoder and this one on 1,000,000 random short names made of %, hex digits, signs and multi-byte characters: | result | names | |---|---| | same answer | 935,098 | | main panics, this PR answers | 57,822 | | different answer, name holds `%+` | 7,080 | | different answer otherwise | 0 | Every name `enc` writes came back unchanged in both, 1,000,000 of 1,000,000. The `%+` case is the intended change, and `enc` never writes it. 3) Not a regression, for a later change: a folder named `%aé` by hand is now listed, but a title that opens the listed name gets the folder `%25a%C3%A9`, a new empty container. Before, the title aborted. 4) Small: the new test sits between the doc comment of `names_windows_would_change_round_trip` and that test, so the first two comment lines now belong to the wrong one. 5) This head shows only the `PR description` check. `Build and test (Windows, no GPU)` has not run on it, so it needs a CI run before the merge. It builds and passes here. 6) The PR is close to being closed as stale. It still merges cleanly and still fixes #325. performance: none; a few byte comparisons per save name verdict: safe to merge hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)
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/448:upstream-pr/448'
git switch 'upstream-pr/448'

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