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]

Re: array bound violation in reg-stack.c


  In message <199907161921.UAA02927@net.HCC.nl>you write:
  > Hello,
  > 
  > I am currently working on using bounds-checking on gcc itself. I found
  > a problem in reg-stack.c. The problem is with the statement (in change_stac
  > k):
  > 
  > while (old->reg[old->top] != new->reg[new->top])
  > 
  > The value of 'old->top' and 'new->top' can be -1. This will result
  > in some random data being used for the compare. This problem is present
  > since gcc-2.7.2.1.
  > The patch to fix this is simple:
  > 
  > 1999-07-13 Herman A.J. ten Brugge <Haj.Ten.Brugge@net.HCC.nl>
  > 
  >         * reg-stack.c (change_stack) Fixed problem with negative array inde
  > x.
  > 
  > --- reg-stack.c.org	Tue Jul 13 18:21:58 1999
  > +++ reg-stack.c	Tue Jul 13 18:47:18 1999
  > @@ -2647,7 +2647,7 @@ change_stack (insn, old, new, when)
  >  	 other regs.  But since we never swap any other reg away from
  >  	 its correct slot, this algorithm will converge.  */
I will not install this patch without a better explanation of the problem.

You need to describe how you get to this condition and explain why it is
valid to have a value of -1 for new->top at this point in the code.

It would also be a significant benefit if you could provide a testcase.

jeff


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