[PATCH v12 1/2] malloc: add tcache support for large chunk caching

Cupertino Miranda cupertino.miranda@oracle.com
Tue Jul 8 17:15:54 GMT 2025


Hi everyone,

After analyzing my patch, I could not find any location that would 
justify the hang in scanimage, when !USE_TCACHE was set.

I took commit daab2a6d19f8360248289840408e7d2e5c203c2e and built glibc 
with !USE_TCACHE.
I removed any calls to malloc_printerr_tail, which fail to build when 
!USE_TCACHE.
Well, scanimage was still hanging.

I get the feeling that my patch might expose the problem but might not 
be the root cause.

In my machine it hangs almost instantly.
Florian: Can you please verify this claim ?

I will try to bisect it further.

Thanks,
Cupertino

On 08-07-2025 17:38, Cupertino Miranda wrote:
> Just to confirm ... hang still happens after the fix.
> Will focus on any code outside USE_TCACHE.
> 
> Cheers,
> Cupertino
> 
> On 08-07-2025 17:06, Cupertino Miranda wrote:
>> That certainly is wrong!
>> Dammit !
>>
>> I am able to reproduce the hang.
>> Will fix it and retry!
>>
>> Thanks,
>> Cupertino
>>
>> On 08-07-2025 16:57, Wilco Dijkstra wrote:
>>> Hi Cupertino,
>>>
>>> It looks like you didn't address my comment here (from v9):
>>>
>>>> +# define TCACHE_SMALL_BINS             64
>>>> +# define TCACHE_LARGE_BINS             12 /* Up to 4M chunks */
>>>> +# define TCACHE_MAX_BINS       (TCACHE_SMALL_BINS + TCACHE_LARGE_BINS)
>>>> +# define MAX_TCACHE_SMALL_SIZE tidx2usize (TCACHE_MAX_BINS-1)
>>>>
>>>> Small bins surely???
>>>>
>>>
>>> So the committed version uses tcache up to around 1216 bytes instead 
>>> of 1036, which
>>> would mean the large bins are being used accidentally. This doesn't 
>>> seem like it
>>> should cause bugs in that there is always another check with 
>>> TCACHE_SMALL_BINS for
>>> small tcache, however there could be issues in large tcache code.
>>>
>>> Not sure how it could explain the hang Florian was seeing though, 
>>> especially since it
>>> apparently still happens with tcache turned off?
>>>
>>> Cheers,
>>> Wilco
>>
> 



More information about the Libc-alpha mailing list