bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [patch #6569] Allow grep to work in small stack environment


From: Eric Blake
Subject: Re: [patch #6569] Allow grep to work in small stack environment
Date: Fri, 27 Aug 2010 13:33:29 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100806 Fedora/3.1.2-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.2

On 08/27/2010 01:01 PM, Paul Eggert wrote:
On 08/27/2010 01:39 AM, Jim Meyering wrote:

   - use xnmalloc, not malloc+test+return, so we don't ignore malloc failure.
   - use sizeof *VAR, not "sizeof TYPE" -- the former is more maintainable.
   - adjust indentation to retain declaration alignment

There are many places in other GNU apps, including gnulib, where
it's assumed that one can declare a 4 kB-or-so array on the stack without
any problem.  So I'm surprised to see the need for this change to GNU grep.
Surely we don't need to go through GNU apps and rejigger things for
configurations with 4 kB stacks?  By today's standards, such stacks are
ridiculously small.

4k in a non-recursive algorithm is probably fine for a non-threaded app; but if there is any chance for recursion, then stack-allocating a 4k array risks interfering with stack overflow detection, since that is larger than the guard page installed at the end of some stacks. For threaded applications (and therefore libraries), it is much more common to have extremely limited stacks for each thread.

--
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]