VFS: fix Unicode case-folding slicing and verbatim root normalisation #313
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/316"
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?
Imported from ivall/xcl. Originally posted by Michael-Glaser on 2026-11-23T23:08:36Z.
Vfs::classify_withsliced un-lowercasedabsusingself.game_root.len() + 1after.to_lowercase(), which panics or corruptsrelwhen Unicode case folding changes UTF-8 byte length (ẞ,İ,K).Vfs::newalso missedstrip_verbatimongame_rootanddata_root_lc.What is in it
crates/xcl/src/vfs.rs: matchgame_root_lcper\component (strip_path_prefix_ci, trimming repeated separators), handle\\?\and\??\UNC prefixes case-insensitively instrip_verbatim, applystrip_verbatim+trim_septo roots inVfs::new, and addclassify_handles_unicode_case_folding_and_verbatim_roots.Tested
aarch64-apple-darwin, Rust 1.100.0):cargo check --offline --target x86_64-pc-windows-msvc --workspace --tests(0 errors, 0 new warnings).@regiumlepidi(RTX 5070 Ti + RDNA2 iGPU: 667 passed, 0 failed, 41 ignored; negative control confirmed) and@DavidM1911(RTX 3060 Ti, Windows 11, merged withmain:cargo test -p xcl --libpassed).Regression run
Retail 60 s smoke run contributed by
@Toons29(AMD Radeon RX 9070 RDNA4, driver 32.0.32029.2010, Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0, release build,XCL_NETWORK=0):Not tested
AI use
@Toons29with Claude Code (Claude Opus 5.5).Imported from ivall/xcl. Originally posted by 0xKaji on 2026-11-23T23:49:11Z.
Reviewed commit
f0bd1eastatically on Linux (not built or executed on Windows; assisted by T3 Code + Gemini 4 Neon).strip_path_prefix_cilooks sound: every slice index is on an ASCII\boundary withinabs, so it eliminates the UTF-8 slicing panics and corruptedrelslices for length-changing case folds (ẞ,İ,K) without introducing regressions on standard paths.A few concrete items before moving this out of draft:
Merge blockers (
CONTRIBUTING.md/PR checks):PR checksis currently failing becausecrates/xcl/src/vfs.rsis runtime code and**Regression run**is missing the twoxcl-smoke v1blocks (mainand PR headf0bd1ea, clean working tree) fromscripts/smoke.ps1.cargo test --workspace -- --test-threads=4counts (and greenCI) are still needed in**Tested**.strip_verbatim(crates/xcl/src/vfs.rs:102-113) mishandles lowercase\\?\unc\...and\??\UNC\...:strip_verbatim, but now also called fromVfs::new(vfs.rs:192, 207, 210).is_device(vfs.rs:157-160) matches\\?\and\??\with ASCII case-insensitiveunc\, whereasstrip_verbatimonly checks exact uppercase"\\\\?\\UNC\\".\\?\unc\server\share\file.binand\??\UNC\server\share\file.binbypassis_device, fall through tostrip_prefix("\\\\?\\")/strip_prefix("\\??\\"), and become relative"unc\\server\\share\\file.bin"/"UNC\\server\\share\\file.bin". That bypasses thep.starts_with("\\\\")UNC guard (vfs.rs:286) and resolves relative to CWD (misclassifying asTarget::Gamewhen CWD is insidegame_root).\\?\or\??\first and then checkingr.get(..4).is_some_and(|s| s.eq_ignore_ascii_case("UNC\\"))would keepstrip_verbatimconsistent withis_device(fine either here or as a small follow-up PR).Minor non-blocking edge cases / test notes:
strip_path_prefix_ci(vfs.rs:143),&abs[pos + 1..]returns a leading\ifabshas repeated separators after the root (e.g.classify_with("C:\\Games\\Title\\\\Data\\a.bin", id)→rel: "\\Data\\a.bin").GetFullPathNameWcollapses\\for normal paths, butabs[pos + 1..].trim_start_matches('\\')guarantees theTarget::Gameinvariant unconditionally.game_rootis a drive root likeX:\or\\?\X:\,trim_sepstores"X:", sooriginal_path("")returns"X:"(drive-relative CWD in Win32) instead of"X:\\".classify_handles_unicode_case_folding_and_verbatim_roots, it would be useful to also assertvc.classify_with("C:\\Games\\Title\\Data\\x.bin", id)(verbatimgame_root_lcnot hijacked by theC:mount) and a mixed/+\Unicode case-folding input.Imported from ivall/xcl. Originally posted by regiumlepidi on 2026-11-23T23:56:51Z.
A Windows run for this draft, since Not tested says it has not been built or run on Windows yet:
f0bd1eamerged onto currentmaindb1ddb2(clean merge): builds and passes, and the new test fails onmain.Tested
XCL_ADAPTER=radeon(the Ryzen 7 9800X3D's RDNA2 iGPU, driver 32.0.21030.2001).\scripts\test.ps1(cargo test --workspace -- --test-threads=4), noXCL_SAMPLE_*setmaindb1ddb2f0bd1eaondb1ddb2classify_handles_unicode_case_folding_and_verbatim_rootscopied unchanged intomain'svfs.rsfails at its first case, with the corrupted slice the description names:With this PR's
vfs.rsit passes.Not tested
scripts/smoke.ps1(I have no Series title), so the Regression run blocks the PR check asks for still have to come from someone who has one.\\?\unc\/\??\UNC\case raised in the review above.AI use: Claude Code with Claude Opus 5.5 ran the build and tests and wrote this comment; the numbers come from those runs.
Imported from ivall/xcl. Originally posted by Michael-Glaser on 2026-11-24T00:18:31Z.
Thanks @0xKaji and @regiumlepidi! Rebased onto main (
a6f5f7a, commitce99a57) and applied the review items: strip_verbatim now handles \?\ and ??\ UNC prefixes case-insensitively, strip_path_prefix_ci trims repeated separators after the root, and added the extra UNC, mixed-separator, and verbatim game_root test cases.Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T02:55:15Z.
Regression run of
a9ce85eaon the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 101 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; I checked the blocks before posting.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T14:29:08Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
Imported from ivall/xcl. Originally posted by Michael-Glaser on 2026-11-27T12:02:08Z.
Thanks @Toons29 and @DavidM1911! Added the verbatim
xcl-smoke v1regression blocks fora9ce85eaand the Windows test results into the PR description.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-27T17:46:46Z.
Full-suite run on NVIDIA and AMD at the current head; the earlier reports here are on older heads. Tested exact head
a9ce85ea(on its base47efa2e).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace --no-fail-fast -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 742 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.classify_handles_unicode_case_folding_and_verbatim_roots.XCL_ADAPTER=radeon),cargo test --workspace --no-fail-fast -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 742 passed, 0 failed, 41 ignored, no skips.--skipleaves out tests that fail on main6089122atoo, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests,const_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
Imported from ivall/xcl. Originally posted by ClosetPie107 on 2026-11-27T18:01:01Z.
Tested on AMD / Linux:
a9ce85ea(RX 9070 16 GB, RDNA4, Mesa 26.3.1 RADV; Ryzen 5 9600X, 32 GB; CachyOS; Proton Experimentalexperimental-11.0-20261112with vkd3d-proton masterec207194plus a local patch dropping thelpVtblchecks of command allocators and lists; DXC 1.9.2609.5; Rust 1.96.0,x86_64-pc-windows-gnudebug build, tests run under Wine)The head as it is (not merged onto current
main), with its base47efa2ecthe same session as the baseline.Tests (
XCL_REQUIRE_GPU=wave64)cargo test -p xcl --lib -- vfs:: --test-threads=1: 13 passed, 0 failed, 0 ignored (includesclassify_handles_unicode_case_folding_and_verbatim_roots).cargo test --workspace --no-fail-fast -- --test-threads=4with--skip compositor_blends_ui_plane_over_scene_plane --skip failed_restore_stops_before_importing_an_unbacked_window --skip grooming_leaves_a_window_under_1_gib_only_its_hole(the first loses the RADV device here, the other two run out of memory under Wine): lib 694 passed, 5 failed, 21 ignored; base47efa2eclib (same flags): 693 passed, 5 failed, 21 ignored, the same 5. The other binaries fail the same 3 tests as onmainhere (e2e,pls_quota,predication_e2e).Not tested
AI use
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T07:56:26Z.
merge-check claim
head:
a9ce85eaf7Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T08:05:05Z.
merge-check
base:
d52ff48caahead:
a9ce85eaf7merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2876 passed, 2 failed, 51 ignored; 29 SKIPPED lines
failing: test_title_runs_and_game_folder_is_untouched
review: automated overnight check — diff inspected for safety only (no build/CI/toolchain/script changes, no process/network/runtime-loading code); no duplicate search performed; no line-by-line code review.
performance: not assessed beyond the suite.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 610.88 (32.0.16.1088); Ryzen 7 5800X3D, 64 GB; Windows 11 22631; OpenCode agent, DeepSeek V4.1 Flash 1017
correction: this check first reported the PR as "not yet" because of a test failure that is not the PR's. The base-comparison step failed to run (test names contain a double colon, not a legal Windows filename), so an empty read was mistaken for "passes on base".
gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16fails on based52ff48cby itself (verified separately with the same command: "assertion failed: 2D D16 resinfo clobbered v2/v3"). Verdict corrected. Apologies for the noise.Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T09:53:46Z.
merge-check claim
head:
a9ce85eaf7Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T10:01:41Z.
merge-check
base:
9dfbe3ea66head:
a9ce85eaf7merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2886 passed, 1 failed, 51 ignored; failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, which fails on the base alone too (base: 2885 passed, 1 failed, 51 ignored, 28 SKIPPED lines). 28 SKIPPED lines, as on the base. The new test
vfs::tests::classify_handles_unicode_case_folding_and_verbatim_rootspassed, as did the existing vfs tests and the e2e title tests.review: no blocking finding; one file, every hunk read. Two fixes in path classification. (1) The game-root prefix is now matched per path component on the lower-cased component (
strip_path_prefix_ci); the old code lower-cased the whole path and then sliced the original string at the root's byte length, which is wrong (and can panic on a char boundary) when lower-casing changes the UTF-8 length (ẞ, İ, K). (2)strip_verbatimhandles the\\?\and\??\prefixes in one place, with a case-insensitiveUNC\, and the game, data and PLS roots are stripped of the verbatim prefix and a trailing separator before comparison. The test covers both folding directions, a root equal to the path, forward slashes, doubled separators, verbatim roots and sibling directories that share a prefix. One thing to know: leading separators of the relative tail are now trimmed (a doubled separator after the root gives the same tail as a single one), which the test pins. Not tested by me: a real title in a folder with such characters.performance: none to speak of: one lower-casing per path component in place of one for the whole path, on file opens.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:07:34Z.
Triage (#1607) – head
a9ce85eNo open or merged PR fixes the same thing.
classifyon main still slicesabs[self.game_root.len() + 1..]after matching the lowercased string, which is wrong (or panics) when lowercasing changes a character's UTF-8 length. #1560 also makes the\\?\UNC\prefix case-insensitive, but itsabs[abs.len() - rest.len()..]still mixes byte lengths oflcandabs, so it does not fix the slicing.No problems found in the diff. Note that
Vfs::newnow strips a verbatim prefix fromgame_root, so game files are opened without\\?\(MAX_PATH limits apply if the launcher ever passes one).Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by Decodere on 2026-12-02T10:31:07Z.
merge-check
base:
1c8b551475head:
a9ce85eaf7merge: clean (trial-merge commit 8ba101471b423761b56cc768c507d7923304477b, git diff --check clean)
build: cargo build --workspace ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture (43 targets): 2909 passed, 1 failed, 51 ignored (+1 new test vs main baseline 2908/1). All 14/14 vfs::tests passed with 0 skips, including new classify_handles_unicode_case_folding_and_verbatim_roots. The single failure is the pre-existing Issue #3441 flake in tests/gpu_two_pass_cache_e2e.rs::two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (line 584, left: 1, right: 0), reproduced identically on clean base
1c8b5514and unrelated to vfs.rs. 28 SKIPPED lines (host environment only: 22 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 2 no heap windows, 1 cannot disable the driver cache (Windows Developer Mode required)).review: Read the full merged diff (+91/-18 in crates/xcl/src/vfs.rs). Replaces byte-offset slicing against
.to_lowercase()inVfs::classify_withwith component-wise case-insensitive prefix matching (strip_path_prefix_ci), avoiding panics or wrong slices when case folding changes UTF-8 byte lengths (ẞ,İ,K) while preserving original casing and rejecting sibling prefixes. Normalizesstrip_verbatimfor both\\?\and\??\plus case-insensitiveUNC\(checkingr.get(..4)safely before slicing&r[4..]), and appliestrim_sep(strip_verbatim(norm(...)))consistently togame_root,pls_root_lc, anddata_root_lcinVfs::new. The new unit test covers multi-byte case folding in both directions, double separators, verbatim roots, sibling rejection, verbatim UNC, andC:mount protection. No scope creep or UB.performance: not applicable (Tier 1 — VFS path normalization/classification only, off hot rendering/GPU paths).
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 4060 8 GB (driver 621.40), Intel Core i5-11400F, 32 GB RAM, Windows 11 Build 26200, Rust 1.100.1 MSVC, DXC 1.9.2602.17 / Antigravity (Gemini 4 Neon)