Fix PR44281 (bad RA with global regs)

Mikael Pettersson mikpelinux@gmail.com
Mon Feb 29 19:46:00 GMT 2016


Michael Matz writes:
 > > > FWIW: signal handlers need no consideration (if they were allowed to
 > > > inspect/alter global reg vars we would have lost and no improvement on
 > > > fixed_regs[] could be done).  They are explicitely documented to not be
 > > > able to access global reg vars.  (They already can't accidentally clobber
 > > > the register in question because signal handlers don't do that)
 > > 
 > > Oh, they can't modify the register in question because the OS would 
 > > restore it?
 > 
 > Yep.

Well, almost.  While it is true that a signal handler cannot *accidentally*
clobber the register state of the interrupted thread, it can in fact access
and update any part of that state via the ucontext_t passed to it.  Doing so
is uncommon, but not unheard of and not even that difficult -- I've done it
myself in several different runtime systems.

The code in a signal handler cannot assume that global register variables
are in sync with the interrupted thread, or that plain assignments to them
are reflected back, but that's not GCC's fault, nor is it GCC's job to make
that happen.

/Mikael



More information about the Gcc-patches mailing list