startup: compare resolved staging paths #2864

Merged
louisdibiasi merged 6 commits from upstream-pr/2872 into main 2026-11-28 03:01:01 +00:00
louisdibiasi commented 2026-11-26 15:26:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by louisdibiasi on 2026-11-26T15:26:41Z.


Change

stage_package.ps1 checks package and destination paths by their spelling. If the package is named through a subst drive or directory junction and the destination uses the underlying path, it can stage inside the package even though the helper promises to keep the destination separate. An executable spelled inside the package can also resolve through a junction to a file outside it.

Compare resolved Windows paths for the package, executable and the destination's nearest existing ancestor before writing. Preserve drive-root separators, and keep the existing destination reparse-point and nonempty-directory checks. If Windows cannot resolve a path, staging stops; normalized-path queries can fail on some SMB shares. The comparison is not a defense against a concurrent change to the filesystem between the check and copy. Add the staging check to the Windows PR preset so the regression runs in PR CI. #2827 adds a runtime build preset in a separate section of the same file.

Verification

Windows, base b505c32b, final head 9ca04115:

  • out\pe-env\Scripts\python.exe -B tests\startup_stage_package_check.py powershell.exe and the same command with pwsh.exe — passed. The synthetic junction controls refuse a destination inside the package through an alias and an executable outside it through a junction, and allow a separate destination and an executable reached through a junction that stays inside the package. A volume-GUID path is also checked against a nested destination and a safe sibling; that control explicitly skips if the temporary volume has no GUID path. On upstream the package-alias control staged inside the package; a separate synthetic source-junction check also staged the outside executable.
  • A temporary subst mapping to a synthetic package reproduced the destination bypass on upstream. With the patch, both shells refused that nested destination and a physical drive-root alias, and staged to a separate sibling. The test mapping was removed. Network shares and concurrent path changes were not tested.
  • Two calls in one PowerShell process passed under both shells. A synthetic volume-GUID package path worked on upstream but failed on the earlier PR head; the final head preserves the safe sibling and refuses a nested destination under both shells. A volume-root boundary control also passed.
  • out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py and git diff --check — passed.
  • . .\tools\dev.ps1; cmake --build --preset pr; ctest --preset pr --no-tests=error — build passed and 36 tests passed at d60a292a, with four min-LOD WARP skips. dev.ps1 reported vswhere.exe unavailable on PATH; the configured build completed. At the final head, ctest --preset pr -N -R '^startup_stage_package$' selected the staging test, and ctest --preset pr --no-tests=error passed 37 tests with the same four skips.

Evidence and follow-up

The fixture creates only synthetic files and junctions. The resolution uses Windows directory handles and GetFinalPathNameByHandleW; the documented network-share limitation is noted in the run instructions. No title or GPU hardware behavior was tested.

