gawk core dumped on too many input values

Corinna Vinschen corinna-cygwin@cygwin.com
Tue Aug 29 13:03:45 GMT 2023


On Aug 28 12:20, Brian Inglis via Cygwin wrote:
> On 2023-08-28 05:47, Joshuah Hurst via Cygwin wrote:
> > On Mon, Aug 28, 2023 at 1:08 AM Jeremy Hetzler via Cygwin
> > <cygwin@cygwin.com> wrote:
> > > 
> > > On Sun, Aug 27, 2023 at 2:25 PM Ed Morton via Cygwin <cygwin@cygwin.com>
> > > wrote:
> > > > 
> > > > This (original email below) turned out to be a general cygwin issue, not
> > > > a gawk issue:
> > > > 
> > > > $ LC_ALL=C sed 's/x/y/' $(seq 1000000)
> > > > Segmentation fault (core dumped)
> > > > 
> > > > $ LC_ALL=C grep 'foo' $(seq 1000000)
> > > > Segmentation fault (core dumped)

This is fixed in current git and can be tested with the next test
release cygwin-3.5.0-0.404.gca2a4ec24362, which is just being built
and uploaded in a few mins.

> > [...]
> > Is this limit?
> > 
> > $ getconf -a | grep -E 'ARG_MAX'
> > _POSIX_ARG_MAX                      4096
> > ARG_MAX                             32000

This isn't the real limit.

ARG_MAX has been chosen at one point to be 32000, because that's a safe
size for the Windows command line length.  Therefore this is a hard limit
if you start non-Cygwin executables.  Cygwin executables don't have this
limit.  In fact, the limit is defined only by the amount of memory the
parent process has available when creating the argv and environment lists
for the child.

We fixed that in git.  As a result, sysconf(_SC_ARG_MAX) will now return
-1.  I. e., ARG_MAX has an indeterminate limit:

  $ getconf -a | grep -E 'ARG_MAX'
  _POSIX_ARG_MAX                      4096
  ARG_MAX
  $ getconf ARG_MAX
  undefined

However! limits.h still defines ARG_MAX as 32000, and we'll stick to
this, on account it being a safe value.

This has a precedent on Linux, where getconf returns something big, but
ARG_MAX is still 131072:

  $ grep ARG_MAX /usr/include/linux/limits.h
  #define ARG_MAX       131072	/* # bytes of args + environ for exec() */
  $ getconf ARG_MAX
  2097152

The limits.h limit of 131072 is historical (32 pages for argv and envp).
The getconf value is a quarter of the stack which is reserved for argv
and envp.

I hope that explains things sufficiently.

The patches will be backported to 3.4.9.


Thanks,
Corinna


More information about the Cygwin mailing list