Oh how I sometimes wish we'd never opened the can of worms WRT stack
clash protection of noreturn functions.

In this BZ we have a noreturn function.  So we trigger the special bits
to emit a push/pop sequence to explicitly probe *sp.  For ia32 we
push/pop %esi.

The pop %esi tells the generic CFI machinery that %esi's value is
returned to its state in the caller.  But that's not entirely correct as
the value will be over written in the body of the function.

This situation shows up in some of the nptl code within glibc
(pthread_unwind).  This in turn is believed to cause giac to behave
improperly.

--

It's fairly obvious that the probe of *sp isn't actually necessary here
because the register saves in the prologue act as probe points for *sp.

In fact, the only way this can ever cause problems is if %esi is used in
the body in which case it would have been callee saved in the prologue.
So if we detect that %esi is already callee saved in the prologue then
we could eliminate the explicit probe of *sp.

But we can do even better.  If any register is saved in the prologue,
then that callee register save functions as an implicit probe of *sp and
we do not need to explicitly probe *sp.

While this was reported with -m32, I'm pretty sure we can trigger a
similar issue on x86_64.

Bootstrapped and regression tested on x86_64.  Also verified the
testcase behavior on -m32.  The test uses flags to hopefully ensure
expected behavior on x86/Solaris, but I did not explicitly test that
configuration.

OK for the trunk?

Jeff

Reply via email to