Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 19 Sep 2022 22:17:02 +0200
From: Joakim Sindholt <>
Subject: Re: The heap memory performance (malloc/free/realloc) is
 significantly degraded in musl 1.2 (compared to 1.1)

On Tue, 20 Sep 2022 03:45:35 +0800, baiyang <> wrote:
> > The only correct value malloc_usable_size can return is the value you passed to the allocator. 
> I don't think so, see:
> Linux man page: - "The value returned by malloc_usable_size() may be **greater than** the requested size of the allocation".
> Mac OS X man page: - "The memory block size is always at least as large as the allocation it backs, **and may be larger**."
> FreeBSD man page: - "The return value **may be larger** than the size that was requested during allocation".
> These official man pages clearly state that the return value of malloc_usable_size is the size of the memory block allocated internally, not the size submitted by the user. 
> Instead, we didn't find any documentation saying that the return value of malloc_usable_size must be the size submitted by the user to be correct. Please correct me if you have the relevant documentation.

It's not that malloc_usable_size must return the size originally
submitted by the user but that if it doesn't and you take that as an
invitation to exceed the original size allocated you will hit UB.

Simple case:
Real world example:

And the reason why is pretty simple:
> The malloc function allocates space for an object whose size is
> specified by size and whose value is indeterminate.

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.