[PATCH v8 3/6] Fix assert during static startup (BZ 33326)
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Mon Mar 30 15:15:57 GMT 2026
On 20/03/26 08:08, Florian Weimer wrote:
> * Adhemerval Zanella:
>
>> The BZ#33326 testcase triggers an assertion during process startup,
>> which results in a segmentation fault instead of an error message
>> and process termination with a SIGABRT. The assert issues
>> __libc_message_impl, which in turn might call string functions
>> depending on the ABI (strchrnul, strlen, memcpy/mempcpy), system
>> calls (writev and mmap), and finally the abort call.
>>
>> Since each function may be called during process startup, before
>> self-relocation and/or the thread pointer being set up, the
>> functions should be built without stack protection.
>>
>> The dl-symbol-redir-ifunc.h is also expanded to cover
>> strlen/memcpy/mempcpy/strchrnul on multiple architectures that implement
>> ifunc.
>>
>> On i386, syscalls should not use the vDSO ("call *%gs:SYSINFO_OFFSET")
>> during program statuup because thread pointer is not yet initialized. This
>
> Typo: sta[r]tu[]p
>
> Perhaps: becahse [the] thread pointer
Ack.
>
>> diff --git a/elf/Makefile b/elf/Makefile
>> index 7f039b5563..29d771ef7a 100644
>> --- a/elf/Makefile
>> +++ b/elf/Makefile
>
>> +tests-special += \
>> + $(objpfx)tst-assert-startup-static.out \
>> + # tests-special
>> +
>
> Uhm, this doesn't seem to be in a region of the makefile that is
> conditional on run-built-tests? So it would cause build-many-glibcs.py
> failures?
Indeed, I will add a run-built-tests if check here.
>
>> @@ -3532,7 +3537,6 @@ $(objpfx)tst-origin.out: tst-origin.sh $(objpfx)tst-origin
>>
>> $(objpfx)tst-dlopen-sgid.out: $(objpfx)tst-dlopen-sgid-mod.so
>>
>> -
>> ifeq ($(run-built-tests),yes)
>
> Spurious whitespace change.
Ack.
>
>> diff --git a/elf/tst-assert-startup-static.c b/elf/tst-assert-startup-static.c
>> new file mode 100644
>> index 0000000000..a3312cd9e5
>> --- /dev/null
>> +++ b/elf/tst-assert-startup-static.c
>
>> +void __tunables_init (char **env)
>> +{
>> +/* The assert called by the loader/startup issues __libc_assert_fail instead
>> + of __libc_assert, and __libc_assert_fail does issues the translation
>> + routines (which would require additional handling to be called at this
>
> Maybe: … instead of __[]assert[_fail], and __libc_assert_fail does [not]
> perform [] translation[] (which …
>
Ack.
Are you ok with the above remarks fixed? I will move the last patch
(elf: Raise SIGABRT for assert within ld.so) out of this serie since
it might require some more discussion.
More information about the Libc-alpha
mailing list