Bash login breaks if too many environment variables are set

Eric Blake ericblake@comcast.net
Fri Sep 16 16:38:00 GMT 2005


> >It looks to me as if a buffer or stack is reused if some maximum is
> >exceeded with effect that the system sometimes works.
> 
>  From your strace output, it looks to me like windows itself is returning
> garbage when we ask it for the list of environment variables.

I don't think all places in Windows have the limitation.  Corinna
reported (and I have reproduced on Win2k, CYGWIN-NT-5.0) that it
is quite easy to create an environment larger than 32k and see it
in a child process:

$ foo=`perl -e 'print "a"x31000'`
$ export foo
$ /bin/env | wc -c
34664

But it certainly does look like at least one version of Windows (the
OP was using CYGWIN_NT-5.1), when manipulating the environment
during .bat execution, is tracking total environment size in a signed
short, then croaking as the variable wraps around.  The output of
'export -p' just before the breaking point will not be exactly 32k,
since Cygwin and bash both add variables to the environment before
export has a chance to print it.

Meanwhile, it also exposes a bug in xargs, using the above environment:
$ xargs --help
xargs: environment is too large for exec

Oops - xargs was over-eager in not exceeding ARG_MAX, even though
--help implied there was nothing to exec, and even though on cygwin
the environ and command line do not share common storage in exec*().

--
Eric Blake



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list