XGameSave: a container name too long for a folder gets a hashed one #488

Closed
pablogonz12 wants to merge 1 commit from upstream-pr/493 into main
pablogonz12 commented 2026-11-24 01:01:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by pablogonz12 on 2026-11-24T01:01:41Z.


A container's folder is enc(name). A valid name has up to 256 characters, and enc turns each escaped byte into three, so past 255 characters the folder cannot be created: XGameSaveCreateContainer returns S_OK and every XGameSaveSubmitUpdate to that container fails with E_FAIL. Fixes #326.

What is in it

  • crates/xcl/src/hle/xgameruntime/gamesave.rs:
    • container_folder(name): enc(name) when it fits in 255 characters (so every folder that works today keeps its name); otherwise the start of enc(name) (never cut inside a %XX), ~ and a 64-bit FNV-1a hash of the lowercase name. enc never writes ~, so the two kinds never meet; the hash is of the lowercase name because container names match ignoring case, as the enc(name) folders do on NTFS.
    • apply() writes the exact name to the folder's name file when the folder is a hashed one; each_container reads it back through container_name(dir).
    • XGameSaveCreateContainer, XGameSaveDeleteContainer(Async) use container_folder.
    • Test long_container_names_are_saved_listed_and_deleted: the two names from the issue (256 letters; "a/" × 85 + "x", 341 characters encoded) are written, read back, found by XGameSaveGetContainerInfo in upper case, listed by XGameSaveEnumerateContainerInfo with their exact names, and deleted; a 255-character name keeps its plain folder.

