App: keep run paths stable when the title changes directory #2677

Closed
github-bot wants to merge 2 commits from github-bot/gh-2677 into main AGit
Owner

@⁠jaschinski97-ops on GitHub · 2026-11-25 17:59 UTC · original
jaschinski97-ops:fix/windows-launch-paths → main · +91 −3 · 3 files · 2 commits · closed without merging

A title changing the process current directory can redirect relative executable/DLL lookups, caches and persistent writes. Resolve the runner-owned executable, cache and data roots to absolute paths once before title code executes. Relative paths retain their launch-directory meaning; destinations need not exist yet.

The refresh to main63bcca43 preserves its early low-memory guards before loading configuration and anchoring paths. This stays separate from #1798's content-folder search. FidelityFX already resolves/loads synchronously before title execution and needs no change here.

Validation:

  • All19 app tests and strict all-target/all-feature Clippy pass locally on the refreshed headbe908d7.
  • The child-process regression changes real CWD in isolation, checks file lookups/cache/storage/saves and fails with identity behavior. It requires no C compiler; this committed test does not execute a PE/DLL.
  • Separate compiled no-CRT program/DLL controls reproduce the relative-executable, cache and data failures on the earlier main. Reproducible source.
  • Combined MSVC release source08b4585 passes19 app,156 HLE and35 loader tests in Windows CI. The downloaded release passes all4 native DLL/storage path cases and all6 status-return cases on Windows11.
  • Latest headbe908d7 passes Windows MSVC workspace CI. Same-source GNU/MSVC exit control confirms the earlier baseline shutdown panic is specific to our GNU build; the supported MSVC release needs no #1996 workaround.

Claim registration corrects parser rejection of the earlier wording. Rebase reply.
AI-assisted with Codex: separate implementation, coordinator review and independent agent review; external Windows reviewers also verified the original path regression. Synthetic programs only, no GPU/game data. No game-start or performance claim.

**@⁠jaschinski97-ops** on GitHub · 2026-11-25 17:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/2677) `jaschinski97-ops:fix/windows-launch-paths` → `main` · +91 −3 · 3 files · 2 commits · closed without merging A title changing the process current directory can redirect relative executable/DLL lookups, caches and persistent writes. Resolve the runner-owned executable, cache and data roots to absolute paths once before title code executes. Relative paths retain their launch-directory meaning; destinations need not exist yet. The refresh to main63bcca43 preserves its early low-memory guards before loading configuration and anchoring paths. This stays separate from #1798's content-folder search. FidelityFX already resolves/loads synchronously before title execution and needs no change here. Validation: - All19 app tests and strict all-target/all-feature Clippy pass locally on the refreshed headbe908d7. - The child-process regression changes real CWD in isolation, checks file lookups/cache/storage/saves and fails with identity behavior. It requires no C compiler; this committed test does not execute a PE/DLL. - Separate compiled no-CRT program/DLL controls reproduce the relative-executable, cache and data failures on the earlier main. [Reproducible source](https://github.com/jaschinski97-ops/VIctory/blob/3627872/verification/windows-startup.md). - Combined MSVC release source08b4585 passes19 app,156 HLE and35 loader tests in [Windows CI](https://github.com/jaschinski97-ops/VIctory/actions/runs/45850777211). The downloaded release passes all4 native DLL/storage path cases and all6 status-return cases on Windows11. - Latest headbe908d7 passes [Windows MSVC workspace CI](https://github.com/Marvisak/VIctory/actions/runs/45850554464). [Same-source GNU/MSVC exit control](https://github.com/jaschinski97-ops/VIctory/blob/8312981/verification/windows-exit.md) confirms the earlier baseline shutdown panic is specific to our GNU build; the supported MSVC release needs no #1996 workaround. [Claim registration](https://git.gtahub.st/github/Marvisak--VIctory/issues/1633) corrects parser rejection of the earlier wording. [Rebase reply](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2677). AI-assisted with Codex: separate implementation, coordinator review and independent agent review; external Windows reviewers also verified the original path regression. Synthetic programs only, no GPU/game data. No game-start or performance claim.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:11:48 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 18:33 UTC · original

Independent verification (review, not a task claim) — covered by the existing claim on #1633.

  • PR head: f206de3a5daee81d0581fe0a6e22314d90b49c1f (OPEN, non-draft, merges cleanly; merge-base == origin/main)
  • origin/main: 13f91caee25f2fdf2c062be5f7a27f058e51cbca
  • Environment: Windows 11, VICTORY_WARP=1, VICTORY_D3D12_WARP=1, dxil.dll 1.8.2502.11 (Windows Kit 10.0.26100.0 x64), no physical GPU used (these app tests do not open a GPU), no game files, synthetic temp files only.

