[patch] Fix BZ 23187 -- stack overflow for many Phdr[]s

Adhemerval Zanella adhemerval.zanella@linaro.org
Tue May 22 20:50:00 GMT 2018



On 22/05/2018 17:25, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> What about use dynarray for this as below.  The initial sizes are still
>> arbitraty and should cover most common cases, but I do not have a strong
>> opinion here (they have total stack usage of 384 bytes for loadcmd_list
>> and 896 for phdr_list on 64 bits architectures).
> 
> dynarray is not compatible with the dl-minimal.c malloc implementation.
> realloc in particular contains this:
> 
>   assert (ptr == alloc_last_block);
> 

At least for this specific usage where only there is only DYARRAY_resize
operation it works (no regression on glibc testcase), although I am not
sure it is the best way to accomplish it. How hard would adapt dl-minimal.c
malloc to work with dynarray?

> 
> Should we use a scratch buffer? Which has constant size and can be expanded
> only if required?

The advantage of dynarray is it provides a slight better typed api with
ties better a list/array abstraction, but for this usage I think a 
scratch_buffer is doable.



More information about the Libc-alpha mailing list