Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <kpf3dyqurk7abwmwv2o46huc7hdp6jtctnojtkl55tlk2kcssz@h342n2tbhz7h>
Date: Thu, 6 Nov 2025 22:53:11 +0100
From: Alejandro Colomar <alx@...nel.org>
To: Thiago Macieira <thiago@...ieira.org>
Cc: Rich Felker <dalias@...c.org>, 
	Demi Marie Obenour <demiobenour@...il.com>, musl@...ts.openwall.com, 
	The 8472 <the8472.rs@...inite-source.de>, Florian Weimer <fw@...eb.enyo.de>, libc-alpha@...rceware.org, 
	Arthur O'Dwyer <arthur.j.odwyer@...il.com>, Jonathan Wakely <jwakely@...hat.com>
Subject: Re: Re: realloci(): A realloc() variant that works in-place

Hi Thiago,

On Wed, Nov 05, 2025 at 09:38:42AM -0800, Thiago Macieira wrote:
> On Wednesday, 5 November 2025 03:24:14 Pacific Standard Time Alejandro Colomar 
> wrote:
> > Agree.  Before adding realloci(), I'd like to see numbers.  An
> > interesting thing to do would be to see some application that uses
> > realloc(3) currently, and check how often realloc(3) doesn't move the
> > object.  (To test that without UB, one needs to do the trick with
> > uintptr_t.)
> 
> I can give you some numbers for realloc() success, with the understanding that 
> they are NOT AT ALL the cases where realloci() would be used. I can't emit a 
> realloc() call that MAY relocate an an array of objects, if the objects don't 
> allow relocating. That would crash the application on the first time realloc() 
> did relocate. So I can only do it for the cases where the implementation would 
> keep using realloc() in the future.
> 
> The only way to test how often realloci() would succeed is to have realloci().
> 
> Anyway, my test is running qtcreator. Remember that it called the placeholder 
> function that would call realloci() 119 times just for running --help.
> 
> It also called QArrayData::reallocateUnaligned() with objectSize > 4 a total 
> of 1577 times, in 115 of which realloc() returned the same pointer (7.3%). In 
> fact, a quick glimpse of the gdb output shows that the same pointer succeed in 
> growing more than once in a row: I see a pointer at least 4x twice in a row, 
> with an increased capacity parameter, suggesting that it's the same array. 
> 
> In the full run (without --help), realloc() extended in place 1045 out of 
> 10088 calls, increasing to 10.3% extension success rate.

Thanks!  10% sounds useful enough IMO.  That's motivation enough for me
to write the proposal for ISO C, and continue working on the musl
patches.


Have a lovely night!
Alex

-- 
<https://www.alejandro-colomar.es>
Use port 80 (that is, <...:80/>).

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

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.