XGameSave: a save file name with a non-ASCII character after '%' panics in an extern "system" call #325
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#325
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@mastrr9 on GitHub · 2026-11-23 23:27 UTC · original
decincrates/xcl/src/hle/xgameruntime/gamesave.rs(line 100 onmain85bdf21) slices&file[i + 1..i + 3]by byte index:When a name in the save folder has
%followed by an ASCII byte and then a multi-byte UTF-8 character, the slice ends inside that character and panics (end byte index 3 is not a char boundary).decruns on every directory and file name in the save folder during enumeration and reads, fromextern "system"functions, where an unwinding panic aborts the process. XCL's ownencnever writes such a name, so this requires a file placed there externally (e.g. copied by hand, restored from backup, or left by another tool).Repro (clean-room, Linux):
Copied
decunchanged into a standalone test:dec("%a\u{e9}")panics.Suggested fix:
Decode directly from
b[i + 1]andb[i + 2], requiring both to be ASCII hex digits (u8::is_ascii_hexdigit), without slicing the&str. That also stopsfrom_str_radixfrom accepting a leading sign such as"%+1". Add unit tests covering"%a\u{e9}"and"%+1".Not tested: on Windows.
AI use: Initially found and reproduced with Claude Code; re-verified against
main(85bdf21) with Antigravity (Gemini 4 Neon).github-bot referenced this issue2026-11-26 04:22:08 +00:00
@Amzi-01 on GitHub · 2026-11-24 00:16 UTC · original
I'll take this. Plan:
decdecodes%XYfromb[i + 1]andb[i + 2]only when both are ASCII hex digits (no&strslicing, nofrom_str_radix), so%a\u{e9}stays literal instead of panicking and%+1is no longer decoded to 0x01. Unit tests for both cases plus a round-trip withenc, and @jleybourne's enumeration repro (%a\u{e9}folder throughXGameSaveEnumerateContainerInfo, no abort). Windows, RTX 3060 for the GPU suite. AI-assisted (Claude Code).@raulmesa96 on GitHub · 2026-11-24 00:37 UTC · original
Fix in #457:
decnow reads the two digits after%as bytes and requires both to be hex digits, so%aéno longer panics and%+1/%-1are no longer decoded. It comes with a unit test that panicked before the fix; the full suite passes on an RTX 3060 (677 passed, 0 failed ona6f5f7a).I have no Xbox title to run
scripts/smoke.ps1on, so the PR has no regression run yet. If anyone who can run one has a minute, the twoxcl-smokeblocks (main and the PR's head) would unblock it.(Claude Code, Claude Opus 5.5, helped write this.)
@Grimkaaah on GitHub · 2026-11-24 01:08 UTC · original
Opened https://github.com/ivall/xcl/pull/514 — decode %XX from bytes only (no str slice panic, no %+1).
@PurpleDizzy on GitHub · 2026-11-24 01:53 UTC · original
Comparison of the four open PRs for this issue (#442, #448, #457, #514)
All four make the same fix:
decreads the two characters after%as bytes and decodes them only if both are ASCII hex digits. That fixes both cases in the issue,%aé(the panic) and%+1(the sign). I read the four diffs againstmain(508a0c7) and found no difference in what the fixeddecreturns. The PRs differ in their tests, their readiness and the regression runs.PR descriptioncheckxcl-smokeblocks (main + head)decencround tripencround tripXGameSaveEnumerateContainerInfo(the abort path)ASYNC_TEST_LOCKNotes per PR
Providerdirectly in its own temp dir. That is safe withoutASYNC_TEST_LOCK, because enumeration runs synchronously and does not use XAsync. Its only blocker is that it is still a draft./// Names Windows does not keep as file names …and#[test] fn names_windows_would_change_round_trip. That doc comment now sits above the new test, and the existing test is left without one. Moving the two existing doc-comment lines back down fixes it.x%4€ycovers a multi-byte character in the second digit's position). It has no main-side smoke block, soPR descriptionfails. It also has no end-to-end test.hex_nibble's_ => 0arm is unreachable after theis_ascii_hexdigitcheck. It also adds a blank line before the final}of the test module.Suggestion: merge #442 once it is marked ready for review. It was first, has no defects I could find, has both regression blocks and tests the abort path. If @Amzi-01 moves the misplaced doc comment, #448 is an equally good alternative with broader tests. Either way, #457 and #514 can be closed as duplicates. #448's round-trip names (
sauvegarde été,保存1,100%) would be a nice addition to whichever PR is merged.Not tested: I compared the diffs by reading them. I did not build or run any of the four branches.
(Claude Code, Opus 5.5, helped write this.)
@lordon1a on GitHub · 2026-11-24 03:47 UTC · original
Comparison of the four open PRs for #325 (#442, #448, #457, #514), to help pick one.
All four make the same fix:
decreads the two hex digits from bytes instead of slicing the&str, and a sign is no longer taken as a digit. The decoded output is the same in all four for every input I tried. Each diff touches onlycrates/xcl/src/hle/xgameruntime/gamesave.rs. I read all four diffs before running them: no network, process,build.rsor file access outside the test temp folders.PR descriptioncheckmainf4ce27ce310370df34b7eaebea994a17a0acargo test -p xcl --lib -- --test-threads=4on each head: #442 632 passed, #448 638 passed, #457 637 passed, #514 638 passed. All had 0 failed and 21 ignored. The counts differ because the PRs start from differentmaincommits.Negative control: with
main'sdecput back, the new tests in #442 and #448 fail. The enumeration tests abort the test process at the panic acrossextern "system", which is #325 itself.Points:
names_windows_would_change_round_trip. That comment now sits ondec_keeps_bad_escapes_literal, and the old test has lost its doc. Its enumeration test also creates the provider throughXGameSaveInitializeProvider. It then removes only the container, so each run leaves%TEMP%\xcl_unit_data\gamesave\xcl-test-325-<pid>behind. Its round-trip loop (enc→decover device names, a trailing dot, CJK) covers the most of the four.Provideron its own temp root and deletes the whole root afterwards. It leaves nothing behind and does not depend on the provider's data folder.Suggestion: merge #442, which was opened first, passes the checks and leaves nothing behind. #448's round-trip cases could be added to #442's test. Close the other three as duplicates.
Tested on an i7-12700H with an RTX 3070 Ti Laptop, Windows 11 build 26200. Toolchain: rustc 1.100.0
x86_64-pc-windows-gnullvm, debug,--libtests only. Not tested: the MSVC toolchain,cargo test --workspace, smoke runs.Written with Claude Code (Claude Opus 5.5). I checked each point above against the diffs and the test runs.
@pickles976 on GitHub · 2026-11-24 04:23 UTC · original
Empirical adjudication of the four PRs on this issue, run 2026-11-24 (Linux,
x86_64-pc-windows-gnucross-build, tests under Wine 9). Canonical battery, added as unit tests tomainand each PR head:dec("%a\u{e9}")(char-boundary case),dec("%+1")(signed form),dec("%41A")("AA"),dec("x%4y%zz")(literals).%a\u{e9}%+1%41Ax%4y%zzmaingamesave.rs:100(confirms the report exactly)0x01(second defect confirmed)All four converge on the same fix shape (decode the two digits from
b[i+1]/b[i+2]with an ASCII-hexdigit check, no&strslicing, nofrom_str_radix) and are behaviourally equivalent under the battery; diffs are 33–54 added lines ingamesave.rsonly.Recommendation for the batch merge: #448 — behaviourally equal, cleanest shape (named
hex_digithelper rather than a closure or inline cast), smallest deletion count (2 lines), and its description check is green like #442's; #457/#514 are one description-fix away but duplicative regardless. Suggest: merge #448 (or #442 if the maintainer prefers its inline style), close the other three as duplicates — all four authors independently verified the same two defects.Repro of the harness: cross-build per #520 (llvm-mingw linker, static
libunwind.afirst in the search path),cargo test -p xcl --lib --target x86_64-pc-windows-gnu zz_325_reviewwithCARGO_TARGET_…_RUNNER=wine.