[PATCH 1/2] setjmp: Use BSD sematic as default for setjmp

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Tue Aug 1 13:51:40 GMT 2023



On 01/08/23 05:35, Florian Weimer wrote:
> * Adhemerval Zanella via Libc-alpha:
> 
>> POSIX relaxed the relation of setjmp/longjmp and the signal mask
>> save/restore, meaning that setjmp does not require to be routed to
>> _setjmp to be standard compliant.
>>
>> This is done to avoid breakage of SIGABRT handlers, since to fully
>> make abort AS-safe, it is required to remove the recurisve lock
>> used to unblock SIGABRT prior raised the signal.
>>
>> Also, it allows caller to actually use setjmp, since from
>> 7011c2622fe3e10a29dbe74f06aaebd07710127d the symbol is unconditionally
>> routed to _setjmp.
> 
> Doesn't this have non-trivial performance impact?

Yes, it is two extra sigprocmask to get/set the signal mask.  This is not 
*strictly* required, but the SIGABRT on abort generates racy conditions on
process creation and.  This patch can be dropped, but it would mean that
to get expected semantic for abort handlers will need to use sigsetjmp (..., 1)
instead of setjmp. 


More information about the Libc-alpha mailing list