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: CreateProcess(): The parameter is incorrect (due to long argument list) #4083

Closed
j3parker opened this issue Nov 13, 2017 · 6 comments
Assignees
Labels
category: misc > misc P2 We'll consider working on this in future. (Assignee optional) platform: windows type: bug

Comments

@j3parker
Copy link
Contributor

j3parker commented Nov 13, 2017

Description of the problem:

When the total length of the arguments + executable (+ null terminator etc.) exceeds 32,767 Bazel fails ungracefully with the error

Action failed to execute: java.io.IOException: CreateProcess(): The parameter is incorrect.

It would be nice if this had a better error message, at least.

Generally this is pretty worrying because Bazel seems to like creating very large argument lists and this definitely something Bazel can just "fix" :) I've been able to solve my specific case with param files but I think there should be an error message so folks know what's up.

Minimal reproduction:

In foo.bzl:

def _broken(ctx):
  dummy = ctx.actions.declare_file("dummy.txt")

  ctx.actions.run(
    outputs = [dummy],
    executable = "echo",
    arguments = ["x"*32760],
  )

broken = rule(
  implementation = _broken,
  outputs = {"foo": "dummy.txt"},
)

In a BUILD:

load("//:foo.bzl", "broken")

broken(name = "whoops")

Changing 32760 to something lower (e.g. 32759) causes the build to fail for legitimate reasons.

  • Bazel version (output of bazel info release): release 0.7.0

Have you found anything relevant by searching the web?

The following issues may be related. They both contain the same error message (CreateProcess(): The parameter is incorrect) and the one's log showed what appeared to be a 51k long process creation.

Anything else, information or logs or outputs that would be helpful?

  • MSDN docs for CreateProcess which documents the 32,767 restriction
@laszlocsomor
Copy link
Contributor

laszlocsomor commented Nov 15, 2017

Thanks for reporting this bug!
I started seeing the same error a few days ago when building Bazel itself. I'll investigate.

@laszlocsomor laszlocsomor self-assigned this Nov 15, 2017
@laszlocsomor laszlocsomor added platform: windows P1 I'll work on this now. (Assignee required) type: bug labels Nov 15, 2017
@j3parker
Copy link
Contributor Author

j3parker commented Nov 15, 2017

I noticed it while trying to get my Windows build of Bazel to run too, I think during some test coverage stuff (I haven't looked too closely yet.)

bazel-io pushed a commit that referenced this issue Nov 16, 2017
Error out if the command we try to pass to
CreateProcess is longer than the limit.

Doing so results in a nicer error message than
"The parameter is incorrect" which is confusing.

In this commit I also improve the error reporting
of CreateProcessWithExplicitHandles.

See #4083
See #4096

Change-Id: I00ec52238706fd8140483eddb488c3069eaa7814
PiperOrigin-RevId: 175969789
@j3parker
Copy link
Contributor Author

In 0.8.0 the error message now looks like:

Action failed to execute: java.io.IOException: ERROR: src/main/native/windows/processes-jni.cc(410): nativeCreateProcess(csc.exe): The filename or extension is too long.

@laszlocsomor
Copy link
Contributor

0.8.0 doesn't yet contain https://github.com/Androbin/bazel/commit/b110dfb5cca8961051426e669566cc3aeeac55ee .

We also need your PR (#4088) with the Java-side changes, so the Java code won't even attempt to create a process if it knows the cmdline is too long.

I figured that one situation where Bazel produces this error is with Java header compilation. Bazel tries to compile all headers in one action, passing all files as arguments. If that fails, Bazel just retries using parameter files. That's why the error is non-fatal, see issue #4096.

@laszlocsomor
Copy link
Contributor

Dropping to P2, because Bazel still displays error messages making this a problem with usability, the errors are benign so Bazel is usable.

@laszlocsomor laszlocsomor added P2 We'll consider working on this in future. (Assignee optional) and removed P1 I'll work on this now. (Assignee required) labels Dec 13, 2017
@laszlocsomor
Copy link
Contributor

I think this is a duplicate of #4096.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: misc > misc P2 We'll consider working on this in future. (Assignee optional) platform: windows type: bug
Projects
None yet
Development

No branches or pull requests

3 participants