Invalid program counters and unwinding

Nathan Sidwell
Tue Jun 26 11:39:00 GMT 2018

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

IIRC, in gcc-land you have to give both noreturn and nothrow attributes 
to make it non-unwindable.

Nathan Sidwell

More information about the Gcc mailing list