Subject: Re: bin/8681: grep may bomb out with "memory exhausted"
To: None <Havard.Eidnes@runit.sintef.no>
From: Simon Burge <simonb@netbsd.org>
List: netbsd-bugs
Date: 10/26/1999 11:47:15
Simon Burge wrote:

> Havard.Eidnes@runit.sintef.no wrote:
> 
> > > With both this and bin/8461, seems like a very strong case to turn off
> > > HAVE_MMAP.  Any objections?
> > 
> > Gah, even doing that appears not to be sufficient to cure the
> > problem:
> 
> It seems that under some circumstances that grep wants to save a very
> large chunk of the current file in a buffer, and that five times that
> buffer is allocated when the buffers are expanded.

Looking at this closer, it's as simple as looking in the current buffer
for a newline.  If the buffer is all zeros (as some of your kernel may
have, and the test file I used did), then it wont find a newline and
tries to save the all of the current buffer and so on until memory runs
out.  At this stage, I think the buffer size limiting patch is probably
the right thing...

Simon.