public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Re: [RFC PATCH] malloc_usable_size.3: Warn about _FORTIFY_SOURCE interaction
@ 2023-04-05 13:55 Wilco Dijkstra
  2023-04-05 21:00 ` Alejandro Colomar
  0 siblings, 1 reply; 6+ messages in thread
From: Wilco Dijkstra @ 2023-04-05 13:55 UTC (permalink / raw)
  To: Alejandro Colomar (man-pages); +Cc: 'GNU C Library', Siddhesh Poyarekar

Hi Alejandro,

> and the header where we define a wrapper macro, which contains several
> comments about assumptions made about different libc implementations:
> 
> <https://github.com/nginx/unit/blob/c54331fa3d9597ba6bc85e7b7242981f00ed25c2/src/nxt_malloc.h#L35>
> 
> I hope that tells you something.  It doesn't tell me anything, but I'm
> not used to fiddling with allocators.  :)

This looks rather worrying - it seems to deliberately use a malloc size that is too
small in the hope that the particular malloc implementation allocates a bit more
and then use that extra space. So every malloc call now needs extra checks to
adjust the size and another call to malloc_usable_size which then needs to be
checked to be larger than the original requested size...

So basically they are trying to save 32 bytes in blocks larger than 128KB
(a whopping 0.024%!!!) by adding ~64 bytes of extra code per malloc call plus
lots of extra executed instructions...

This kind of stupidity convinces me even more that we need to obsolete
malloc_usable_size - people clearly cannot use it properly or avoid
hardcoding internal implementation details which could change at any time.

Cheers,
Wilco

^ permalink raw reply	[flat|nested] 6+ messages in thread
[parent not found: <CAD66C+YQKWJQNv2i=8+BuL3Z5NzDQsG-1izhVxZ549xhMTTUjA@mail.gmail.com>]

end of thread, other threads:[~2023-04-05 21:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-05 13:55 [RFC PATCH] malloc_usable_size.3: Warn about _FORTIFY_SOURCE interaction Wilco Dijkstra
2023-04-05 21:00 ` Alejandro Colomar
     [not found] <CAD66C+YQKWJQNv2i=8+BuL3Z5NzDQsG-1izhVxZ549xhMTTUjA@mail.gmail.com>
2023-04-04 11:42 ` Siddhesh Poyarekar
2023-04-05  0:51   ` Sam James
2023-04-05  2:35   ` Alejandro Colomar
2023-04-05 12:58     ` Siddhesh Poyarekar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).