-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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
misc/wasm, cmd/link: Go 1.17.2 causes WASM builds to throw command line too long
with many environment variables
#49011
Comments
I just discovered that this also impacts running tests for the same reason:
|
command line too long
with many environment variablescommand line too long
with many environment variables
Also CC @cherrymui, @neelance. |
Both command line arguments and environment variables are currently passed to WebAssembly by writing them to linear memory, and CL 354571 added a fixed limit of 4096 bytes for both. The error message can certainly be improved to also mention environment variables. I'm wondering if you can speak about how much more than 4096 bytes you're running into in your use case? Is it just a little over, or is it significantly over? Or is it unpredictable? |
I'm the author of esbuild and I use GitHub Actions to run my Go WASM tests. Here's the full list of environment variables I'm seeing in my tests: Click to expand the list of environment variables
The text I pasted above comes in at 3919 bytes for 96 environment variables, so you'd need to add an extra 98*8=768 for the pointers for a total of 3919+768=4687 bytes just for environment variable data alone. So it's a little over 4096 bytes. The maximum value of the |
I see no reason against increasing the limit from 4096 to 8192 bytes. Later, after https://golang.org/cl/350737 landed, we can switch to the WASI interface for getting the arguments and environment which would remove the limit entirely. |
Change https://golang.org/cl/358194 mentions this issue: |
@gopherbot Please open backport tracking issues. This is a follow-up to the security fix included in Go 1.17.2 and 1.16.9 for issue #48797; without it some programs are unable to run. |
Backport issue(s) opened: #49153 (for 1.16), #49154 (for 1.17). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
Change https://golang.org/cl/359399 mentions this issue: |
Change https://golang.org/cl/359400 mentions this issue: |
… env on wasm On wasm, the wasm_exec.js helper passes the command line arguments and environment variables via a reserved space in the wasm linear memory. Increase this reserved space from 4096 to 8192 bytes so more environment variables can fit into the limit. Later, after https://golang.org/cl/350737 landed, we can switch to the WASI interface for getting the arguments and environment. This would remove the limit entirely. Updates #49011. Fixes #49153. Change-Id: I48a6e952a97d33404ed692c98e9b49c5cd6b269b Reviewed-on: https://go-review.googlesource.com/c/go/+/358194 Trust: Richard Musiol <neelance@gmail.com> Run-TryBot: Richard Musiol <neelance@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> (cherry picked from commit 252324e) Reviewed-on: https://go-review.googlesource.com/c/go/+/359400 Trust: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
… env on wasm On wasm, the wasm_exec.js helper passes the command line arguments and environment variables via a reserved space in the wasm linear memory. Increase this reserved space from 4096 to 8192 bytes so more environment variables can fit into the limit. Later, after https://golang.org/cl/350737 landed, we can switch to the WASI interface for getting the arguments and environment. This would remove the limit entirely. Updates #49011. Fixes #49154. Change-Id: I48a6e952a97d33404ed692c98e9b49c5cd6b269b Reviewed-on: https://go-review.googlesource.com/c/go/+/358194 Trust: Richard Musiol <neelance@gmail.com> Run-TryBot: Richard Musiol <neelance@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> (cherry picked from commit 252324e) Reviewed-on: https://go-review.googlesource.com/c/go/+/359399 Trust: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Suggested workaround for some cases: Run with a clean environment, e.g.: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes. It's caused by the latest release.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Here's a simple way to reproduce the issue:
What did you expect to see?
This should print
0
.What did you see instead?
This fails with the following error:
There are at least two problems:
With Go 1.17.2, it's now impossible to use Go WASM programs in situations with many environment variables. This comes up when trying to run something via GitHub Actions, for example.
The error message
command line too long
is confusing because there are no command-line arguments. Instead the problem is that there are too many environment variables.See also
The text was updated successfully, but these errors were encountered: