grep bug

Steve Young sdyoung at vt220.org
Fri Feb 13 18:58:21 PST 2004


On Feb 9, 2004, at 12:04 AM, Rob MacGregor wrote:

> I can confirm this behaviour under 5.2-CURRENT from the 5th of 
> February:
>
> -bash-2.05b$ grep -r foo / >/dev/null
> grep: /dev/network: Permission denied
> grep: /dev/geom.ctl: Permission denied
> grep: /dev/devctl: Permission denied
> grep: /dev/ata: Permission denied
> grep in realloc(): error: allocation failed
> Abort trap (core dumped)
> Feb  9 06:59:59 phoenix kernel: pid 55974 (grep), uid 1001: exited on 
> signal
> 6 (
> core dumped)

   Hi Rob,

   The problem here is that grep is trying to grep /dev/zero and is 
trying to allocate all your memory in the process of handling this 
infinite input.  This will happen when grep is used on any of the /dev 
files that spit out unlimited output, such as /dev/random and the sound 
input device, I suspect.  Arguably grep shouldn't eat up all your 
memory when this happens but that's more of a GNU issue than a FreeBSD 
issue, and really it would be kind of hard to handle 
gracefully/portably.  Have you reported this to the gnu bugs mailing 
address? It may conceivably use 100% CPU but it shouldn't try and grab 
100% memory too.

   Thanks,
   Steve.



More information about the freebsd-current mailing list