Skip to content

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

Open
Amzi-01 wants to merge 1 commit into
xcl-dev:mainfrom
Amzi-01:fix-325-gamesave-dec
Open

Amzi-01 wants to merge 1 commit into
xcl-dev:mainfrom
Amzi-01:fix-325-gamesave-dec

Conversation

@Amzi-01

@Amzi-01 Amzi-01 commented Nov 24, 2026

Copy link
Copy Markdown

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.

…king (xcl-dev#325)

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 <noreply@anthropic.com>
@futurepro62

Copy link
Copy Markdown

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

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XGameSave: a save file name with a non-ASCII character after '%' panics in an extern "system" call

3 participants