AI-assisted.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5512769404 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2872). Originally posted by [louisdibiasi](https://github.com/louisdibiasi) on 2026-11-26T15:26:41Z. --- ## Change `stage_package.ps1` checks package and destination paths by their spelling. If the package is named through a `subst` drive or directory junction and the destination uses the underlying path, it can stage inside the package even though the helper promises to keep the destination separate. An executable spelled inside the package can also resolve through a junction to a file outside it. Compare resolved Windows paths for the package, executable and the destination's nearest existing ancestor before writing. Preserve drive-root separators, and keep the existing destination reparse-point and nonempty-directory checks. If Windows cannot resolve a path, staging stops; normalized-path queries can fail on some SMB shares. The comparison is not a defense against a concurrent change to the filesystem between the check and copy. Add the staging check to the Windows PR preset so the regression runs in PR CI. #2827 adds a runtime build preset in a separate section of the same file. ## Verification Windows, base `b505c32b`, final head `9ca04115`: - `out\pe-env\Scripts\python.exe -B tests\startup_stage_package_check.py powershell.exe` and the same command with `pwsh.exe` — passed. The synthetic junction controls refuse a destination inside the package through an alias and an executable outside it through a junction, and allow a separate destination and an executable reached through a junction that stays inside the package. A volume-GUID path is also checked against a nested destination and a safe sibling; that control explicitly skips if the temporary volume has no GUID path. On upstream the package-alias control staged inside the package; a separate synthetic source-junction check also staged the outside executable. - A temporary `subst` mapping to a synthetic package reproduced the destination bypass on upstream. With the patch, both shells refused that nested destination and a physical drive-root alias, and staged to a separate sibling. The test mapping was removed. Network shares and concurrent path changes were not tested. - Two calls in one PowerShell process passed under both shells. A synthetic volume-GUID package path worked on upstream but failed on the earlier PR head; the final head preserves the safe sibling and refuses a nested destination under both shells. A volume-root boundary control also passed. - `out\pe-env\Scripts\python.exe -B tests\bidi_controls_check.py` and `git diff --check` — passed. - `. .\tools\dev.ps1; cmake --build --preset pr; ctest --preset pr --no-tests=error` — build passed and 36 tests passed at `d60a292a`, with four min-LOD WARP skips. `dev.ps1` reported `vswhere.exe` unavailable on PATH; the configured build completed. At the final head, `ctest --preset pr -N -R '^startup_stage_package$'` selected the staging test, and `ctest --preset pr --no-tests=error` passed 37 tests with the same four skips. ## Evidence and follow-up The fixture creates only synthetic files and junctions. The resolution uses Windows directory handles and [`GetFinalPathNameByHandleW`](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfinalpathnamebyhandlew); the documented network-share limitation is noted in the run instructions. No title or GPU hardware behavior was tested. AI-assisted. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets.
KelboLive commented 2026-11-26 20:24:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-26T20:24:43Z.

Review: COMMENTED


startup: compare resolved staging paths

Clear and focused change. Comparing resolved staging paths helps ensure that paths with different normalizations (e.g., trailing slashes, .. components, mixed separators) are treated consistently.

Observations

  • Small scope (129 lines) — documentation/tooling change, easy to review
  • 0 comments — fresh PR, no maintainer feedback yet
  • Changes to path comparison logic should be checked for edge cases:
    • Paths with mixed forward/back slashes
    • Paths with . or .. components
    • Case sensitivity on Windows (should be case-insensitive)

Questions

  • What was the real-world trigger for this change? Were two staging paths resolving differently?

Verdict: Easy to review. Recommend looking for edge cases in path normalization and verifying the new comparison handles Windows-style paths consistently.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6080121340 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2872#pullrequestreview-6080121340). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-26T20:24:43Z. **Review:** COMMENTED --- **startup: compare resolved staging paths** Clear and focused change. Comparing resolved staging paths helps ensure that paths with different normalizations (e.g., trailing slashes, `..` components, mixed separators) are treated consistently. ### Observations - Small scope (129 lines) — documentation/tooling change, easy to review - 0 comments — fresh PR, no maintainer feedback yet - Changes to path comparison logic should be checked for edge cases: - Paths with mixed forward/back slashes - Paths with `.` or `..` components - Case sensitivity on Windows (should be case-insensitive) ### Questions - What was the real-world trigger for this change? Were two staging paths resolving differently? **Verdict:** Easy to review. Recommend looking for edge cases in path normalization and verifying the new comparison handles Windows-style paths consistently.
pigalot commented 2026-11-27 19:54:48 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T19:54:48Z.

Review: COMMENTED


I tried to review dbec99b0 over current main 454fc0ed. The trial merge conflicts in CMakePresets.json. Since this PR's base e446b072, main has added the page-run fixtures to the pr preset (0cfdd607, merged in 104617d6), and this PR edits the same test-filter line. The resolution should keep both additions.

I'll review it once it is updated with main.

This reply was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6092819804 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2872#pullrequestreview-6092819804). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-27T19:54:48Z. **Review:** COMMENTED --- I tried to review `dbec99b0` over current `main` `454fc0ed`. The trial merge conflicts in `CMakePresets.json`. Since this PR's base `e446b072`, `main` has added the page-run fixtures to the `pr` preset (`0cfdd607`, merged in `104617d6`), and this PR edits the same test-filter line. The resolution should keep both additions. I'll review it once it is updated with `main`. This reply was AI-assisted.
pigalot commented 2026-11-28 02:43:06 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-28T02:43:06Z.


I merged main (fdb6faaa) into this branch as 7b7efadf, a plain merge commit with no rebase or force-push. It conflicted with main.

Conflict: CMakePresets.json, the pr test preset filter. main had added xmem_(run_break_readers|…), startup_dstorage_break_window, xmem_page_runs_device(_join)?_warp and linear_buffer_backing_share_warp. I kept main's filter and appended this branch's startup_stage_package at the end, which is the same change as before. The file still parses as JSON. git diff --check origin/main...HEAD is clean, and the net diff against main is this branch's 4 files.

What I ran on 7b7efadf. I did a full build in dev and release, then ran

ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^startup_(stage_package|launch|tools_lint|run_ps1)$'
ctest --preset pr --no-tests=error -j 4
  • Named tests: 4 of 4 pass in each preset.
  • pr preset: 53 of 70 pass, including startup_stage_package. The other 17 return 77 (capability skip): 14 spirv_*_warp and 3 xmem_placeholder_split_*.

A different reviewer will re-review the merged head.

Environment: AMD Ryzen 7 9800X3D, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10, WARP 10.0.26100.9818.

This reply was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7232548651 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2872#issuecomment-7232548651). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-28T02:43:06Z. --- I merged `main` (`fdb6faaa`) into this branch as `7b7efadf`, a plain merge commit with no rebase or force-push. It conflicted with `main`. **Conflict:** `CMakePresets.json`, the `pr` test preset filter. `main` had added `xmem_(run_break_readers|…)`, `startup_dstorage_break_window`, `xmem_page_runs_device(_join)?_warp` and `linear_buffer_backing_share_warp`. I kept `main`'s filter and appended this branch's `startup_stage_package` at the end, which is the same change as before. The file still parses as JSON. `git diff --check origin/main...HEAD` is clean, and the net diff against `main` is this branch's 4 files. **What I ran on `7b7efadf`.** I did a full build in `dev` and `release`, then ran ```powershell ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^startup_(stage_package|launch|tools_lint|run_ps1)$' ctest --preset pr --no-tests=error -j 4 ``` - **Named tests:** 4 of 4 pass in each preset. - **`pr` preset:** 53 of 70 pass, including `startup_stage_package`. The other 17 return 77 (capability skip): 14 `spirv_*_warp` and 3 `xmem_placeholder_split_*`. A different reviewer will re-review the merged head. Environment: AMD Ryzen 7 9800X3D, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10, WARP 10.0.26100.9818. This reply was AI-assisted.
R0Y00 commented 2026-11-28 03:00:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-28T03:00:52Z.

Review: APPROVED


Reviewed 7b7efadf8e with main c827d8ba (integrated tree 830ee58dbc). The current PR preset keeps the earlier main test groups and includes startup_stage_package. The source, package, and nearest existing staging ancestor are resolved before directory creation. Existing reparse-point and nonempty-directory checks are retained. The documented limits for SMB path resolution and concurrent filesystem changes match the implementation.

On Windows 11 26200.9974 both synthetic staging runs passed, including package preservation and the path guards. The launcher text control passed. No game files were involved.

python -B tests/startup_stage_package_check.py powershell.exe
python -B tests/startup_stage_package_check.py pwsh.exe
python -B tests/startup_run_ps1_check.py --text-only

The required hosted Windows CI job and the Linux Python and gfx1013 checks passed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6095311807 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2872#pullrequestreview-6095311807). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-28T03:00:52Z. **Review:** APPROVED --- Reviewed 7b7efadf8eeb with main c827d8ba (integrated tree 830ee58dbc6918f6e289a3c8e3d528626fa78908). The current PR preset keeps the earlier main test groups and includes startup_stage_package. The source, package, and nearest existing staging ancestor are resolved before directory creation. Existing reparse-point and nonempty-directory checks are retained. The documented limits for SMB path resolution and concurrent filesystem changes match the implementation. On Windows 11 26200.9974 both synthetic staging runs passed, including package preservation and the path guards. The launcher text control passed. No game files were involved. ``` python -B tests/startup_stage_package_check.py powershell.exe python -B tests/startup_stage_package_check.py pwsh.exe python -B tests/startup_run_ps1_check.py --text-only ``` The required hosted Windows CI job and the Linux Python and gfx1013 checks passed.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2864
No description provided.