xargs completely broken under cygwin 3.6.0-0.108.gb7f5a33200a9
Brian Inglis
Brian.Inglis@SystematicSW.ab.ca
Tue Apr 2 06:18:40 GMT 2024
On 2024-04-01 21:36, Bruce Jerrick via Cygwin wrote:
> 'xargs' (part of 'findutils') is completely broken if
> 3.6.0-0.108.gb7f5a33200a9 (test version) is installed:
^ Cygwin
>
> $ xargs
> xargs: Unexpected suffix cmdline on cmdline
>
> $ xargs --version
> xargs: Unexpected suffix cmdline on cmdline
>
> $ echo narf | xargs echo
> xargs: Unexpected suffix cmdline on cmdline
>
> 'xargs' is from the current x86_64 findutils-4.9.0-1 .
> All other packages are up to date per setup.ini dated
> 2024-04-01 21:32:37 GMT.
>
> I first discovered this under Windoze 11 Insider Preview
> (with no other Cygwin test versions).
> On a Windoze 10 machine, it was OK with cygwin 3.5.1-1,
> appeared when I installed 3.6.0-0.108.gb7f5a33200a9,
> then went away when I reverted to 3.5.1-1 .
> (All machines are VMware VM's.)
>
> ----------------------------------------------------------------
>
> I have just started looking at the source, and the error
> is coming from this snippet from 'safe_atoi()' in
> lib/safe-atoi.c :
^ findutils 4.9.0
> safe_atoi (const char *s, enum quoting_style style)
> {
> ...
> lval = strtol (s, &end, 10);
> ...
> else if (*end)
> {
> die (EXIT_FAILURE, errno, _("Unexpected suffix %s on %s"),
> quotearg_n_style (0, style, end),
> quotearg_n_style (1, style, s));
> }
> ...
That function safe_atoi() appears only to be called by xargs from
remember_non_cloexec_fds() -> get_max_fd() -> get_proc_max_fd(), all in
lib/fdleak.c and appears to be trying to convert the text cmdline, which should
not happen because it is trying to open, read, and convert directory entries
from /proc/self/fd.
Could you please try running:
$ xargs -t --show-limits < /dev/null
Your environment variables take up 9285 bytes
POSIX upper limit on argument length (this system): 20667
POSIX smallest allowable upper limit on argument length (all systems): 4096
Maximum length of command we could actually use: 11382
Size of command buffer we are actually using: 20667
Maximum parallelism (--max-procs must be no greater): 2147483647
echo
and it would be useful if you could run a failing command under strace e.g.
$ strace -o xargs.strace xargs -t --show-limits < /dev/null
or similar and attach as text to your reply.
There could be something funny going on with recent changes to Cygwin directory
lookup affecting proc virtual file system lookups e.g.
Cygwin: implement dirent.d_reclen
https://cygwin.com/cgit/newlib-cygwin/commit/?h=topic/3.6&id=7e40e0169a75ebdf3f3861dab47abdfeb0ad9c58
and subsequent changes around dirents.
Could someone please take a look at those recent changes, testing access to proc
file system entries, perhaps also with xargs, in case access to virtual files
have issues?
> From 'man 3 strtol":
> "If the subject string is empty (or not in acceptable form),
> no conversion is performed and the value of s is stored
> in ptr [i.e., 'end'] ..."
> Which is apparently what is happening here.
>
> I have yet to discover where "cmdline" is coming from (perhaps
> /proc/%d/cmdline), let alone what it looks like.
> Further progress by me will depend on what success I have in
> building 'findutils' from source :) .
For more info, install cygwin-doc, and run:
$ man 5 proc
Contents of /proc/.../cmdline is an argv array:
$ cat -A /proc/self/cmdline; echo
cat^@-A^@/proc/self/cmdline^@
There could also be something funny going on with recent changes to Cygwin
process startup e.g.
Cygwin: redefine CW_CMDLINE to CW_CMDLINE_ALLOC
https://cygwin.com/cgit/newlib-cygwin/commit/?h=topic/3.6&id=732afede935832beab181ae421c1366df2ae6af5
Could someone please take a look at those recent changes, testing with xargs, in
case base assumptions of argv[] command line arguments and environ, envp[]
environment variables address locations, terminators, atexit routines, could be
broken?
--
Take care. Thanks, Brian Inglis Calgary, Alberta, Canada
La perfection est atteinte Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer but when there is no more to cut
-- Antoine de Saint-Exupéry
More information about the Cygwin
mailing list