-
Notifications
You must be signed in to change notification settings - Fork 326
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
xargs: exec ... Argument list too long #40
Comments
On 08/10/2016 07:44 AM, Matthias Urhahn wrote:
The Linux kernel removed that limit in 2007 That said, let's cd to a directory with a lot of files in it: $ find . | wc And I'm seeing a limit here too. Hmmm...
The kernel should not be enforcing this? Maybe something else is? There #define ARG_MAX 131072 /* # bytes of args + environ for exec() */ And that's used in fs/exec.c: /*
Ok, so that's still there as a MINIMUM, and the maximum is 1/4 the $ find . | head -n 40000 | wc Yup, the actual default limit is way more than 131072, and that $ ulimit -Hs (Huh, what happens if I set the stack size limit to less than 131072
It didn't enforce a default maximum length limit because as far as I http://landley.net/notes-2011.html#17-12-2011 So it's not hard to add a default, but what the default should be isn't
The sanity checks are there (-s is implemented), toybox just doesn't
See above. There's a sysconf(_SC_ARG_MAX), which does appear to be calculating this Oh well, use the sysconf and then file a bug against musl. (Elliott will Thanks for the heads up, Rob |
Thanks for the details, very intresting.
I'm not sure I understood this. Should I file this somewhere else?
What commit? |
On 08/11/2016 12:25 AM, Matthias Urhahn wrote:
No, I meant that's how I should fix it in toybox.
One I haven't made yet, fixing this. (Busy day, sorry.) Rob |
thread restarted with patch for xargs (but not find): http://lists.landley.net/pipermail/toybox-landley.net/2017-September/009167.html |
i think this can be closed now... as of the end of 2019 this is working for bionic, glibc, and macOS. |
The magic -4096 is still a little creepy, but yes it seems to be working. |
toybox 0.7.1
On some Android devices (N5@6.0) using a chain of
find .... | xargs .... stat ....
, yields the errorArgument list too long
.Some googlfu shows that this is likely related to the argument exceeding the kernels ARG_MAX value.
Androids ARG_MAX according to this 131072.
Manually limiting the xargs argument length using
-s bytes
fixes this for me.I've looked at the code for xarg in toybox but could not figure out yet how the max argument length is determined.
Busybox doesn't seem to run into this issue using the same command on the same device. Busybox seems to have some sanity checks, adjusting the argument length if necessary.
Could there be an issue with how toybox's
xarg
determines the default argument length on Android?The text was updated successfully, but these errors were encountered: