Skip to content

RPF: commit an extracted record past MAX_PATH with a verbatim path - #1072

Open
iggyvilla wants to merge 1 commit into
xcl-dev:mainfrom
iggyvilla:xcl-rpf-long-path
Open

iggyvilla wants to merge 1 commit into
xcl-dev:mainfrom
iggyvilla:xcl-rpf-long-path

Conversation

@iggyvilla

Copy link
Copy Markdown
Contributor

xcl rpf --extract ... --out <folder> writes each record through atomic_write_with, which moved its temporary file into place with MoveFileExW on the plain paths. That call fails with error 3 ("The system cannot find the path specified") for a path of MAX_PATH characters or more, although the folder and the temporary file exist; std's own file calls add the \\?\ prefix, this one did not. So an extraction into a deep output folder failed. move_path now gives MoveFileExW the absolute path, prefixed with \\?\ (or \\?\UNC\) when it is 260 characters or longer; shorter, verbatim and device paths are unchanged. The same mistake in the XGameSave code is #922's; this PR does not touch that file.

What is in it

  • crates/xcl/src/rpf.rs: move_path and its two uses in atomic_write_with (+68/-2 with tests).
  • Tests, same file: move_path_prefixes_only_what_is_past_max_path (drive, UNC, short, verbatim, verbatim UNC, device, the 259 and 260-character edges, .. folded) and atomic_write_commits_past_max_path (a real write into a 300+ character path; it fails with error 3 without the change).

Tested

  • AMD Radeon RX 6650 XT (RDNA2), Windows 10.0.26300, rustc 1.100.0, debug.
  • cargo test -p xcl --lib rpf::tests: 7 passed, 0 failed, 0 ignored. Without the change atomic_write_commits_past_max_path fails with Os { code: 3, kind: NotFound }.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on 6de9cf7: 726 passed, 3 failed, 41 ignored, 0 SKIPPED. The 3 failures are the ones already on main: placed_title_textures_share_vram_and_preserve_pixels (also fails alone; the packed-mip bug D3D12.X: map a one-slice title texture's packed mips where D3D12 addresses them #470 fixes), and transitions_apply_when_their_list_is_submitted and d32s8_targets_take_their_own_size_of_video_memory (PoisonError after it; they pass alone; Tests: a panicking title-texture test no longer poisons the others #673).

Regression run

The change is in xcl rpf, which a title run does not reach, so this only shows that nothing else moved. After an unmeasured warm-up of each build, with no other build or title run on the machine, the runs alternated: head 446, main 447, main 445, head 444 frames; no device removals or crashes. The second pair is shown.

main:

xcl-smoke v1
commit: 6efdabcdaac93ce5cc123a85e85deba5d49cb294
gpu: AMD Radeon RX 6650 XT
title: retail
seconds: 60
exit: 0x0
frames shown: 445 (PresentX 451)
presents per 2 s (last 3): 59 41 0
device removals: 0
crashes: 0
peak commit: 15271 MB

This PR:

xcl-smoke v1
commit: 6de9cf7945400f125efe10bf14a5e8f80cde81f2
gpu: AMD Radeon RX 6650 XT
title: retail
seconds: 60
exit: 0x0
frames shown: 444 (PresentX 448)
presents per 2 s (last 3): 58 42 0
device removals: 0
crashes: 0
peak commit: 15268 MB

Not tested

AI use

  • Claude Code, Claude Sonnet 5.5 (claude-sonnet-5-5): wrote the change, the tests and this description, and ran the tests above.

atomic_write_with moved its temporary file into place with MoveFileExW on
the plain paths. That call fails with error 3 (path not found) for a path
of MAX_PATH characters or more, although the folder and the temporary file
exist (std's own file calls add the \\?\ prefix, this one does not). So
`xcl rpf --extract ... --out <deep folder>` failed on records whose output
path is 260 characters or longer.

move_path gives MoveFileExW the absolute path, prefixed with \\?\ (or
\\?\UNC\) when it is 260 characters or longer; shorter, verbatim and device
paths are unchanged.

Assisted-by: Claude Code (Claude Sonnet 5.5)
@futurepro62

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head 6de9cf7 (on its base 6efdabc).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 729 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: move_path_prefixes_only_what_is_past_max_path, atomic_write_commits_past_max_path.

Not tested

  • AMD, a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

kacper-serewis pushed a commit to kacper-serewis/xcl that referenced this pull request Nov 24, 2026
Adapt xcl-dev#1072 with NT-prefix preservation. Real extractor probes verified the payload and destination handling on long drive and UNC paths and restored the short NT-path behavior.

Assisted-by: T3 Code (gpt-6.2-astra)
@kacper-serewis

Copy link
Copy Markdown

On 6de9cf7, a destination in NT form (\??\C:\...\record.bin; short path, existing folder) fails: atomic_write works on the base 6efdabc and returns error 123 (ERROR_INVALID_NAME) with the PR.

Tested: Windows 11, debug, CPU only.

std::path::absolute treats \??\ as a root-relative path. Suggested, at the top of move_path:

    // std::path::absolute treats the NT prefix as a root-relative DOS path
    if path.as_os_str().as_encoded_bytes().starts_with(br"\??\") {
        return Ok(path.as_os_str().encode_wide().chain([0]).collect());
    }

With it on 6de9cf7 the test below and the PR's own pass (cargo test -p xcl --lib rpf::: 8 passed, 0 failed).

Test (append to rpf.rs)
#[cfg(test)]
mod nt_probe {
    use super::*;
    use std::time::{SystemTime, UNIX_EPOCH};
    #[test]
    fn nt_form_destination_commits() {
        let nonce = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos();
        let root = std::env::temp_dir().join(format!("xcl-rpf-nt-{}-{nonce}", std::process::id()));
        std::fs::create_dir_all(&root).unwrap();
        let nt = std::path::PathBuf::from(format!(r"\??\{}\record.bin", root.display()));
        let r = atomic_write(&nt, b"payload");
        let data = std::fs::read(root.join("record.bin"));
        std::fs::remove_dir_all(&root).unwrap();
        assert!(r.is_ok(), "{r:?}");
        assert_eq!(data.unwrap(), b"payload");
    }
}

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this comment; the suggested change was written with T3 Code (gpt-6.2-astra). I checked the points before posting.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

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.

4 participants