Invalid program counters and unwinding

Florian Weimer fweimer@redhat.com
Mon Jan 1 00:00:00 GMT 2018


On 06/26/2018 01:35 PM, Nathan Sidwell wrote:
> On 06/26/2018 07:21 AM, Florian Weimer wrote:
> 
>> GCC doesn't do this AFAIK, but it's theoretically possible not to 
>> preserve the return address for a noreturn function.  But that would 
>> be very bad for exception handling, so let's hope compilers don't do 
>> this.
> 
> I'd forgotten about noreturn.  Such functions may terminate by throwing 
> an exception (and for our purposes I think pthread_cancel implementatio 
> is sufficiently exception-like):
> 
> from C++ std:  [dcl.attr.noreturn]/2 [ Note: The function may terminate 
> by throwing an exception. — end note ]
> 
> and from doc/extend.texi:
> 
> The @code{noreturn} keyword does not affect the exceptional path
> when that applies: a @code{noreturn}-marked function may still
> return to the caller by throwing an exception or calling
> @code{longjmp}.
> 
> IIRC, in gcc-land you have to give both noreturn and nothrow attributes 
> to make it non-unwindable.

Are you sure?  I was under the impression that GCC did not do this 
because it interferes too much with debugging.

Furthermore, glibc marks abort as nothrow and noreturn, which is a bit 
dubious, considering that it is perfectly fine to throw exception from 
synchronously delivered signals.

Thanks,
Florian



More information about the Gnu-gabi mailing list