Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Oct 2004 21:10:06 +0300
From:      Ruslan Ermilov <ru@freebsd.org>
To:        Dan Nelson <dnelson@allantgroup.com>
Cc:        freebsd-current@freebsd.org
Subject:   Re: awk leaking memory during arithmetic?
Message-ID:  <20041007181006.GC84576@ip.net.ua>
In-Reply-To: <20041004172224.GA30419@dan.emsphone.com>
References:  <20041004171422.GK262@numachi.com> <20041004172224.GA30419@dan.emsphone.com>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
On Mon, Oct 04, 2004 at 12:22:24PM -0500, Dan Nelson wrote:
> In the last episode (Oct 04), Brian Reichert said:
> > I may be misremembering some awk lore, but this still seems like
> > undesired behavior.  Essentially, I'm trying to sum up some numbers,
> > but awk spin, chewing up memory, until it drops a huge core file.
> > 
> >   # uname -a
> >   FreeBSD backup.internal 5.2.1-RELEASE FreeBSD 5.2.1-RELEASE #1: Mon Sep 27
> >   19:27:46 EDT 200	 root@backup2.internal:/usr/src/sys/i386/compile/FILESERVER  i386
> >   
> >   # cat test_list | awk '{print $1}'
> >   53999616
> >   53999616
> >   53311488
> >   102475776
> >   257134592
> >   858624
> >   512909312
> >   1147392
> >   39385174
> >   35815424
> > 
> >   # cat test_list | awk '{ t += $1 } END {print $t}'
> >   awk in malloc(): error: allocation failed
> 
> I think "print t" is what you want here.  $t would refer to the t'th
> field in the line, and it looks like awk tried to resize the array out
> to 1111037014 entries and failed.
> 
There's an open PR bin/72370 on this (now with the patch).


Cheers,
-- 
Ruslan Ermilov
ru@FreeBSD.org
FreeBSD committer

[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (FreeBSD)

iD8DBQFBZYZ+qRfpzJluFF4RAjlKAJ9BGrnH4om7oVoCIe8dwiON5ulKAwCcDjHG
qukxP/UwTbS+r8B1vsiDBcM=
=UEy1
-----END PGP SIGNATURE-----
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041007181006.GC84576>