bug-diffutils
[Top][All Lists]
Advanced

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

Re: [bug-diffutils] Memory leak and memory errors in cmp


From: Paul Eggert
Subject: Re: [bug-diffutils] Memory leak and memory errors in cmp
Date: Fri, 16 Aug 2013 13:05:31 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130803 Thunderbird/17.0.8

Thanks, but it's not really a memory leak, as cmp is about
to exit anyway; the only point of calling 'free'
would be to waste some CPU time to pacify valgrind.

The memory error is a false alarm too.  'cmp' is deliberately
accessing uninitialized storage as part of an optimization,
where it reads word-by-word instead of byte-by-byte.
On practical platforms no bug can occur there.

Perhaps from a theoretical point of view there is a bug,
since the C standard says behavior is undefined when a
program accesses a word that contains an uninitialized byte,
but even if we initialized those bytes the behavior
would still be undefined (since the word could be a trap
representation).  There's little point to slowing down
'cmp' to pacify just one theoretical objection, when there
other objections are equally fatal in theory.

For what it's worth, to "fix" the memory error you can compile
with -Dword='unsigned char', albeit at some performance cost.



reply via email to

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