HLE: relaunch arguments split by the C runtime's rules #2615
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2615
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2615"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@c4k3ss on GitHub · 2026-11-25 16:56 UTC · original
c4k3ss:hle/relaunch-args-crt-rules→main· +80 −7 · 1 files · 1 commits · openWhat
split_args(from #455) splits the argument line a title hands toXLaunchNewGameinto the pieceslifecycle::relaunchpasses throughCommand::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} -ybecame-json={\a\:1}and-y, anda\\\"b cbecame one argument.The splitter now follows the rules the title's C runtime parses argv with ("Parsing C++ command-line arguments", Microsoft Learn):
2nbackslashes before a"arenbackslashes and the quote delimits;2n + 1arenbackslashes 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 newrelaunch_args_split_as_the_c_runtime_doesholds 19 lines whose expected argv was taken from a real UCRT process on this machine (a Python interpreter printingsys.argv);a_relaunch_preserves_literal_whitespace_argumentscovers 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 --checkreports pre-existing differences elsewhere in the crate; no unrelated formatting changes are included.XLaunchNewGamecall; 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]>@shadow9owo on GitHub · 2026-11-25 17:20 UTC · original
C (lang) is not runtime dependent did you mean C++?
@kotekompotek on GitHub · 2026-11-25 17:43 UTC · original
Reviewed the splitter against the UCRT rules:
2nbackslashes before a quote emitnand leave the quote to toggle,2n+1emitnplus 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 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").
@Marvisak on GitHub · 2026-11-25 22:17 UTC · original
Automated triage for the maintainers.
Recommended for a maintainer's look.
split_argsincrates/victory-hle/src/modules/xgame.rsnow 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/"""" xcases) and it matches the stated rules; therelaunch_argsemptiness check now uses the same separators. One file, merges cleanly, CIcheckpassing.Generated by Claude Code
@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 base67e8ae1).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo 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.relaunch_args_split_as_the_c_runtime_does,a_relaunch_preserves_literal_whitespace_arguments.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#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_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
@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-worktreeCARGO_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.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 on GitHub · 2026-11-26 16:05 UTC · original · approved these changes
Reviewed
afbbe9f0b3e1c4fff128e88e056b4e682804bbd5(merged cleanly onto63bcca43c6a00a758510398fa43096ce7e4f7df0) and verified on Windows 11 x64 (rustc 1.98.1MSVC).Audit
crates/victory-hle/src/modules/xgame.rs:118,:134,:160,:166:argsis strictly theargv[1..]tail passed separately fromexe, so UCRT'sargv[1..]quoting/escaping rules (notargv[0]'s special rule) are the exact semantics needed."(2n->nbackslashes + delimiter,2n + 1->nbackslashes + literal"), doubled""inside quotes (including right after an even backslash run such as"a\\""b"), empty quoted arguments, and restricting separators to' '/'\t'(consistent withrelaunch_args'strim_matches([' ', '\t'])) all match Microsoft's UCRTparse_command_linerules.Verification
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 (includingrelaunch_args_split_as_the_c_runtime_doesanda_relaunch_preserves_literal_whitespace_arguments).split_argsdirectly against live Windows 11 UCRTargvparsing (spawning a UCRT process withCommandExt::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.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.