Skip to content

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

Closed
pablogonz12 wants to merge 1 commit into
ivall:mainfrom
pablogonz12:gamesave-long-names
Closed

pablogonz12 wants to merge 1 commit into
ivall:mainfrom
pablogonz12:gamesave-long-names

Conversation

@pablogonz12

Copy link
Copy Markdown

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 Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #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 TLS: xcl.exe built with MinGW and lld keeps its TLS directory #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.

A container's folder is enc(name), and a valid name has up to 256 characters that enc turns into up to three each: past 255 the folder cannot be created, so XGameSaveCreateContainer said S_OK and every XGameSaveSubmitUpdate to it failed with E_FAIL (ivall#326). Such a name now gets the start of enc(name), '~' and a 64-bit FNV-1a hash of the lowercase name as its folder (enc never writes '~'), and the exact name in the folder's 'name' file, which listing reads. Names whose folder fits keep the folder they always had.
@pablogonz12

Copy link
Copy Markdown
Author

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

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 long valid container name makes every save to it fail

1 participant