Commands and results

  • cargo test --locked -p victory launch_paths_survive → 1 passed, 0 failed, 0 ignored (the new test; the census integration test filtered out).
  • cargo test --locked -p victory (full crate) → unit tests 11 passed, 0 failed, 0 ignored; tests/census.rs 2 passed, 0 failed, 0 ignored.
  • cargo clippy --locked -p victory --all-targets → clean, no warnings.

Negative control

  • I replaced launch_paths with identity behaviour (no std::path::absolute on the executable, cache dir or data dir). launch_paths_survive_a_title_changing_the_current_directory FAILED (parent and child panic, 0 passed, 1 failed). Restored, it passes.

Review notes

  • The change is minimal: the runner-owned executable, cache dir and data dir are made absolute once, before title code runs, and the rest of run uses the anchored values (set_image_path and read take the new exe). std::path::absolute does not need the paths to exist and does not resolve symlinks, which matches the stated "relative to the launch directory" semantics.
  • The test is well isolated: the CWD change happens in a re-executed child process with an env-var guard, so parallel tests are unaffected. It checks real cache, storage and saves destinations plus the late-DLL lookup, and asserts that no shifted elsewhere/cache or elsewhere/data tree appears. The test module is cfg(all(test, windows)), matching launch_paths, so non-Windows builds are not affected.
  • tempfile is added only as a dev-dependency (Cargo.lock change is one line, and --locked accepts it).
  • I did not run the PR's separate no-CRT EXE/DLL probe, so I make no claim about PE/DLL execution. I found no bugs.

AI disclosure: independent verification by Claude Code (Claude Sonnet 5.5).

**@⁠oni-swr** on GitHub · 2026-11-25 18:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/2677#issuecomment-7171065018) **Independent verification (review, not a task claim)** — covered by the existing claim on #1633. - PR head: `f206de3a5daee81d0581fe0a6e22314d90b49c1f` (OPEN, non-draft, merges cleanly; merge-base == `origin/main`) - `origin/main`: `13f91caee25f2fdf2c062be5f7a27f058e51cbca` - Environment: Windows 11, `VICTORY_WARP=1`, `VICTORY_D3D12_WARP=1`, `dxil.dll` 1.8.2502.11 (Windows Kit 10.0.26100.0 x64), no physical GPU used (these app tests do not open a GPU), no game files, synthetic temp files only. **Commands and results** - `cargo test --locked -p victory launch_paths_survive` → 1 passed, 0 failed, 0 ignored (the new test; the `census` integration test filtered out). - `cargo test --locked -p victory` (full crate) → unit tests 11 passed, 0 failed, 0 ignored; `tests/census.rs` 2 passed, 0 failed, 0 ignored. - `cargo clippy --locked -p victory --all-targets` → clean, no warnings. **Negative control** - I replaced `launch_paths` with identity behaviour (no `std::path::absolute` on the executable, cache dir or data dir). `launch_paths_survive_a_title_changing_the_current_directory` FAILED (parent and child panic, 0 passed, 1 failed). Restored, it passes. **Review notes** - The change is minimal: the runner-owned executable, cache dir and data dir are made absolute once, before title code runs, and the rest of `run` uses the anchored values (`set_image_path` and `read` take the new `exe`). `std::path::absolute` does not need the paths to exist and does not resolve symlinks, which matches the stated "relative to the launch directory" semantics. - The test is well isolated: the CWD change happens in a re-executed child process with an env-var guard, so parallel tests are unaffected. It checks real cache, storage and saves destinations plus the late-DLL lookup, and asserts that no shifted `elsewhere/cache` or `elsewhere/data` tree appears. The test module is `cfg(all(test, windows))`, matching `launch_paths`, so non-Windows builds are not affected. - `tempfile` is added only as a dev-dependency (`Cargo.lock` change is one line, and `--locked` accepts it). - I did not run the PR's separate no-CRT EXE/DLL probe, so I make no claim about PE/DLL execution. I found no bugs. AI disclosure: independent verification by Claude Code (Claude Sonnet 5.5).
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 18:35 UTC · original

Real hazard, clean fix - std::path::absolute normalizes without requiring existence (unlike canonicalize), so cache/data dirs that don't exist yet still resolve relative to launch. The child-process CWD test is a nice way to cover this without poisoning parallel tests. One note: launch_paths is cfg(windows) but called unconditionally from run() - fine today since this app is Windows-only, worth a non-Windows passthrough or comment if a port ever lands.

**@⁠kotekompotek** on GitHub · 2026-11-25 18:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2677#issuecomment-7171122024) Real hazard, clean fix - std::path::absolute normalizes without requiring existence (unlike canonicalize), so cache/data dirs that don't exist yet still resolve relative to launch. The child-process CWD test is a nice way to cover this without poisoning parallel tests. One note: launch_paths is cfg(windows) but called unconditionally from run() - fine today since this app is Windows-only, worth a non-Windows passthrough or comment if a port ever lands.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 18:57 UTC · original

