HLE: relaunch arguments split by the C runtime's rules #2613

Open
c4k3ss wants to merge 1 commit from upstream-pr/2615 into main
c4k3ss commented 2026-11-25 16:56:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by c4k3ss on 2026-11-25T16:56:12Z.


What

split_args (from #455) splits the argument line a title hands to XLaunchNewGame into the pieces lifecycle::relaunch passes through Command::args. It toggled quoting at every " and kept every backslash, so an argument line meant as a Windows command line reached the relaunched title changed: -json={\"a\":1} -y became -json={\a\:1} and -y, and a\\\"b c became one argument.

The splitter now follows the rules the title's C runtime parses argv with ("Parsing C++ command-line arguments", Microsoft Learn): 2n backslashes before a " are n backslashes and the quote delimits; 2n + 1 are n backslashes and a literal "; other backslashes are literal; inside quotes "" is a literal " and quoting goes on; only a space or a tab separates arguments, so a line that is other whitespace is one argument and is still passed. The two cases #455 covered (quoted paths, empty arguments, O'Brien) behave as before.

AI-assisted (Claude Code); reviewed by a second tool and by hand.

Tested

  • cargo test -p victory-hle --lib: 148 passed, 0 failed (Windows 11, Rust 1.98.1). The new relaunch_args_split_as_the_c_runtime_does holds 19 lines whose expected argv was taken from a real UCRT process on this machine (a Python interpreter printing sys.argv); a_relaunch_preserves_literal_whitespace_arguments covers the line-level check. The two existing relaunch tests still pass.
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.
  • cargo xtask policy: ok. No game files or data from them were added.
  • git diff --check: clean. cargo fmt --check reports pre-existing differences elsewhere in the crate; no unrelated formatting changes are included.
  • Not tested: a real title's XLaunchNewGame call; as with #455, the regression is at the argument-building layer.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6609433662 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2615). Originally posted by [c4k3ss](https://github.com/c4k3ss) on 2026-11-25T16:56:12Z. --- ## What `split_args` (from #455) splits the argument line a title hands to `XLaunchNewGame` into the pieces `lifecycle::relaunch` passes through `Command::args`. It toggled quoting at every `"` and kept every backslash, so an argument line meant as a Windows command line reached the relaunched title changed: `-json={\"a\":1} -y` became `-json={\a\:1}` and `-y`, and `a\\\"b c` became one argument. The splitter now follows the rules the title's C runtime parses argv with ("Parsing C++ command-line arguments", Microsoft Learn): `2n` backslashes before a `"` are `n` backslashes and the quote delimits; `2n + 1` are `n` backslashes and a literal `"`; other backslashes are literal; inside quotes `""` is a literal `"` and quoting goes on; only a space or a tab separates arguments, so a line that is other whitespace is one argument and is still passed. The two cases #455 covered (quoted paths, empty arguments, `O'Brien`) behave as before. AI-assisted (Claude Code); reviewed by a second tool and by hand. ## Tested - `cargo test -p victory-hle --lib`: 148 passed, 0 failed (Windows 11, Rust 1.98.1). The new `relaunch_args_split_as_the_c_runtime_does` holds 19 lines whose expected argv was taken from a real UCRT process on this machine (a Python interpreter printing `sys.argv`); `a_relaunch_preserves_literal_whitespace_arguments` covers the line-level check. The two existing relaunch tests still pass. - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. - `cargo xtask policy`: ok. No game files or data from them were added. - `git diff --check`: clean. `cargo fmt --check` reports pre-existing differences elsewhere in the crate; no unrelated formatting changes are included. - Not tested: a real title's `XLaunchNewGame` call; as with #455, the regression is at the argument-building layer.
shadow9owo commented 2026-11-25 18:02:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by shadow9owo on 2026-11-25T17:20:53Z.


C (lang) is not runtime dependent did you mean C++?

<!-- greyfinch-sync:Marvisak/VIctory:comment:7169372200 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2615#issuecomment-7169372200). Originally posted by [shadow9owo](https://github.com/shadow9owo) on 2026-11-25T17:20:53Z. --- C (lang) is not runtime dependent did you mean C++?
kotekompotek commented 2026-11-25 18:02:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T17:43:52Z.


Reviewed the splitter against the UCRT rules: 2n backslashes before a quote emit n and leave the quote to toggle, 2n+1 emit n plus a literal quote; "" inside quotes is a literal; only space/tab separate. Implementation matches all three cases (odd count consumes the quote as literal; even count leaves it for the next loop iteration). Verified-by-UCRT test cases are a nice touch. CI green.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7169918685 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2615#issuecomment-7169918685). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T17:43:52Z. --- Reviewed the splitter against the UCRT rules: `2n` backslashes before a quote emit `n` and leave the quote to toggle, `2n+1` emit `n` plus a literal quote; `""` inside quotes is a literal; only space/tab separate. Implementation matches all three cases (odd count consumes the quote as literal; even count leaves it for the next loop iteration). Verified-by-UCRT test cases are a nice touch. CI green.
c4k3ss commented 2026-11-25 18:02:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by c4k3ss on 2026-11-25T17:54:54Z.


