Re: execve E2BIG (Argument list too long)
On September 30, 2020 8:44:40 AM Andreas Schwab wrote: On Sep 30 2020, Daniel Colascione wrote: It might be worth asking lkml to lift this restriction You will have bad luck with that. The limit has been introduced for security reasons. What "security reasons"? You'd still be subject to the stack ulimit, which you can set to whatever you want.
Re: execve E2BIG (Argument list too long)
Ok, I think that explains most of what I am seeing. I can indeed swap variable name characters for more characters in my overly long export. I'm no longer sure what I was seeing with the sourcing line, it seemed to have an effect on my tests yesterday but I can now add or remove this without triggering the effect. Looking at the man for execve, I see that the argument and environment variables are packed into 2 arrays of strings. I seem to be running into the MAX_ARG_STRLEN limit of 128k - which is the size of the smallest string that is triggering this error code. I am able to pass more arguments or more env variables until I hit the absolute limit - presumably ARG_MAX which for me is 2048k. The absolute vs local paths when calling the script is a bit weird. I wouldn't have thought it would effect the env of the execve call - I'm still calling from the same directory - and even if it did affect the environment then providing an absolute path would have increased its size, but calling it with the absolute path reduces the expansion of "${BASH_ARGV[*]}" by 18 characters which is the length of my path. On Wed, Sep 30, 2020 at 5:39 PM Chet Ramey wrote: > > On 9/30/20 3:12 AM, Michael Green wrote: > > > Bash Version: 5.0 > > Patch Level: 17 > > Release Status: release > > > > Description: > > > > The included short script when run with the following command results > > in execve "E2BIG (Argument list too long) errors". > > The argument list includes the size of the environment, and your script > creates a huge environment variable. > > -- > ``The lyf so short, the craft so long to lerne.'' - Chaucer > ``Ars longa, vita brevis'' - Hippocrates > Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: execve E2BIG (Argument list too long)
On Sep 30 2020, Daniel Colascione wrote: > It might be worth asking lkml to lift this restriction You will have bad luck with that. The limit has been introduced for security reasons. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
Re: execve E2BIG (Argument list too long)
On September 30, 2020 8:24:01 AM Ilkka Virta wrote: On Wed, Sep 30, 2020 at 5:53 PM Michael Green wrote: The included short script when run with the following command results in execve "E2BIG (Argument list too long) errors". * The number of arguments can be tuned down to "seq 1 23694" and it still occurs, but any lower and it disappears. That sounds a lot like the 128 kB hard limit Linux puts on the size of a single argument to exec. (I know it counts for command line arguments, I expect it also counts for env variables. They're passed in pretty much the same way anyway.) It might be worth asking lkml to lift this restriction seq 1 23694 | wc gives 131058, just a bit less than 131072. Add the variable name and it goes over. Workaround: use another OS, or pass big data like that in files.
Re: execve E2BIG (Argument list too long)
On 9/30/20 3:12 AM, Michael Green wrote: > Bash Version: 5.0 > Patch Level: 17 > Release Status: release > > Description: > > The included short script when run with the following command results > in execve "E2BIG (Argument list too long) errors". The argument list includes the size of the environment, and your script creates a huge environment variable. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: execve E2BIG (Argument list too long)
On Wed, Sep 30, 2020 at 09:12:30AM +0200, Michael Green wrote: > seq 1 4 | xargs ./bash_bug > > BEGIN: bash_bug > -- > #!/usr/bin/env bash > . "exists_or_not" > export A123456789012345="${BASH_ARGV[*]}" > mkdir -p /tmp/foobar > perl -E 'say "hello world"' 'foo' 'bar' > -- > END bash_bug Why do you consider this to be a bug in bash? You've asked your operating system to run a command (mkdir or perl) with an environment that exceeds the size the kernel will permit. The kernel gives you the error.
Re: execve E2BIG (Argument list too long)
On Wed, Sep 30, 2020 at 5:53 PM Michael Green wrote: > The included short script when run with the following command results > in execve "E2BIG (Argument list too long) errors". > > * The number of arguments can be tuned down to "seq 1 23694" and it > still occurs, but any lower and it disappears. > That sounds a lot like the 128 kB hard limit Linux puts on the size of a single argument to exec. (I know it counts for command line arguments, I expect it also counts for env variables. They're passed in pretty much the same way anyway.) seq 1 23694 | wc gives 131058, just a bit less than 131072. Add the variable name and it goes over. Workaround: use another OS, or pass big data like that in files.
execve E2BIG (Argument list too long)
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wno-parentheses -Wno-format-security uname output: Linux h001201355 5.7.10-201.fc32.x86_64 #1 SMP Thu Jul 23 00:58:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux Machine Type: x86_64-redhat-linux-gnu Bash Version: 5.0 Patch Level: 17 Release Status: release Description: The included short script when run with the following command results in execve "E2BIG (Argument list too long) errors". Running "strace -f" on this shows the error, and "Argument list too long" is printed out to stderr for the calls to external commands. seq 1 4 | xargs ./bash_bug BEGIN: bash_bug -- #!/usr/bin/env bash . "exists_or_not" export A123456789012345="${BASH_ARGV[*]}" mkdir -p /tmp/foobar perl -E 'say "hello world"' 'foo' 'bar' -- END bash_bug "xargs" is only used for the sake of being concise. The issue occurs with an equivalently long list of arguments. A number of the parameters can be tuned to make the problem occur or not. * The number of arguments can be tuned down to "seq 1 23694" and it still occurs, but any lower and it disappears. * The sourcing of a file appears to be required, but it doesn't matter what that file is or even if it exists. * The variable name length of the exported variable must be 16 or more characters, reducing this to 15 or less makes the bug disappear. It also doesn't matter what characters are, any valid variable name of 16 or more characters will do. * The path used for calling the script seems to affect the issue. In my tests using the absolute script path sometimes made the bug disappear, but using a local relative path seemed to reliably produce it. This issue was tested on the reporting system and the oldest system I could find and was present on both systems * Fedora release 32 (Thirty Two) 5.7.10-201.fc32.x86_64 * Red Hat Enterprise Linux Server release 6.10 (Santiago) 2.6.32-754.3.5.el6.x86_64 Repeat-By: Running provided script with the given command.