GNU bug report logs - #13530
head: memory exhausted when printing all from stdin but last P/E bytes

Previous Next

Package: coreutils;

Reported by: Lei Zhang <lei.zhang <at> uwaterloo.ca>

Date: Wed, 23 Jan 2013 02:43:01 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


Message #20 received at 13530 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Bernhard Voelker <mail <at> bernhard-voelker.de>
Cc: Lei Zhang <lei.zhang <at> uwaterloo.ca>, 13530 <at> debbugs.gnu.org
Subject: Re: bug#13530: head: memory exhausted when printing all from stdin
	but last P/E bytes
Date: Wed, 23 Jan 2013 13:27:15 +0000
On 01/23/2013 01:21 PM, Bernhard Voelker wrote:
> On 01/23/2013 02:03 PM, Pádraig Brady wrote:
>> On 01/23/2013 12:53 PM, Bernhard Voelker wrote:
>>> head doesn't "allocate everything up front" - instead, it only
>>> allocates the pointer array which would hold the actual data.
>>
>> Sure. I was wondering whether that should change
>> to allocate everything up front so as to exit early.
>
> I think that's not a good idea because head would ENOMEM
> even if it doesn't wouldn't need the memory (depending on the
> input). Why should the following fail?
>
>    $ echo 123 | head -c -T
>
> I think there's no reason to fail until we really know it would
> fail. In this case, we can only know it when we actually come
> to the point when we need the memory.
>
> It doesn't matter if we have
>    $ echo 123 | head -c -10
> or
>    $ echo 123 | head -c -P

Yes my point is that the above could be a problem at:

today    | head -c -P # This noop is OK
tomorrow | head -c -P # If we actually send lots of data we fail

cheers,
Pádraig.




This bug report was last modified 12 years and 42 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.