[PATCH v2 3/5] elf: Replace alloca with dl_scratch_buffer in _dl_load_cache_lookup

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Mon May 18 17:26:52 GMT 2026



On 15/05/26 19:00, H.J. Lu wrote:
>> +
>> +static int
>> +do_test (void)
>> +{
>> +  /* Sanity: from the main thread (no stack pressure needed).  */
>> +  dlopen_via_cache (NULL);
>> +
>> +  /* The motivating scenario: from a PTHREAD_STACK_MIN thread.  Before
>> +     _dl_load_cache_lookup was converted to dl_scratch_buffer this would
>> +     have alloca'd ~3 KB mid-dlopen and risked overflowing.  */
>> +  size_t stacksize =
>> +#ifdef PTHREAD_STACK_MIN
>> +    PTHREAD_STACK_MIN;
>> +#else
>> +    support_small_thread_stack_size ();
> 
> Shouldn't we use support_small_thread_stack_size unconditionally?
The main issue with support_small_thread_stack_size is it defines a quite large
thread stack, which would require to add a 'slack' stack usage on each test
to triggers the stack overflow on unpatched libc.

Also, from the original commit (36ada9ee2cd3b686df6952446b92816584eacbb8) it
is not clear what exactly does not work with PTHREAD_STACK_MIN. I guess that
would be some features that add some under the hood allocation like 
pthread_cancel (through libgcc_s.so dlopen), but I think we should also check
whether the support_small_thread_stack_size is really required for some tests.


More information about the Libc-alpha mailing list