XGameRuntime: prefix MoveFileExW paths with \\?\ past MAX_PATH (#722) #922

Closed
github-bot wants to merge 1 commit from gh-pr/922/head into gh-pr/922/base
Owner

@⁠bigiello on GitHub · 2026-11-24 08:21 UTC · original
fix/gamesave-movefile-long-path → main · +145 −3 · 1 files · 1 commits · closed without merging

Draft pending scripts/smoke.ps1 regression blocks on a retail title (no local game files available; see Not tested).

Fixes #722.

replace_file in crates/xcl/src/hle/xgameruntime/gamesave.rs passed plain UTF-16 paths to MoveFileExW. Without the Win32 verbatim prefix (\\?\ / \\?\UNC\), MoveFileExW rejects paths reaching MAX_PATH (260 UTF-16 units) with ERROR_PATH_NOT_FOUND (3), even though std::fs::File::create wrote the sibling temp file using a verbatim path. Saves into long container names (e.g., ~170–200 characters under %LOCALAPPDATA%\XCL\...) therefore failed with E_FAIL.

What is in it

  • crates/xcl/src/hle/xgameruntime/gamesave.rs:
    • verbatim_wide: resolves std::path::absolute, folds . / .. / / before bypassing Win32 path normalization, preserves existing \\?\ and \\.\ prefixes as well as unpaired UTF-16 surrogates, and emits NUL-terminated \\?\ or \\?\UNC\ UTF-16 buffers.
    • replace_file: encodes both source and destination paths via verbatim_wide before calling MoveFileExW.
    • Unit tests a_blob_past_max_path_is_saved (create, overwrite, temp-file cleanup, and public XGameSave C API round-trip past MAX_PATH; failed with E_FAIL before the fix) and verbatim_wide_normalizes_and_prefixes_win32_paths (drive, normalized ..//, \\?\, \\.\, UNC, and unpaired surrogate cases).

Tested

  • Hardware: Windows 11 x64, AMD Ryzen 5 5600, 32 GB RAM, NVIDIA GeForce RTX 4070 SUPER (11999 MiB VRAM, D3D12 SM 6.6, 32-lane waves), MSVC stable-x86_64-pc-windows-msvc (rustc 1.100.0), Windows SDK DXC 1.8.2502.11 (10.0.26100.0\x64).
  • Before fix (09940bb): cargo test -p xcl --lib -- a_blob_past_max_path_is_saved failed with left: -2147467259 (E_FAIL).
  • After fix (d2edf29):
    • cargo test -p xcl --lib -- gamesave --nocapture: 12 passed, 0 failed.
    • cargo test -p xcl --lib -- --test-threads=1: 677 passed, 0 failed, 21 ignored (2 GPU tests skipped: no wave64 — gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware).
    • .\scripts\test.ps1 and cargo test --workspace --no-fail-fast -- --test-threads=4: all integration test binaries passed (console_dlls_e2e 13 passed, console_shaders 3 passed / 4 ignored, disasm_e2e 1 passed, e2e 3 passed, gpu_compute_e2e 2 passed, gpu_pso_e2e 7 passed, heap_probe 0 passed / 4 ignored, pls_quota 1 passed, predication_e2e 1 passed, rpf_e2e 2 passed, sparse_reinit 1 passed, texture_states 1 passed, xg_oracle 6 passed / 12 ignored; xcl main / xcl-testtitle / doc-tests: 0 tests). Under --test-threads=4, xcl --lib hit the pre-existing #718 timing flake in placed_title_textures_share_vram_and_preserve_pixels (poisoning transitions_apply_when_their_list_is_submitted and d32s8_targets_take_their_own_size_of_video_memory: 674 passed, 3 failed, 21 ignored); all 3 passed cleanly in 3.50s when run with --test-threads=1 and in the full --test-threads=1 run above.
    • cargo clippy --workspace --all-targets: 0 errors, 0 new warnings on touched lines.
    • rustfmt --check crates\xcl\src\hle\xgameruntime\gamesave.rs: 0 diffs on touched lines (cargo fmt --check overall exits 1 due to pre-existing formatting in untouched files).

Not tested

  • Live SMB/UNC share save root (the \\?\UNC\ formatting path is unit-tested in verbatim_wide_normalizes_and_prefixes_win32_paths, not exercised against a real network share).
  • Native 64-lane hardware waves (RTX 4070 SUPER has 32-lane waves only).
  • Retail game data and scripts/smoke.ps1 -Game <folder> (XCL_SAMPLE_* unset; no retail game files available locally).

AI use

  • Tool: Antigravity model: Neon. Assisted with implementing verbatim_wide, adding regression and path-normalization tests, running tests/clippy, and drafting this PR description. All diffs and test outputs verified locally.
**@⁠bigiello** on GitHub · 2026-11-24 08:21 UTC · [original](https://github.com/xcl-dev/xcl/pull/922) `fix/gamesave-movefile-long-path` → `main` · +145 −3 · 1 files · 1 commits · closed without merging Draft pending `scripts/smoke.ps1` regression blocks on a retail title (no local game files available; see **Not tested**). Fixes #722. `replace_file` in `crates/xcl/src/hle/xgameruntime/gamesave.rs` passed plain UTF-16 paths to `MoveFileExW`. Without the Win32 verbatim prefix (`\\?\` / `\\?\UNC\`), `MoveFileExW` rejects paths reaching `MAX_PATH` (260 UTF-16 units) with `ERROR_PATH_NOT_FOUND` (3), even though `std::fs::File::create` wrote the sibling temp file using a verbatim path. Saves into long container names (e.g., ~170–200 characters under `%LOCALAPPDATA%\XCL\...`) therefore failed with `E_FAIL`. **What is in it** - `crates/xcl/src/hle/xgameruntime/gamesave.rs`: - `verbatim_wide`: resolves `std::path::absolute`, folds `.` / `..` / `/` before bypassing Win32 path normalization, preserves existing `\\?\` and `\\.\` prefixes as well as unpaired UTF-16 surrogates, and emits NUL-terminated `\\?\` or `\\?\UNC\` UTF-16 buffers. - `replace_file`: encodes both source and destination paths via `verbatim_wide` before calling `MoveFileExW`. - Unit tests `a_blob_past_max_path_is_saved` (create, overwrite, temp-file cleanup, and public `XGameSave` C API round-trip past `MAX_PATH`; failed with `E_FAIL` before the fix) and `verbatim_wide_normalizes_and_prefixes_win32_paths` (drive, normalized `..`/`/`, `\\?\`, `\\.\`, UNC, and unpaired surrogate cases). **Tested** - Hardware: Windows 11 x64, AMD Ryzen 5 5600, 32 GB RAM, NVIDIA GeForce RTX 4070 SUPER (11999 MiB VRAM, D3D12 SM 6.6, 32-lane waves), MSVC `stable-x86_64-pc-windows-msvc` (`rustc 1.100.0`), Windows SDK DXC 1.8.2502.11 (`10.0.26100.0\x64`). - Before fix (`09940bb`): `cargo test -p xcl --lib -- a_blob_past_max_path_is_saved` failed with `left: -2147467259` (`E_FAIL`). - After fix (`d2edf29`): - `cargo test -p xcl --lib -- gamesave --nocapture`: 12 passed, 0 failed. - `cargo test -p xcl --lib -- --test-threads=1`: 677 passed, 0 failed, 21 ignored (2 GPU tests skipped: `no wave64` — `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`). - `.\scripts\test.ps1` and `cargo test --workspace --no-fail-fast -- --test-threads=4`: all integration test binaries passed (`console_dlls_e2e` 13 passed, `console_shaders` 3 passed / 4 ignored, `disasm_e2e` 1 passed, `e2e` 3 passed, `gpu_compute_e2e` 2 passed, `gpu_pso_e2e` 7 passed, `heap_probe` 0 passed / 4 ignored, `pls_quota` 1 passed, `predication_e2e` 1 passed, `rpf_e2e` 2 passed, `sparse_reinit` 1 passed, `texture_states` 1 passed, `xg_oracle` 6 passed / 12 ignored; `xcl` main / `xcl-testtitle` / doc-tests: 0 tests). Under `--test-threads=4`, `xcl --lib` hit the pre-existing `#718` timing flake in `placed_title_textures_share_vram_and_preserve_pixels` (poisoning `transitions_apply_when_their_list_is_submitted` and `d32s8_targets_take_their_own_size_of_video_memory`: 674 passed, 3 failed, 21 ignored); all 3 passed cleanly in 3.50s when run with `--test-threads=1` and in the full `--test-threads=1` run above. - `cargo clippy --workspace --all-targets`: 0 errors, 0 new warnings on touched lines. - `rustfmt --check crates\xcl\src\hle\xgameruntime\gamesave.rs`: 0 diffs on touched lines (`cargo fmt --check` overall exits 1 due to pre-existing formatting in untouched files). **Not tested** - Live SMB/UNC share save root (the `\\?\UNC\` formatting path is unit-tested in `verbatim_wide_normalizes_and_prefixes_win32_paths`, not exercised against a real network share). - Native 64-lane hardware waves (RTX 4070 SUPER has 32-lane waves only). - Retail game data and `scripts/smoke.ps1 -Game <folder>` (`XCL_SAMPLE_*` unset; no retail game files available locally). **AI use** - Tool: Antigravity model: Neon. Assisted with implementing `verbatim_wide`, adding regression and path-normalization tests, running tests/clippy, and drafting this PR description. All diffs and test outputs verified locally.
Fixes #722.

replace_file in gamesave.rs passed plain UTF-16 paths to MoveFileExW,
which rejects paths at or above MAX_PATH (260 UTF-16 units) with
ERROR_PATH_NOT_FOUND (3) even though std::fs::File::create wrote the
sibling temp file using a verbatim path. Any XGameSave container whose
blob path exceeded 260 characters therefore failed with E_FAIL.

- Add verbatim_wide in gamesave.rs to resolve absolute paths, fold
  "." / ".." / "/" before bypassing Win32 normalization, preserve
  existing "\\?\" and "\\.\" prefixes and unpaired UTF-16 surrogates,
  and emit "\\?\" or "\\?\UNC\" NUL-terminated UTF-16 buffers.
- Add regression tests covering creation, overwrite, temp-file cleanup,
  and public XGameSave API round-trips past MAX_PATH (failed with E_FAIL
  before the fix), plus Win32 prefix/normalization edge cases.

Assisted-by: Antigravity (exact model name not exposed to agent)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:36:55 +00:00
github-bot closed this pull request 2026-11-26 04:36:55 +00:00
Author
Owner

@⁠iggyvilla on GitHub · 2026-11-24 10:13 UTC · original

Test report on d2edf29 (PR head), with its merge base 09940bb for the smoke pair (main has moved on to 9aec53d; the PR changes gamesave.rs only).

Tested

  • AMD Radeon RX 6650 XT 8 GB (RDNA2, 64-lane waves), driver 32.0.21045.29003; Ryzen 7 5700X, 32 GB RAM; Windows 11 build 26300; rustc 1.100.0 x86_64-pc-windows-msvc; debug for the tests, release for the smoke runs.
  • cargo test -p xcl --lib gamesave: 12 passed, 0 failed (includes a_blob_past_max_path_is_saved and verbatim_wide_normalizes_and_prefixes_win32_paths).
  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4: 715 passed, 3 failed, 41 ignored, 0 SKIPPED lines (this adapter runs the wave64 tests). The three failures are in xcl --lib (674 passed, 3 failed, 21 ignored): placed_title_textures_share_vram_and_preserve_pixels (#470, 3D 64x64x64 4 mips: subresource 2 mismatch), and transitions_apply_when_their_list_is_submitted and d32s8_targets_take_their_own_size_of_video_memory, which fail with PoisonError after it. Run alone, the two cascade tests each pass (1 passed), and placed_title_textures_share_vram_and_preserve_pixels fails alone the same way on the merge base 09940bb and on this head, so it is not this PR. All integration binaries passed (e2e 3 passed after cargo build --workspace).
  • Smoke, scripts/smoke.ps1 -Game <retail title>, 60 s each, XCL_NETWORK=0, one unmeasured warm-up run of the head first (the title was on a new disk), then head, base, base, head. All five runs: exit 0x0, 0 device removals, 0 crashes. Order and results (head = d2edf29, base = 09940bb):

head, first measured run:

xcl-smoke v1
commit: d2edf2961b04daacee09ef741b9e42b78e33fe44
gpu: AMD Radeon RX 6650 XT
title: retail
seconds: 60
exit: 0x0
frames shown: 477 (PresentX 483)
presents per 2 s (last 3): 17 60 23
device removals: 0
crashes: 0
peak commit: 15132 MB

base, first run:

xcl-smoke v1
commit: 09940bb87fa11bc394fd9e5de570c2b7cfd16323
gpu: AMD Radeon RX 6650 XT
title: retail
seconds: 60
exit: 0x0
frames shown: 483 (PresentX 487)
presents per 2 s (last 3): 25 60 15
device removals: 0
crashes: 0
peak commit: 15135 MB

The repeats agree: base second run 476 frames / 15269 MB, head second run 483 frames / 15143 MB.

Not tested

  • The title does not save during a 60 s run, so the smoke pair shows that the PR does not disturb a title run, not that a long-path save works on the retail title. The save path is covered by the unit tests only.
  • A UNC share (the \\?\UNC\ branch is covered by the unit test only).
  • scripts/smoke.ps1 was run on the PR head and its merge base, not on a merge with today's main.

AI use: Claude Code, Claude Sonnet 5.5, built both commits, ran the tests and the smoke runs and wrote this report; I did not write any of the PR's code.

**@⁠iggyvilla** on GitHub · 2026-11-24 10:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/922#issuecomment-7128490114) Test report on `d2edf29` (PR head), with its merge base `09940bb` for the smoke pair (`main` has moved on to `9aec53d`; the PR changes `gamesave.rs` only). **Tested** - AMD Radeon RX 6650 XT 8 GB (RDNA2, 64-lane waves), driver 32.0.21045.29003; Ryzen 7 5700X, 32 GB RAM; Windows 11 build 26300; rustc 1.100.0 `x86_64-pc-windows-msvc`; debug for the tests, release for the smoke runs. - `cargo test -p xcl --lib gamesave`: **12 passed, 0 failed** (includes `a_blob_past_max_path_is_saved` and `verbatim_wide_normalizes_and_prefixes_win32_paths`). - `cargo build --workspace`, then `cargo test --workspace --no-fail-fast -- --test-threads=4`: **715 passed, 3 failed, 41 ignored, 0 SKIPPED lines** (this adapter runs the wave64 tests). The three failures are in `xcl --lib` (674 passed, 3 failed, 21 ignored): `placed_title_textures_share_vram_and_preserve_pixels` (#470, `3D 64x64x64 4 mips: subresource 2 mismatch`), and `transitions_apply_when_their_list_is_submitted` and `d32s8_targets_take_their_own_size_of_video_memory`, which fail with `PoisonError` after it. Run alone, the two cascade tests each pass (1 passed), and `placed_title_textures_share_vram_and_preserve_pixels` fails alone the same way on the merge base `09940bb` and on this head, so it is not this PR. All integration binaries passed (`e2e` 3 passed after `cargo build --workspace`). - Smoke, `scripts/smoke.ps1 -Game <retail title>`, 60 s each, `XCL_NETWORK=0`, one unmeasured warm-up run of the head first (the title was on a new disk), then head, base, base, head. All five runs: exit 0x0, 0 device removals, 0 crashes. Order and results (head = `d2edf29`, base = `09940bb`): head, first measured run: ``` xcl-smoke v1 commit: d2edf2961b04daacee09ef741b9e42b78e33fe44 gpu: AMD Radeon RX 6650 XT title: retail seconds: 60 exit: 0x0 frames shown: 477 (PresentX 483) presents per 2 s (last 3): 17 60 23 device removals: 0 crashes: 0 peak commit: 15132 MB ``` base, first run: ``` xcl-smoke v1 commit: 09940bb87fa11bc394fd9e5de570c2b7cfd16323 gpu: AMD Radeon RX 6650 XT title: retail seconds: 60 exit: 0x0 frames shown: 483 (PresentX 487) presents per 2 s (last 3): 25 60 15 device removals: 0 crashes: 0 peak commit: 15135 MB ``` The repeats agree: base second run 476 frames / 15269 MB, head second run 483 frames / 15143 MB. **Not tested** - The title does not save during a 60 s run, so the smoke pair shows that the PR does not disturb a title run, not that a long-path save works on the retail title. The save path is covered by the unit tests only. - A UNC share (the `\\?\UNC\` branch is covered by the unit test only). - `scripts/smoke.ps1` was run on the PR head and its merge base, not on a merge with today's `main`. **AI use:** Claude Code, Claude Sonnet 5.5, built both commits, ran the tests and the smoke runs and wrote this report; I did not write any of the PR's code.
Author
Owner

@⁠SlopTart on GitHub · 2026-11-24 10:37 UTC · original

Linux / AMD RDNA3 datapoint.

Merged state: head d2edf29 onto main 02bfd1d, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 722 passed, 7 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows. MoveFileExW prefix-past-MAX_PATH green.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. My Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

**@⁠SlopTart** on GitHub · 2026-11-24 10:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/922#issuecomment-7129027799) Linux / AMD RDNA3 datapoint. **Merged state:** head `d2edf29` onto main `02bfd1d`, clean merge. **Full suite, `cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4`:** **722 passed, 7 failed, 41 ignored**; failures are the known Wine-lane set from my #42 rows. MoveFileExW prefix-past-MAX_PATH green. **Not tested:** retail titles (none here), Windows, RDNA4. Counts only, no game data. **Machine:** RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross `x86_64-pc-windows-gnu`, `XCL_NETWORK=0`, release profile, `--test-threads=4`. My Linux rows: #42 / #718. AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.