Independent Windows 11 verification and code review of f206de3a (on 13f91ca):

Verification (rustc 1.98.1 MSVC)

  • cargo clippy --locked -p victory --all-targets -- -D warnings and --all-features: 0 warnings.
  • cargo test --locked -p victory: 11 passed (unit, including launch_paths_survive_a_title_changing_the_current_directory), 2 passed (tests/census.rs).

Review Notes

  • Anchoring exe, cfg.cache_dir, and cfg.data_dir via std::path::absolute before spawn_main cleanly keeps title_dir, LateDlls, G:/T: mounts, shaders cache, storage/saves, and crashes.log immune to title SetCurrentDirectory calls, without requiring directories to pre-exist (and preserving UNC paths).
  • Two minor non-blocking notes:
    • Diagnostic env vars read lazily later (VICTORY_CAPTURE in crates/victory-gpu/src/capture.rs and VICTORY_XMA_DUMP in crates/victory-hle/src/modules/audio.rs) still resolve relative paths against the live CWD if not anchored at startup.
    • launch_paths is gated #[cfg(windows)] while pub fn run is un-gated, which is fine today (the run module itself is Windows-only) and only worth keeping aligned if cross-platform builds (e.g. #2670) compile it.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 18:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/2677#issuecomment-7171623424) Independent Windows 11 verification and code review of `f206de3a` (on `13f91ca`): ### Verification (`rustc 1.98.1` MSVC) - `cargo clippy --locked -p victory --all-targets -- -D warnings` and `--all-features`: **0 warnings**. - `cargo test --locked -p victory`: **11 passed** (unit, including `launch_paths_survive_a_title_changing_the_current_directory`), **2 passed** (`tests/census.rs`). ### Review Notes - Anchoring `exe`, `cfg.cache_dir`, and `cfg.data_dir` via `std::path::absolute` before `spawn_main` cleanly keeps `title_dir`, `LateDlls`, `G:`/`T:` mounts, `shaders` cache, `storage`/`saves`, and `crashes.log` immune to title `SetCurrentDirectory` calls, without requiring directories to pre-exist (and preserving UNC paths). - Two minor non-blocking notes: - Diagnostic env vars read lazily later (`VICTORY_CAPTURE` in `crates/victory-gpu/src/capture.rs` and `VICTORY_XMA_DUMP` in `crates/victory-hle/src/modules/audio.rs`) still resolve relative paths against the live CWD if not anchored at startup. - `launch_paths` is gated `#[cfg(windows)]` while `pub fn run` is un-gated, which is fine today (the `run` module itself is Windows-only) and only worth keeping aligned if cross-platform builds (e.g. #2670) compile it.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:16 UTC · original

Automated triage for the maintainers.

This PR no longer merges cleanly into main (f3578e3): apps/victory/src/run.rs conflicts with changes that landed on main. It will be reviewed once it is rebased.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/2677#issuecomment-7176163043) <!-- victory-triage v1 head=f206de3a5daee81d0581fe0a6e22314d90b49c1f verdict=needs-rebase at=2026-11-25T22:15:11Z --> Automated triage for the maintainers. This PR no longer merges cleanly into `main` (f3578e3): `apps/victory/src/run.rs` conflicts with changes that landed on `main`. It will be reviewed once it is rebased. --- _Generated by [Claude Code](https://claude.ai/code)_
# Conflicts:
#	apps/victory/src/run.rs
Author
Owner

@⁠jaschinski97-ops on GitHub · 2026-11-26 15:35 UTC · original

Updated to current main 63bcca43 in head be908d79b1fbf076b109188c9f59823947495744. The conflict is resolved by keeping the new early low-memory guards before launch_paths(Config::load()). All 19 app tests and strict all-target/all-feature Clippy pass locally; new Windows MSVC CI is running. The earlier needs-rebase triage is addressed. Thank you for the independent path/CWD verification. No new GPU tests or game files.

**@⁠jaschinski97-ops** on GitHub · 2026-11-26 15:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2677#issuecomment-7196471846) Updated to current main `63bcca43` in head `be908d79b1fbf076b109188c9f59823947495744`. The conflict is resolved by keeping the new early low-memory guards before `launch_paths(Config::load())`. All 19 app tests and strict all-target/all-feature Clippy pass locally; new Windows MSVC CI is running. The earlier needs-rebase triage is addressed. Thank you for the independent path/CWD verification. No new GPU tests or game files.
github-bot closed this pull request 2026-11-26 18:12:19 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2677
No description provided.