This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA]: Fix serious ultrasparc return bug (corrupted return value)


On Fri, Dec 07, 2001 at 11:39:31AM +0100, Stephane Carrez wrote:
> We have found a serious bug for gcc-ultrasparc in the return
> of some functions.  The problem is that gcc generates sequences like:
> 
> 	return	%i7+8
> 	ld	[%sp-20], %o0
> 
> and the load instruction is reading below the stack which is very bad.
> Since this sequence of instruction is not atomic, when an interrupt
> (Kernel) or a signal (User) is handled after the 'return', the stack
> can be modified, thus resulting in a wrong value returned by the function.

Simply forbidding %fp in delay slot of return will ban even completely valid
delay slots:

int bar (int a, int b, int c, int d, int e, int f, int g, int h)
{
  int res;

  toto (&res);
  return h;
}

Thus IMHO you should check for this in something like:
case PLUS:
  if (GET_CODE (XEXP (*where, 0)) == REG
      && REGNO (XEXP (*where, 0)) == FRAME_POINTER_REGNUM
      && (GET_CODE (XEXP (*where, 1)) != CONST_INT
	  || INTVAL (XEXP (*where, 1)) < 0))
    return 1;
  break;

instead.
Also, a testcase in gcc.dg with scan-assembler for this would be very
helpful.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]