bug-coreutils
[Top][All Lists]
Advanced

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

bug#9762: tac fails when given multiple non-seekable inputs due to misus


From: Paul Eggert
Subject: bug#9762: tac fails when given multiple non-seekable inputs due to misuse of mkstemp()
Date: Tue, 18 Oct 2011 09:08:56 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110928 Fedora/3.1.15-1.fc14 Thunderbird/3.1.15

On 10/18/11 05:38, Jim Meyering wrote:
> * src/tac.c (temp_stream): Don't exit immediately upon failed heap
> allocation, here.  That would inhibit processing of any additional
> command-line arguments.

It doesn't matter that much either way here, but in general I'm
leery about any attempt to do useful work after a memory allocation
failure in C.  The output of 'tac' will be wrong anyway, and many
users would prefer 'tac' to simply exit, than to go on and generate
a much larger (but still wrong) output, consuming needless resources.

Also (as my recent experiences with Emacs have shown),
once malloc has failed, other code can start to go wrong,
including library code that we have no control over.  Sometimes
the failures are subtle, and sometimes they're spectacular; either
way it's typically better to steer clear of that particular chasm.

After malloc fails, Emacs typically enters a "restricted" mode,
where it first releases a memory reserve, and then continually
asks you to save your work and exit as soon as possible.  This
is good advice, and even then one is not entirely sure of exiting
safely.





reply via email to

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