Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 303669 - sys-apps/findutils: xargs uses wrong limits on Interix
Summary: sys-apps/findutils: xargs uses wrong limits on Interix
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: All Interix
: High minor (vote)
Assignee: Markus Duft (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-06 04:29 UTC by Greg Turner
Modified: 2010-10-27 06:54 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
apply interix-temp patch and gentler xargs usage on interix (sqlite-3.6.22-r1_ebuild.patch,724 bytes, patch)
2010-02-06 04:36 UTC, Greg Turner
Details | Diff
apply interix-temp patch and gentler xargs usage on interix (portage-2.2.00.15320_ebuild.patch,779 bytes, patch)
2010-02-06 04:38 UTC, Greg Turner
Details | Diff
Don't mess with TEMP/TMP on Interix as they are non-standard and wackyness will ensue (portage-2.2.00.15320-interix-temp.patch,335 bytes, patch)
2010-02-06 04:40 UTC, Greg Turner
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Turner 2010-02-06 04:29:30 UTC
On (my) Interix, TEMP and TMP contain something like 'C:\Windows\Blah'.  Portage concatenates these with colon separators, passes this to the bash printf builtin, which interprets the backslashes as god-knows-what, and then pipes the mangled output to something like:

  tr ':' '\0' | sort -x -u | tr '\0' ':'

results: GIGO, obv.

So I've enclosed a patch to stop this.

Also, maybe this is a quirk of my system, somehow, but I have always had lots of problems with commands like:

   find ${foo} | xargs grep ${bar}

Somehow, grep seems to run out of memory handling the larger lists that xargs might feed it.  To prevent these problems, I have gotten into the habit of doing 

   find ${foo} | xargs -s 4000 grep ${bar}

I should really figure out what's wrong with grep -- but in the meanwhile I patch my portage to do -s 4000.
Comment 1 Greg Turner 2010-02-06 04:36:42 UTC
Created attachment 218613 [details, diff]
apply interix-temp patch and gentler xargs usage on interix
Comment 2 Greg Turner 2010-02-06 04:38:27 UTC
Created attachment 218615 [details, diff]
apply interix-temp patch and gentler xargs usage on interix

oops, wrong patch.
Comment 3 Greg Turner 2010-02-06 04:40:06 UTC
Created attachment 218617 [details, diff]
Don't mess with TEMP/TMP on Interix as they are non-standard and wackyness will ensue
Comment 4 Markus Duft (RETIRED) gentoo-dev 2010-02-09 08:32:55 UTC
have you bootstrapped yourself on interix, or are you using the system from the install DVD images? because those contain propper .profile's, installed for each user you instructed setup to set up ;p. those $HOME/.profile's fixup some things, mostly regarding the (at our company) later building of windows binaries. but there are also things like translating TEMP. etc to interix paths...
Comment 5 Greg Turner 2010-02-09 23:32:38 UTC
(In reply to comment #4)
> have you bootstrapped yourself on interix, or are you using the system from the
> install DVD images? because those contain propper .profile's, installed for
> each user you instructed setup to set up ;p. those $HOME/.profile's fixup some
> things, mostly regarding the (at our company) later building of windows
> binaries. but there are also things like translating TEMP. etc to interix
> paths...

I used the DVD and I haven't touched the .profile.  At a glance, it seems to explicitly set them to be /windows/ paths:

  export TMP="$(unixpath2win $TMPDIR)"
  export TEMP="$(unixpath2win $TMPDIR)"

Maybe the reason it does this, despite it being very non-unixy, is that if win32 processes inherit, i.e., TEMP=/tmp from Interix (for example, due to manual command-line execution), bad things will probably happen.
Comment 6 Markus Duft (RETIRED) gentoo-dev 2010-02-10 10:45:01 UTC
ah - of course i was wrong - TEMP needs to be windows-ish for cl.exe (the windows compiler) to be executable... damn :] why am i not having problems then? hmm...
Comment 7 Fabian Groffen gentoo-dev 2010-02-13 13:19:46 UTC
What's the output of xargs --show-limits on Interix?  If that output is wrong, we better patch xargs than random code that uses xargs (and relies on it doing the right thing).
Comment 8 Greg Turner 2010-02-13 23:19:33 UTC
(In reply to comment #7)
> What's the output of xargs --show-limits on Interix?  If that output is wrong,
> we better patch xargs than random code that uses xargs (and relies on it doing
> the right thing).

I get:

Your environment variables take up 3575 bytes
POSIX upper limit on argument length (this system): 1042953
POSIX smallest allowable upper limit on argument length (all systems): 4096
Maximum length of command we could actually use: 1039378
Size of command buffer we are actually using: 131072

I just tried doing

  find /usr -print0 | xargs -0 echo

and sure enough it gave me

  "xargs: echo: Cannot allocate memory"

So, I was blaming this on grep but clearly that is wrong.

Chasing down the highest -s argument that works here in typical O(log n) style, -s54597 works but -s54598 runs out of memory.

If you know how to fix xargs that would be awesome.
Comment 9 Greg Turner 2010-02-13 23:53:04 UTC
(In reply to comment #8)
> (In reply to comment #7)
> -s54597 works but -s54598 runs out of memory.

One more note on this: the number autotools derives for "maximum length of command line arguments" is 24577.
Comment 10 Greg Turner 2010-03-04 03:13:33 UTC
(In reply to comment #9)
> (In reply to comment #8)
> > (In reply to comment #7)
> > -s54597 works but -s54598 runs out of memory.
> One more note on this: the number autotools derives for "maximum length of
> command line arguments" is 24577.

If this is going to be a findutils bug (which, to be clear, I agree it should be), should I make a new one for the TEMP/TMP handling issue in portage?
Comment 11 Fabian Groffen gentoo-dev 2010-03-04 07:18:55 UTC
If you want it to be addressed, I'd say yes, otherwise it'll get lost.
Comment 12 Greg Turner 2010-03-04 08:18:44 UTC
(In reply to comment #11)
> If you want it to be addressed, I'd say yes, otherwise it'll get lost.

My thoughts exactly.  It's #307729.
Comment 13 Markus Duft (RETIRED) gentoo-dev 2010-10-22 14:49:05 UTC
in now came back to this bug after a while. tracing a little through xargs, i found out that execvp itself issues the cannot allocate memory error. thus it seams that exec*() cannot handle whatever is returned from sysconf(_SC_ARG_MAX). guess thats a bug ;p

however, i can work around this by using the static defined ARG_MAX, which is far less than _SC_ARG_MAX, and makes it work fine. just need to get the patch upstream, or some sort of other solution, they'll accept.
Comment 14 Markus Duft (RETIRED) gentoo-dev 2010-10-27 06:54:26 UTC
i have a patch for this now, that is accepted and pushed upstream already - last build test in the makes, and i'll commit it to the tree after that :)