[PATCH] malloc: Make sure tcache_key is not 0

Wilco Dijkstra Wilco.Dijkstra@arm.com
Wed Jul 30 08:57:14 GMT 2025


Hi Florian,

> Is the issue that tcache_key == 0 is wrong from an algorithmic point of
> view?

Zero has always been used as a value that cannot be a valid key (it would
catastrophically bad for performance), but now it results in an endless loop.

Basically the assumption for the "key" is that it is not a commonly occurring value
in memory. So we should exclude small positive/negative values and anything
that doesn't appear random enough to be used (eg. check popcount is between
24 and 40).

Cheers,
Wilco



More information about the Libc-alpha mailing list