[PATCH] libc_fatal: Get rid of alloca

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Thu Aug 31 17:39:38 GMT 2023



On 31/08/23 14:29, Florian Weimer wrote:
> * Adhemerval Zanella Netto via Libc-alpha:
> 
>> On 31/08/23 11:04, Joe Simmons-Talbott via Libc-alpha wrote:
>>> On Thu, Aug 31, 2023 at 04:00:34PM +0200, Andreas Schwab wrote:
>>>> On Aug 31 2023, Joe Simmons-Talbott wrote:
>>>>
>>>>> I guess an option would be to use a fixed sized array with a judiciously
>>>>> selected size to store the structs.  I think this would work since there
>>>>> are not a lot of calls to __libc_message and none with more than a few
>>>>> '%s'.  Thoughts?
>>>>
>>>> How does that differ from using alloca?
>>>
>>> I guess it really doesn't other than avoiding possible stack overflow
>>> which seems unlikely.
>>>
>>> Thanks,
>>> Joe
>>>
>>
>> Maybe a better option would to evaluate each '%s' and call multiple writes
>> instead of one single writev.  You can maybe add support for %d, so we can
>> simplify __libc_assert_fail to be tail call to __libc_message.
> 
> I think it should be a single write or writev, so that the message
> doesn't get split.

So either we continue to use alloca or limit the maximum number of varargs.
Since it is an internal function, I think later should be feasible. 


More information about the Libc-alpha mailing list