0.7.3 --- a started program's arguments and directory arrive as they were given - #22
Merged
Merged
Conversation
…were given The command line dropped every backslash: a run of them was counted and never written, and an element was converted in place just beyond the line, so quoting overwrote what it had not read. Every element was also quoted, which the command interpreter reads as a command rather than a switch. Elements are now written as they are unless the splitting would alter them, and quoted by the rule it inverts otherwise. A started program read its arguments through the name-narrowing that turns backslashes into slashes; arguments are now narrowed as given (clause 7.6). And the program and its directory were handed over in the \\?\ form, which the command interpreter refuses as a current directory; the prefix is removed wherever the name means the same without it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A program started on Windows did not receive the arguments it was given, and the command interpreter could not be started at all.
Found through lsp-mcpp, whose Windows conformance run starts
mcpp, which on windows-2022 went through the command interpreter, and got:Three defects, each measured with a round-trip test (a program starts a copy of itself and prints the vector it received) under Wine:
1. Backslashes were dropped from the command line, and quoting overwrote unread input.
append_quotedcounted a run of backslashes and never wrote it, soC:\dir\file.txtarrived asC:dirfile.txtand a trailing backslash closed the quote early and merged the following elements. Separately, each element was converted in place just beyond the line, so any escape the quoting added overwrote characters it had not read yet.Now an element is converted into its own buffer and quoted by the rule
CommandLineToArgvWinverts: backslashes before a quote are doubled and the quote escaped, backslashes before the closing quote are doubled, every other backslash is literal.2. Every element was quoted. The splitting accepts that, but the command interpreter parses its own command line and reads
"/c"as a command rather than its switch; a batch file, which runs through the interpreter, received a line it called incorrect. An element is now quoted only when the splitting would otherwise alter it (empty, or containing a space, tab, newline or quote).3. Arguments were narrowed as names.
prepare()insrc/env.cppstored each argument throughokw::narrow, which rewrites\as/because openkal spells a name's separator that way. An argument is not a name; clause 7.6 requires the vector unaltered.4. The program and its directory were handed over in the
\\?\form.GetFinalPathNameByHandleWanswers with the verbatim prefix;CreateProcessWaccepts it, but a started program inherits it as its current directory and the command interpreter refuses that (above). The prefix is now removed wherever the name means the same without it: a drive path within the classic bound, or\\?\UNC\host\shareas\\host\share. A longer name keeps the prefix, because without it the name would not be accepted at all. (Wine's interpreter tolerates the prefix, so this one is shown by the log above rather than by a local run.)Environment values are unchanged: they are still narrowed with the name substitution, which the specification does not address; recorded here rather than changed.
With openkal-llvm-runtime → openkal-musl → this tree, lsp-mcpp's
test_processforx86_64-windows-gnupasses all 11 cases under Wine, includingarguments arrive unalteredandthe command interpreter runs in the work directory(cmd.exe /d /c type marker.txtin a work directory). The objects still reference no C runtime symbol in the dev and release profiles.Remaining, and a requirement rather than a defect: an argument carrying the interpreter's own metacharacters (
& | < > ^ %) is passed to a batch file as the splitting rule says, which the interpreter then interprets. openkal does not define starting a script through its interpreter, so this is not addressed.0.7.3.