Tested

  • AMD Radeon RX 9070 XT (RADV GFX1201, Mesa), AMD Ryzen 9 9900X, CachyOS (Linux 7.3), Wine 11.0 (Proton CachyOS) with vkd3d-proton v3.1 + the patch from #257, Rust stable, release.
  • cargo test -p xcl --lib --release --target x86_64-pc-windows-gnu (llvm-mingw 20261117), test binary run under Wine with --test-threads=4:
    • this PR (820ff6a): 632 passed, 5 failed, 21 ignored;
    • main (a6f5f7a): 631 passed, 5 failed, 21 ignored – the same five fail on both (gpu_f64_roots, gpu_f64_math_random, gpu_nonfused_mad_and_mac_prevent_fma_contraction, xma2_source_voice_decodes_and_manages_lifetime, and pe::tests::parses_own_test_binary_tls, which #464 fixes for this toolchain).
  • cargo test ... gamesave: 11 passed. The new test on main's gamesave.rs (without its two container_folder asserts): FAILED at the first XGameSaveSubmitUpdate, as the issue describes.

Regression run
Made with scripts/linux/smoke.sh from #257 under Wine (not smoke.ps1), MSVC builds (cargo xwin) of both commits. The main block was made with a local copy of the script with two lines changed so that a run which does not reach its end still prints its block (set -eu instead of set -euo pipefail; the data: fallback as an if).

xcl-smoke v1
commit: a6f5f7a74cc620c1f88a9e3669a633d10c3c8212
gpu: AMD Radeon RX 9070 XT (RADV GFX1201)
title: Build
seconds: 60
exit: 0x0
frames shown: 9 (PresentX 9)
presents per 2 s (last 3): 1 0 1
device removals: 0
crashes: 0
peak commit: 0 MB
xcl-smoke v1
commit: 820ff6a2d1abd2b3869c7a9940cb6e0bda30bfff
gpu: AMD Radeon RX 9070 XT (RADV GFX1201)
title: Build
seconds: 60
exit: 0x0
frames shown: 10 (PresentX 11)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 0 MB

Not tested

  • Windows and NTFS: built and run only as x86_64-pc-windows-gnu under Wine on Linux (the Linux file system has the same 255-byte limit on a name).
  • A title that uses names this long: the retail title in the regression run does not.

AI use

  • Claude Code (Claude Opus 5.5): wrote the change, the test and this description, and ran the commands above on the machine described.
<!-- greyfinch-sync:ivall/xcl:issue:6572186814 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/493). Originally posted by [pablogonz12](https://github.com/pablogonz12) on 2026-11-24T01:01:41Z. --- A container's folder is `enc(name)`. A valid name has up to 256 characters, and `enc` turns each escaped byte into three, so past 255 characters the folder cannot be created: `XGameSaveCreateContainer` returns `S_OK` and every `XGameSaveSubmitUpdate` to that container fails with `E_FAIL`. Fixes #326. **What is in it** - `crates/xcl/src/hle/xgameruntime/gamesave.rs`: - `container_folder(name)`: `enc(name)` when it fits in 255 characters (so every folder that works today keeps its name); otherwise the start of `enc(name)` (never cut inside a `%XX`), `~` and a 64-bit FNV-1a hash of the lowercase name. `enc` never writes `~`, so the two kinds never meet; the hash is of the lowercase name because container names match ignoring case, as the `enc(name)` folders do on NTFS. - `apply()` writes the exact name to the folder's `name` file when the folder is a hashed one; `each_container` reads it back through `container_name(dir)`. - `XGameSaveCreateContainer`, `XGameSaveDeleteContainer(Async)` use `container_folder`. - Test `long_container_names_are_saved_listed_and_deleted`: the two names from the issue (256 letters; `"a/" × 85 + "x"`, 341 characters encoded) are written, read back, found by `XGameSaveGetContainerInfo` in upper case, listed by `XGameSaveEnumerateContainerInfo` with their exact names, and deleted; a 255-character name keeps its plain folder. **Tested** - AMD Radeon RX 9070 XT (RADV GFX1201, Mesa), AMD Ryzen 9 9900X, CachyOS (Linux 7.3), Wine 11.0 (Proton CachyOS) with vkd3d-proton v3.1 + the patch from #257, Rust stable, release. - `cargo test -p xcl --lib --release --target x86_64-pc-windows-gnu` (llvm-mingw 20261117), test binary run under Wine with `--test-threads=4`: - this PR (`820ff6a`): 632 passed, 5 failed, 21 ignored; - `main` (`a6f5f7a`): 631 passed, 5 failed, 21 ignored – the same five fail on both (`gpu_f64_roots`, `gpu_f64_math_random`, `gpu_nonfused_mad_and_mac_prevent_fma_contraction`, `xma2_source_voice_decodes_and_manages_lifetime`, and `pe::tests::parses_own_test_binary_tls`, which #464 fixes for this toolchain). - `cargo test ... gamesave`: 11 passed. The new test on `main`'s `gamesave.rs` (without its two `container_folder` asserts): FAILED at the first `XGameSaveSubmitUpdate`, as the issue describes. **Regression run** Made with `scripts/linux/smoke.sh` from #257 under Wine (not `smoke.ps1`), MSVC builds (`cargo xwin`) of both commits. The `main` block was made with a local copy of the script with two lines changed so that a run which does not reach its end still prints its block (`set -eu` instead of `set -euo pipefail`; the `data:` fallback as an `if`). ``` xcl-smoke v1 commit: a6f5f7a74cc620c1f88a9e3669a633d10c3c8212 gpu: AMD Radeon RX 9070 XT (RADV GFX1201) title: Build seconds: 60 exit: 0x0 frames shown: 9 (PresentX 9) presents per 2 s (last 3): 1 0 1 device removals: 0 crashes: 0 peak commit: 0 MB ``` ``` xcl-smoke v1 commit: 820ff6a2d1abd2b3869c7a9940cb6e0bda30bfff gpu: AMD Radeon RX 9070 XT (RADV GFX1201) title: Build seconds: 60 exit: 0x0 frames shown: 10 (PresentX 11) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 0 MB ``` **Not tested** - Windows and NTFS: built and run only as `x86_64-pc-windows-gnu` under Wine on Linux (the Linux file system has the same 255-byte limit on a name). - A title that uses names this long: the retail title in the regression run does not. **AI use** - Claude Code (Claude Opus 5.5): wrote the change, the test and this description, and ran the commands above on the machine described.
upstream-sync closed this pull request 2026-11-24 06:58:37 +00:00
pablogonz12 commented 2026-11-24 07:05:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by pablogonz12 on 2026-11-24T01:01:50Z.


Closing: duplicate of #481 (and #492), which were opened before this one for the same issue. Sorry for the noise.

<!-- greyfinch-sync:ivall/xcl:comment:7118681277 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/493#issuecomment-7118681277). Originally posted by [pablogonz12](https://github.com/pablogonz12) on 2026-11-24T01:01:50Z. --- Closing: duplicate of #481 (and #492), which were opened before this one for the same issue. Sorry for the noise.

Pull request closed

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!488
No description provided.