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

Open
github-bot wants to merge 1 commit from github-bot/gh-2615 into main AGit
Owner

@⁠c4k3ss on GitHub · 2026-11-25 16:56 UTC · original
c4k3ss:hle/relaunch-args-crt-rules → main · +80 −7 · 1 files · 1 commits · open

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.
**@⁠c4k3ss** on GitHub · 2026-11-25 16:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/2615) `c4k3ss:hle/relaunch-args-crt-rules` → `main` · +80 −7 · 1 files · 1 commits · open ## 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.
`split_args` toggled quoting at every `"` and kept every backslash, so an
XLaunchNewGame argument line such as `-json={\"a\":1}` reached the
relaunched title as `-json={\a\:1}` and `a\\\"b c` as one argument. The
splitter now follows the rules the title's C runtime parses argv with:
`2n` backslashes before a quote are `n` backslashes and the quote
delimits, `2n + 1` are `n` backslashes and a literal quote, other
backslashes are literal, and `""` inside quotes is a literal quote with
quoting kept.

A test holds ten lines with the argv a UCRT process receives for each.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:10:23 +00:00
Author
Owner

@⁠shadow9owo on GitHub · 2026-11-25 17:20 UTC · original

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

**@⁠shadow9owo** on GitHub · 2026-11-25 17:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2615#issuecomment-7169372200) C (lang) is not runtime dependent did you mean C++?
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 17:43 UTC · original

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.

**@⁠kotekompotek** on GitHub · 2026-11-25 17:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/2615#issuecomment-7169918685) 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.
Author
Owner

@⁠c4k3ss on GitHub · 2026-11-25 17:54 UTC · original

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

**@⁠c4k3ss** on GitHub · 2026-11-25 17:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/2615#issuecomment-7170176346) "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").
Author
Owner

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

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

**@⁠Marvisak** on GitHub · 2026-11-25 22:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/2615#issuecomment-7176174817) <!-- 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)_
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-26 01:25 UTC · original

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.
**@⁠futurepro62** on GitHub · 2026-11-26 01:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/2615#issuecomment-7179765857) 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.
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-26 15:40 UTC · original

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

**@⁠cloph-dsp** on GitHub · 2026-11-26 15:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/2615#issuecomment-7196591548) 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).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 16:05 UTC · original · approved these changes

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.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 16:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/2615#pullrequestreview-6077244887) · **approved these changes** 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 can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2615/head:github-bot/gh-2615'
git switch 'github-bot/gh-2615'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2615'
git switch 'github-bot/gh-2615'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2615'
git switch 'github-bot/gh-2615'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2615'
git switch 'main'
git merge --squash 'github-bot/gh-2615'
git switch 'main'
git merge --ff-only 'github-bot/gh-2615'
git switch 'main'
git merge 'github-bot/gh-2615'
git push origin 'main'
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!2615
No description provided.