Skip to content

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

Closed
jaschinski97-ops wants to merge 2 commits into
Marvisak:mainfrom
jaschinski97-ops:fix/windows-launch-paths
Closed

jaschinski97-ops wants to merge 2 commits into
Marvisak:mainfrom
jaschinski97-ops:fix/windows-launch-paths

Conversation

@jaschinski97-ops

@jaschinski97-ops jaschinski97-ops commented Nov 25, 2026 •

Copy link
Copy Markdown

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 Loader: handle thread spawn failure in detach_all without panicking #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.

@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown

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).

@kotekompotek

Copy link
Copy Markdown

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.

@fuzeofficlal

Copy link
Copy Markdown
Contributor

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. Build and test on Linux; a CI job keeps it so; VICTORY_LOG_FILE #2670) compile it.

Copy link
Copy Markdown
Owner

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

# Conflicts:
#	apps/victory/src/run.rs
@jaschinski97-ops

Copy link
Copy Markdown
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants