Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: fix java_binary.jvm_flags escaping #7314

Closed
wants to merge 1 commit into from

Conversation

laszlocsomor
Copy link
Contributor

Bazel on Windows now correctly forwards
java_binary.jvm_flags to the binary.

Bazel Bash-tokenizes java_binary.jvm_flags.
On Linux/macOS, this is done by embedding the
flags into the Java stub script, which is a Bash
script, so Bash itself does the tokenization.

On Windows, java_binary is launched by a native
C++ binary. Therefore nothing could Bash-tokenize
the flags until now. From now on, Bazel itself
Bash-tokenizes the flags before embedding them in
the launcher. The launcher then escapes these
flags for CreateProcessW.

This PR also adds a new, CreateProcessW-aware
escaping method called CreateProcessEscapeArg, to
the launcher.

The pre-existing GetEscapedArgument escaped only
with Bash semantics in mind. This method is now
renamed to BashEscapeArg, and used only for the
Bash launcher. For the Python and Java launcher,
the new CreateProcessEscapeArg method is used.

Fixes #7072

Change-Id: I48d675fcce39e4f6c95e3bad3e8569f0274f662a

@laszlocsomor laszlocsomor requested a review from lberki as a code owner January 31, 2019 13:52
@laszlocsomor laszlocsomor removed the request for review from lberki January 31, 2019 13:56
@laszlocsomor laszlocsomor changed the title Windows: fix java_binary.jvm_flags escaping WIP: Windows: fix java_binary.jvm_flags escaping Jan 31, 2019
@laszlocsomor laszlocsomor force-pushed the gh-7072 branch 2 times, most recently from 6616927 to f3bc3a1 Compare February 5, 2019 12:54
@laszlocsomor laszlocsomor changed the title WIP: Windows: fix java_binary.jvm_flags escaping Windows: fix java_binary.jvm_flags escaping Feb 5, 2019
Bazel on Windows now correctly forwards
java_binary.jvm_flags to the binary.

Bazel Bash-tokenizes java_binary.jvm_flags.
On Linux/macOS, this is done by embedding the
flags into the Java stub script, which is a Bash
script, so Bash itself does the tokenization.

On Windows, java_binary is launched by a native
C++ binary. Therefore nothing could Bash-tokenize
the flags until now. From now on, Bazel itself
Bash-tokenizes the flags before embedding them in
the launcher. The launcher then escapes these
flags for CreateProcessW.

This PR also adds a new, CreateProcessW-aware
escaping method called CreateProcessEscapeArg, to
the launcher.

The pre-existing GetEscapedArgument escaped only
with Bash semantics in mind. This method is now
renamed to BashEscapeArg, and used only for the
Bash launcher. For the Python and Java launcher,
the new CreateProcessEscapeArg method is used.

Fixes bazelbuild#7072
@laszlocsomor laszlocsomor requested review from philwo and joeleba and removed request for philwo February 5, 2019 16:28
laszlocsomor added a commit to laszlocsomor/bazel that referenced this pull request Feb 8, 2019
Fix the quoting logic for command line arguments
passed to CreateProcessW.

Related to bazelbuild#7314

Fixes bazelbuild#7122
@laszlocsomor
Copy link
Contributor Author

I'll break up this PR because it's too complicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants