When and why realloc(,0) was broken in glibc in 1999
Alejandro Colomar
alx@kernel.org
Mon Aug 3 13:51:29 GMT 2026
Hi Maciej,
> Date: 2026-08-02 22:23:36+0100
> From: "Maciej W. Rozycki" <macro@orcam.me.uk>
>
> On Sun, 2 Aug 2026, Alejandro Colomar wrote:
>
> > The original implementation in glibc would have been con‐
> > forming to C99. However, and ironically, trying to comply
> > with C99 before the standard was released, glibc changed
> > its behavior in glibc 2.1.1 into something that ended up
> > not conforming to the final C99 specification (but this is
> > debated, as the wording of the standard seems self‐contra‐
> > dicting).
>
> Well, this was a period when glibc was driven by personal preferences of
> one particular maintainer, so I don't think it is a good example in this
> discussion.
Just to clarify something about this, to which I didn't reply before:
we can't blame Drepper for this bug.
In this case, there was a discussion in the mailing list, and there was
no discrepancy against this change.
<https://sourceware.org/pipermail/libc-alpha/1999-April/000956.html>
It's just a case of a discussion that happened with incomplete
information, and which favoured standards conformance over common sense.
In fact, I was surprised when I learnt about this case, because I would
have expected Drepper to ignore the standard for being bogus.
Jonathan Larmour correctly noted in that discussion that glibc was not
conforming to C89.
<https://sourceware.org/pipermail/libc-alpha/1999-April/002394.html>
This finding from Jonathan should have triggered some more research, but
they didn't.
Roland McGrath pointed out his understanding of the (ambiguous) C89
specification, and claimed that it was a bug in glibc (and thus he seems
to have been in favour of the "fix" too).
<https://sourceware.org/pipermail/libc-alpha/1999-April/000958.html>
Interestingly, he claimed that it was a recently introduced bug, but as
far as I know, the glibc behavior had been unchanged before that.
It seems it was Roland McGrath who pushed for the idea that consistency
wasn't paramound, and that standards conformance was.
<https://sourceware.org/pipermail/libc-alpha/1999-April/002398.html>
Then Drepper did that change, and in his head it was consistent.
<https://sourceware.org/pipermail/libc-alpha/1999-April/000963.html>
It clearly isn't consistent, but it's understandable that he didn't see
it back then.
Wolfram Gloger seemed to be convinced that Drepper's change was
consistent (even if it isn't).
<https://sourceware.org/pipermail/libc-alpha/1999-April/002401.html>
For some reason, nobody in that group analyzed this carefully enough.
I guess it was inertia. We can't blame Drepper (alone) for this bug.
Have a lovely day!
Alex
--
<https://www.alejandro-colomar.es>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20260803/075e3da4/attachment.sig>
More information about the Libc-alpha
mailing list