XGameSave: a long valid container name makes every save to it fail #326
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#326
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:28 UTC · original
XGameSaveCreateContainerstores a container in a folder namedenc(name)under the provider root (crates/xcl/src/hle/xgameruntime/gamesave.rsonmain85bdf21:enc()at line 73, folder created inapply()at line 567).valid_container_name_length(line 254) allows up to 256 characters, matching the GDK maximum, but Windows caps each path component at 255 characters, andenc()expands every/(which the GDK allows in container names) into%2F(3 characters).Examples accepted by
XGameSaveCreateContainer(S_OK) whose folder cannot be created:enc(name)length"a/" × 85 + "x"Because
XGameSaveCreateContainerreturnsS_OK,create_dir_alllater fails inapply()and everyXGameSaveSubmitUpdateto that container returnsE_FAIL.Repro (clean-room, Linux):
Copied
enc()unchanged into a standalone program and calledcreate_dir_all(Linux shares the 255-byte component limit): both the 256-char and 341-char names failed withFile name too long.Suggested fix:
When
enc(name)exceeds ~200 characters, store the container under a shortened folder name (e.g. truncated prefix + hash of the full name) and persist the exact container name in a metadata file inside the folder foreach_containerto read back. Separately, enforcing the GDK's allowed character set inXGameSaveCreateContainer(returningE_GS_INVALID_CONTAINER_NAMEfor disallowed characters like spaces or:) would match console behavior more closely.Not tested: on Windows or with a game.
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:54 +00:00
github-bot referenced this issue2026-11-26 04:59:09 +00:00
@Grimkaaah on GitHub · 2026-11-24 00:51 UTC · original
Claim — shortened folder when
enc(name)exceeds the path component limitPlan: When
enc(name)is longer than 255 bytes (Windows/Linux component max), store the container under a short folder (xcl-+ SHA-256 prefix of the encoded name) and write the exact container name into a metadata file inside that folder soeach_container/ enumeration still round-trip. Keepvalid_container_name_lengthat the GDK 256-char max soXGameSaveCreateContainerstaysS_OKfor valid names; only the on-disk folder is shortened. Unit tests for the 256-ASCII and"a/"×85+"x"cases (folder creates, enumerate returns the original name, submit works).AI-assisted (Cursor / Composer). Working now.
@DavidM1911 on GitHub · 2026-11-24 00:52 UTC · original
I'll take this one. Plan:
container_dir_name()returnsenc(name)while it fits (~200 chars, matching the suggestion — longer encodings never fit a Windows path component in practice anyway), otherwise~xcllong.<sip-hash>(the~can't appear inenc()output, so no collision). The real name goes in anamefile inside the folder, written atomically byapply()(self-healing, sinceapplygets the name through theUpdate), andeach_containerreads it back for~xcllong.*dirs.delete_path/CreateContaineruse the same mapping. Unit test: a 256-char name and an"a/"-heavy name round-trip through create → submit → enumerate → delete.@Grimkaaah on GitHub · 2026-11-24 00:56 UTC · original
Opened a fix PR: uses a hashed
~xclc.<fnv>folder whenenc(name)is too long, and stores the exact name incontainer_namefor enumeration. Tests cover the 256-char case from the issue.@lordon1a on GitHub · 2026-11-24 04:05 UTC · original
Comparison of the open PRs for #326 (#481, #492; #623 was closed by its author in favour of these), to help pick one.
Both store a container whose
enc(name)is longer than 200 characters under a hashed folder and keep the real name in a file inside it. Both merge cleanly intomainf4ce27cand touch onlygamesave.rs. I read the diffs before running them and found nothing outside the save folder and the test temp folders. Their own tests pass on the merge withmain.PR descriptioncheckf9947a0560368cstd::collections::hash_map::DefaultHasherPoints:
DefaultHasher, which is not stable across Rust releases. The std docs say its algorithm "is not specified, and so it and its hashes should not be relied upon over releases". The hash names a folder on disk. If a toolchain update changes it, an XCL built with the new compiler looks for long-named containers under a different folder. Those saves stop showing up, while the old folder still holds them and still enumerates through itsnamefile. #481's FNV-1a (and #623's) does not depend on the compiler. Replacing the hasher in #492 with a fixed function is a few lines.container_nameinto every container on every update, not only the hashed ones, andeach_containerthen counts a folder holding only that file as an existing container. That changes the on-disk layout of every save made from then on. It does not break anything I found, but keeping the file only in hashed folders, as #492 does, keeps existing saves as they are.replace_file'sMoveFileExWis called without the\\?\prefix and refuses paths of 260 characters or more, so a 190-character name still fails on both PRs and onmain. With the test data folder, that name gives a 267-character container folder andXGameSaveSubmitUpdatereturnsE_FAIL. The 256-character case in their tests passes only because the hashed folder is short. I opened #722 for that, with a failing test and a fix. With it, the 190-character name saves on its own. With #722 in, the threshold here only has to keep each component under 255.namefile against the requested name on open would turn that into an error instead.Suggestion: #492 passes the checks and keeps the change to hashed folders only. It can be merged once
DefaultHasheris replaced by a fixed hash (FNV-1a as in #481). Then close #481. #722 is a separate fix and works with either.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,cargo test -p xcl --lib gamesaveon each PR merged intomainf4ce27c, plus a 190-character-name save test. Not tested: the MSVC toolchain,cargo test --workspace, smoke runs.Written with Claude Code (Claude Opus 5.5). I checked each point against the diffs and the runs above.
@pickles976 on GitHub · 2026-11-24 05:01 UTC · original
Adjudication of the two PRs (design review + one measurement, 2026-11-24):
Both converge on the right shape — names whose
enc()fits stay in their current folder (existing saves untouched, no migration), only over-long names move to a hash folder, and both handle the enumeration read-back (XGameSaveEnumerateContainerInfomust report the container's name, not the hash folder). Neither can collide with anenc()folder (~is percent-encoded byenc, so both prefixes are reserved).~…stored_container_name()via theapply-signature plumbingDefaultHasher::new()(SipHash-1-3, fixed seed)~xcllong.The measurement I added: #492's choice of
DefaultHasher::new()looks risky — a randomly-seeded hasher would give a different folder every process launch and silently orphan long-name saves across game sessions (worse than the original bug). It isn't:DefaultHasher::new()is deterministically seeded — I hashed the issue's("a/"*85)+"x"case in 10 separate processes, 10/10 identical — so #492's folder mapping is run-stable. #481 doesn't need the argument (FNV has no seed at all), but its description check is red and itsapply()-signature change touches more surface than the defect needs.Recommendation: merge #492; #481's author's
stored_container_nameframing is the more future-proof read-back, worth cherry-picking ifLONG_PREFIXever grows — as-is it's a description-fix and a smaller-diff duplicate away from #492.mainreaches on Windows; the obstacle is replaced vtables — proposal: proxies #175