memory leak or something wrong

Marc Lehmann schmorp at schmorp.de
Tue Jun 19 14:27:55 CEST 2012


On Mon, Jun 18, 2012 at 05:04:34PM -0500, Brandon Black <blblack at gmail.com> wrote:
> Shortly after the last email, I noticed the realloc() docs in Fedora
> 16 contain this sentence about realloc():

Scary, they broke it.

The debian manpage is explicit though:

   if size is equal to zero, and ptr is not NULL, then the call is
   equivalent to free(ptr)

> http://lists.gnu.org/archive/html/bug-gnulib/2011-03/msg00243.html .

So it seems eglibc has broken it, and not glibc, at leats according tot he
glibc bug report, which strongly indicates that this is a defetc in the
standard (and it likely is, as the overwhelming behaviour on unices is for
relaloc to free).

> IMHO, in a world with that kind of mess going on, the new "safe"
> behavior for portable code may just be to never use realloc(p,0)
> because you can't trust what it means :(

Well, the code in libev isn't portable, it is glibc specific, and glibc
guarantees the correct behaviour. It is clearly a bug in glibc that needs to
be resolved.

While libev can (and should) work around this bug, this doesn't help any
of the other programs who rely on correct behaviour. It cannot be fixed in
libev.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the libev mailing list