"C runtime" here is Microsoft's C runtime library (the UCRT), not the language: it is the code that turns the command line into argv for every C and C++ program on Windows, and these are its rules (Microsoft Learn, "Parsing C++ command-line arguments").

<!-- greyfinch-sync:Marvisak/VIctory:comment:7170176346 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2615#issuecomment-7170176346). Originally posted by [c4k3ss](https://github.com/c4k3ss) on 2026-11-25T17:54:54Z. --- "C runtime" here is Microsoft's C runtime library (the UCRT), not the language: it is the code that turns the command line into argv for every C and C++ program on Windows, and these are its rules (Microsoft Learn, "Parsing C++ command-line arguments").
Marvisak commented 2026-11-25 23:06:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:17:21Z.


Automated triage for the maintainers.

Recommended for a maintainer's look. split_args in crates/victory-hle/src/modules/xgame.rs now follows the documented Microsoft C runtime argv rules (2n / 2n+1 backslashes before a quote, "" inside quotes, only space and tab separating), so a relaunch line such as -json={\"a\":1} reaches the relaunched title as meant; the old splitter kept every backslash and toggled on every quote. I traced the new loop through the test table (including the """ x / """" x cases) and it matches the stated rules; the relaunch_args emptiness check now uses the same separators. One file, merges cleanly, CI check passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176174817 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2615#issuecomment-7176174817). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:17:21Z. --- <!-- victory-triage v1 head=afbbe9f0b3e1c4fff128e88e056b4e682804bbd5 verdict=merge-candidate at=2026-11-25T22:19:00Z --> Automated triage for the maintainers. Recommended for a maintainer's look. `split_args` in `crates/victory-hle/src/modules/xgame.rs` now follows the documented Microsoft C runtime argv rules (2n / 2n+1 backslashes before a quote, `""` inside quotes, only space and tab separating), so a relaunch line such as `-json={\"a\":1}` reaches the relaunched title as meant; the old splitter kept every backslash and toggled on every quote. I traced the new loop through the test table (including the `""" x` / `"""" x` cases) and it matches the stated rules; the `relaunch_args` emptiness check now uses the same separators. One file, merges cleanly, CI `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
futurepro62 commented 2026-11-26 02:07:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T01:25:54Z.


Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head afbbe9f (on its base 67e8ae1).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 775 passed, 0 failed, 9 ignored.
  • The new tests ran and passed: relaunch_args_split_as_the_c_runtime_does, a_relaunch_preserves_literal_whitespace_arguments.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7179765857 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2615#issuecomment-7179765857). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T01:25:54Z. --- Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head `afbbe9f` (on its base `67e8ae1`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **775 passed, 0 failed, 9 ignored**. - The new tests ran and passed: `relaunch_args_split_as_the_c_runtime_does`, `a_relaunch_preserves_literal_whitespace_arguments`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
cloph-dsp commented 2026-11-26 16:05:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T15:40:20Z.


Independent local verification of PR #2615 (head afbbe9f0b3e1c4fff128e88e056b4e682804bbd5), Windows / Rust 1.100.0 MSVC, per-worktree CARGO_TARGET_DIR=D:\Victory-Contrib\target-2615, no game data.

  • cargo test --locked -p victory-hle --lib -- modules::xgame::tests::relaunch_args_split_as_the_c_runtime_does --exact --quiet → 1 passed, 0 failed, 147 filtered, exit 0.
  • cargo test --locked -p victory-hle --lib -- modules::xgame::tests::a_relaunch_preserves_literal_whitespace_arguments --exact --quiet → 1 passed, 0 failed, 147 filtered, exit 0.
  • Both new test names are absent from the merge base 67e8ae14 (negative control).
  • git diff --check 67e8ae14..HEAD → exit 0.

I did not exercise a real relaunch with a title or UCRT edge cases beyond the committed synthetic cases. CPU-only; GPU/driver N/A. AI-assisted (Hy4 flash).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7196591548 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2615#issuecomment-7196591548). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-26T15:40:20Z. --- Independent local verification of PR #2615 (head `afbbe9f0b3e1c4fff128e88e056b4e682804bbd5`), Windows / Rust 1.100.0 MSVC, per-worktree `CARGO_TARGET_DIR=D:\Victory-Contrib\target-2615`, no game data. - `cargo test --locked -p victory-hle --lib -- modules::xgame::tests::relaunch_args_split_as_the_c_runtime_does --exact --quiet` → 1 passed, 0 failed, 147 filtered, exit 0. - `cargo test --locked -p victory-hle --lib -- modules::xgame::tests::a_relaunch_preserves_literal_whitespace_arguments --exact --quiet` → 1 passed, 0 failed, 147 filtered, exit 0. - Both new test names are absent from the merge base `67e8ae14` (negative control). - `git diff --check 67e8ae14..HEAD` → exit 0. I did not exercise a real relaunch with a title or UCRT edge cases beyond the committed synthetic cases. CPU-only; GPU/driver N/A. AI-assisted (Hy4 flash).
fuzeofficlal commented 2026-11-26 16:05:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T16:05:29Z.

Review: APPROVED


Reviewed afbbe9f0b3e1c4fff128e88e056b4e682804bbd5 (merged cleanly onto 63bcca43c6a00a758510398fa43096ce7e4f7df0) and verified on Windows 11 x64 (rustc 1.98.1 MSVC).

Audit

  • crates/victory-hle/src/modules/xgame.rs:118, :134, :160, :166:
    • args is strictly the argv[1..] tail passed separately from exe, so UCRT's argv[1..] quoting/escaping rules (not argv[0]'s special rule) are the exact semantics needed.
    • Backslash runs before " (2n -> n backslashes + delimiter, 2n + 1 -> n backslashes + literal "), doubled "" inside quotes (including right after an even backslash run such as "a\\""b"), empty quoted arguments, and restricting separators to ' ' / '\t' (consistent with relaunch_args's trim_matches([' ', '\t'])) all match Microsoft's UCRT parse_command_line rules.

Verification

  • Clean merge onto 63bcca43c6a00a758510398fa43096ce7e4f7df0 + cargo run -p xtask -- policy (191 files ok)
  • cargo clippy -p victory-hle --all-targets -- -D warnings (default & --all-features)
  • cargo test -p victory-hle --lib -- modules::xgame::: 5/5 passed (including relaunch_args_split_as_the_c_runtime_does and a_relaunch_preserves_literal_whitespace_arguments).
  • Differential-tested split_args directly against live Windows 11 UCRT argv parsing (spawning a UCRT process with CommandExt::raw_arg) across 35 edge cases (1–7 consecutive quotes, "" after even/odd backslash runs like "a\\""b" and "\\""" x, a""b / a"""b, trailing backslashes, \n/\r/\u{b}/\u{c}/\u{a0}, unterminated quotes, single quotes): 35/35 exact matches.
<!-- greyfinch-sync:Marvisak/VIctory:review:6077244887 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2615#pullrequestreview-6077244887). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T16:05:29Z. **Review:** APPROVED --- Reviewed `afbbe9f0b3e1c4fff128e88e056b4e682804bbd5` (merged cleanly onto `63bcca43c6a00a758510398fa43096ce7e4f7df0`) and verified on Windows 11 x64 (`rustc 1.98.1` MSVC). ### Audit - `crates/victory-hle/src/modules/xgame.rs:118`, `:134`, `:160`, `:166`: - `args` is strictly the `argv[1..]` tail passed separately from `exe`, so UCRT's `argv[1..]` quoting/escaping rules (not `argv[0]`'s special rule) are the exact semantics needed. - Backslash runs before `"` (`2n` -> `n` backslashes + delimiter, `2n + 1` -> `n` backslashes + literal `"`), doubled `""` inside quotes (including right after an even backslash run such as `"a\\""b"`), empty quoted arguments, and restricting separators to `' '` / `'\t'` (consistent with `relaunch_args`'s `trim_matches([' ', '\t'])`) all match Microsoft's UCRT `parse_command_line` rules. ### Verification - Clean merge onto `63bcca43c6a00a758510398fa43096ce7e4f7df0` + `cargo run -p xtask -- policy` (`191 files ok`) - `cargo clippy -p victory-hle --all-targets -- -D warnings` (default & `--all-features`) - `cargo test -p victory-hle --lib -- modules::xgame::`: **5/5 passed** (including `relaunch_args_split_as_the_c_runtime_does` and `a_relaunch_preserves_literal_whitespace_arguments`). - Differential-tested `split_args` directly against live Windows 11 UCRT `argv` parsing (spawning a UCRT process with `CommandExt::raw_arg`) across 35 edge cases (1–7 consecutive quotes, `""` after even/odd backslash runs like `"a\\""b"` and `"\\""" x`, `a""b` / `a"""b`, trailing backslashes, `\n`/`\r`/`\u{b}`/`\u{c}`/`\u{a0}`, unterminated quotes, single quotes): **35/35 exact matches**.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2615:upstream-pr/2615'
git switch 'upstream-pr/2615'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2615'
git switch 'upstream-pr/2615'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2615'
git switch 'upstream-pr/2615'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2615'
git switch 'main'
git merge --squash 'upstream-pr/2615'
git switch 'main'
git merge --ff-only 'upstream-pr/2615'
git switch 'main'
git merge 'upstream-pr/2615'
git push origin 'main'
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
Marvisak/VIctory!2613
No description provided.