Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f0752d0a-02b0-4de0-8468-df3364d88c19@cs.ucla.edu>
Date: Tue, 17 Jun 2025 08:28:07 -0700
From: Paul Eggert <eggert@...ucla.edu>
To: Rich Felker <dalias@...c.org>
Cc: Alejandro Colomar <alx@...nel.org>, Florian Weimer <fweimer@...hat.com>,
 Adhemerval Zanella Netto <adhemerval.zanella@...aro.org>,
 musl@...ts.openwall.com, libc-alpha@...rceware.org,
 Joseph Myers <josmyers@...hat.com>, наб
 <nabijaczleweli@...ijaczleweli.xyz>, Robert Seacord <rcseacord@...il.com>,
 Bruno Haible <bruno@...sp.org>, bug-gnulib@....org,
 JeanHeyd Meneide <phdofthehouse@...il.com>, enh <enh@...gle.com>
Subject: Re: Re: BUG: realloc(p,0) should be consistent with malloc(0)

On 2025-06-17 07:51, Rich Felker wrote:

> I'm not sure what you mean by "not having heard anyone but you bring
> this up in the last 15 years". This has been a recurring issue

+1.


> One thing I kinda would like to think about is if there's a way we can
> signal at compile-time (without run tests that don't work for cross
> compiling) that realloc is non-broken and doesn't need gnulib-style
> wrapping/replacement.

That would help. Gnulib's gl_FUNC_REALLOC_0_NONNULL currently has some 
painful hacks (see below) that we hope work even for cross-compiling, 
for most platforms. But not everyone can or does use Gnulib, and it 
would be nice if glibc and other platforms would tell us their behavior 
in a standard way, to lessen our dependence on chewing gum and hope.

Even better, I'd like a simple way to tell glibc and bionic "Make 
realloc (p, 0) return nonnull on success" and have it just work, without 
all this rickety fooraw.

Here are some of the hacks Gnulib now uses for cross-compiles.

> # Modules that use this macro directly or indirectly should depend               
> # on extensions-aix, so that _LINUX_SOURCE_COMPAT gets defined                   
> # before this macro gets invoked.  This helps if !(__VEC__ || __AIXVEC),         
> # and doesn't hurt otherwise.                                                    
> ...>        [AS_CASE([$host_os],
>           [# Guess yes on platforms where we know the result.                    
>            freebsd* | netbsd* | openbsd* | darwin* | bitrig* \
>            | *-musl* | midipix* | midnightbsd* \
>            | hpux* | solaris* | cygwin*],
>             [gl_cv_func_realloc_0_nonnull="guessing yes"],
>           [# Guess as follows if we don't know.                                  
>            gl_cv_func_realloc_0_nonnull=$gl_cross_guess_normal])])])

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.