[Top][All Lists]

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

Re: possible gawk memory leak?

From: arnold
Subject: Re: possible gawk memory leak?
Date: Fri, 25 Jun 2021 07:16:58 -0600
User-agent: Heirloom mailx 12.5 7/5/10


Thank you for sending a bug report.

This is not a bug.

/dev/zero is an infinite source of zero bytes. Reading from it NEVER
returns end-of-file. Thus gawk starts reading and keeps reading in the
hope that it will see a record separator character. Since the default
separator character is newline, and /dev/zero never supplies a newline,
it just keeps on reading until it can no longer allocate memory.

In short, "don't do that". :-)



Eckard Brauer <eckard.brauer@gmx.de> wrote:

> Hello,
> playing around I just observed a little problem with gawk I can't
> really explain well (gawk-5.1.0, Linux (Gentoo), x86_64). Executing
> awk 'NR==4{exit}{print NR}' /dev/zero
> gawk tries to allocate all available memory and so freezes the whole
> host for some time. Doing that in a memory limited environment to
> preserve disk swapping only let's happen the crash earlier and without
> system freeze:
>  $ ulimit -m 8192000
>  $ ulimit -v 8192000
>  $ awk 'NR==4{exit}{print NR}' /dev/zero
> awk: fatal: io.c:3464:grow_iop_buffer: iop->buf: cannot reallocate 8589934593 
> bytes of memory: Cannot allocate memory
> So if that's not an individual problem, could you either explain the
> reason(s) for that behaviour, or fix it if it's unintended?
> Thanks in advance && best regards,
> Eckard Brauer

reply via email to

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