Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1aaa9a0f-8425-4c48-8698-65a3765a67a2@cs.ucla.edu>
Date: Fri, 20 Jun 2025 18:34:25 -0700
From: Paul Eggert <eggert@...ucla.edu>
To: Alejandro Colomar <alx@...nel.org>, Thorsten Glaser <tg@...bsd.de>
Cc: libc-alpha@...rceware.org, bug-gnulib@....org, musl@...ts.openwall.com,
 наб <nabijaczleweli@...ijaczleweli.xyz>,
 Douglas McIlroy <douglas.mcilroy@...tmouth.edu>,
 Robert Seacord <rcseacord@...il.com>, Elliott Hughes <enh@...gle.com>,
 Bruno Haible <bruno@...sp.org>, JeanHeyd Meneide <phdofthehouse@...il.com>,
 Rich Felker <dalias@...c.org>,
 Adhemerval Zanella Netto <adhemerval.zanella@...aro.org>,
 Joseph Myers <josmyers@...hat.com>, Florian Weimer <fweimer@...hat.com>,
 Laurent Bercot <ska-dietlibc@...rnet.org>, Andreas Schwab <schwab@...e.de>,
 Eric Blake <eblake@...hat.com>, Vincent Lefevre <vincent@...c17.net>,
 Mark Harris <mark.hsj@...il.com>, Collin Funk <collin.funk1@...il.com>,
 Wilco Dijkstra <Wilco.Dijkstra@....com>, DJ Delorie <dj@...hat.com>,
 Cristian Rodríguez <cristian@...riguez.im>,
 Siddhesh Poyarekar <siddhesh@...plt.org>, Sam James <sam@...too.org>,
 Mark Wielaard <mark@...mp.org>, "Maciej W. Rozycki" <macro@...hat.com>,
 Martin Uecker <ma.uecker@...il.com>,
 Christopher Bazley <chris.bazley.wg14@...il.com>, eskil@...ession.se
Subject: Re: alx-0029r1 - Restore the traditional realloc(3) specification

On 2025-06-20 18:06, Alejandro Colomar wrote:
> 	+       to both return a null pointer and set errno to ENOMEM.

Given the proposed change, I don't see why ENOMEM must be added to the C 
spec. The spec changes malloc and realloc so that returning null means 
failure (i.e., out of memory) and returning non-null means success. In 
that case, there seems to be no pressing need for ENOMEM in the C 
standard (as opposed to POSIX).

If ENOMEM is really needed, its presence should be justified in the 
proposal. Alternatively, the proposal could be divided into two: the 
main proposal is the null-if-and-only-if-failure part, and ENOMEM could 
be the secondary proposal.

One other thing: Doug McIlroy's point was that realloc(p,n) should never 
fail when p already addresses storage of size n or greater. As a 
corollary, realloc(p,0) should never fail when p is non-null. It might 
be helpful to add this as a third proposal. A lot of apps already assume 
McIlroy's point, after all.

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.