Ping: RFA: Testsuite fixes (1/3): builtin_apply
diff mbox

Message ID 20110925083521.gqkcy0xpw88ogg44-nzlynne@webmail.spamcop.net
State New
Headers show

Commit Message

Joern Rennecke Sept. 25, 2011, 12:35 p.m. UTC
This patch has not been reviewed for eight weeks.

----- Forwarded message from amylaar@spamcop.net -----
     Date: Mon, 01 Aug 2011 00:41:04 -0400
     From: Joern Rennecke <amylaar@spamcop.net>
Reply-To: Joern Rennecke <amylaar@spamcop.net>
  Subject: RFA: Testsuite fixes (1/3): builtin_apply
       To: gcc-patches@gcc.gnu.org

I am working with a toolchain that is frugal with stack usage at startup, so
an attempt to read dozens more bytes than have been pushed causes unmapped
memory references.

Fixed by adding an automatic variable that occupies sufficient space.

Regression tested with x86_64-unknown-linux-gnu X sh-elf .
No change there, as the default SH liker script places the stack at 3M,
and the default simulator size is 16M.


----- End forwarded message -----
2011-07-21  Joern Rennecke <joern.rennecke@embecosm.com>

	* gcc.dg/torture/stackalign/builtin-apply2.c:
	Make sure we don't read past the bottom of the stack.

2009-09-24  Joern Rennecke <joern.rennecke@embecosm.com>

	* gcc.dg/builtin-apply2.c: Make sure we don't read past the bottom of
	the stack.

Comments

Richard Biener Sept. 25, 2011, 5:02 p.m. UTC | #1
On Sun, Sep 25, 2011 at 2:35 PM, Joern Rennecke <amylaar@spamcop.net> wrote:
> This patch has not been reviewed for eight weeks.
>
> ----- Forwarded message from amylaar@spamcop.net -----
>    Date: Mon, 01 Aug 2011 00:41:04 -0400
>    From: Joern Rennecke <amylaar@spamcop.net>
> Reply-To: Joern Rennecke <amylaar@spamcop.net>
>  Subject: RFA: Testsuite fixes (1/3): builtin_apply
>      To: gcc-patches@gcc.gnu.org
>
> I am working with a toolchain that is frugal with stack usage at startup, so
> an attempt to read dozens more bytes than have been pushed causes unmapped
> memory references.
>
> Fixed by adding an automatic variable that occupies sufficient space.
>
> Regression tested with x86_64-unknown-linux-gnu X sh-elf .
> No change there, as the default SH liker script places the stack at 3M,
> and the default simulator size is 16M.
>
>
> ----- End forwarded message -----
>
>
> 2011-07-21  Joern Rennecke <joern.rennecke@embecosm.com>
>
>        * gcc.dg/torture/stackalign/builtin-apply2.c:
>        Make sure we don't read past the bottom of the stack.
>
> 2009-09-24  Joern Rennecke <joern.rennecke@embecosm.com>
>
>        * gcc.dg/builtin-apply2.c: Make sure we don't read past the bottom of
>        the stack.
>
> Index: gcc.dg/torture/stackalign/builtin-apply-2.c
> ===================================================================
> --- gcc.dg/torture/stackalign/builtin-apply-2.c
> (.../GNU/fsf-gcc/trunk/gcc/testsuite)   (revision 2013)
> +++ gcc.dg/torture/stackalign/builtin-apply-2.c
> (.../Customer-Projects/X/branches/Y-20110628/toolchain/gcc-4.7.0-20110701/gcc/testsuite)
>        (revision 2013)
> @@ -24,7 +24,10 @@ void bar(char *name, ...)
>
>  int main(void)
>  {
> -  bar("eeee", 5.444567, 8.90765, 4.567789, INTEGER_ARG);
> +  /* Make sure that there is some stack that can be legitimately read.  */
> +  char dummy[64];
> +
> +  bar(dummy, 5.444567, 8.90765, 4.567789, INTEGER_ARG);
>
>   return 0;
>  }
> Index: gcc.dg/builtin-apply2.c
> ===================================================================
> --- gcc.dg/builtin-apply2.c     (.../GNU/fsf-gcc/trunk/gcc/testsuite)
> (revision 2013)
> +++ gcc.dg/builtin-apply2.c
> (.../Customer-Projects/X/branches/Y-20110628/toolchain/gcc-4.7.0-20110701/gcc/testsuite)
>        (revision 2013)
> @@ -36,6 +36,9 @@ void bar(char *name, ...)
>
>  int main(void)
>  {
> +  /* Make sure that there is some stack that can be legitimately read.  */
> +  char dummy[64];
> +

How is this ever the correct thing to do?  Why doesn't this trigger
for user code as well?
It really looks like you are papering over backend issues here.

Richard.

>   bar("eeee", 5.444567, 8.90765, 4.567789, INTEGER_ARG);
>
>   return 0;
>
>
Joseph Myers Sept. 25, 2011, 5:04 p.m. UTC | #2
On Sun, 25 Sep 2011, Joern Rennecke wrote:

> I am working with a toolchain that is frugal with stack usage at startup, so
> an attempt to read dozens more bytes than have been pushed causes unmapped
> memory references.
> 
> Fixed by adding an automatic variable that occupies sufficient space.

Shouldn't you fix STACK_ARGUMENTS_SIZE, conditional on the target in use?  
(In gcc.dg/builtin-apply2.c; the other test would need such a definition 
added.)

Patch
diff mbox

Index: gcc.dg/torture/stackalign/builtin-apply-2.c
===================================================================
--- gcc.dg/torture/stackalign/builtin-apply-2.c	(.../GNU/fsf-gcc/trunk/gcc/testsuite)	(revision 2013)
+++ gcc.dg/torture/stackalign/builtin-apply-2.c	(.../Customer-Projects/X/branches/Y-20110628/toolchain/gcc-4.7.0-20110701/gcc/testsuite)	(revision 2013)
@@ -24,7 +24,10 @@  void bar(char *name, ...)
 
 int main(void)
 {
-  bar("eeee", 5.444567, 8.90765, 4.567789, INTEGER_ARG);
+  /* Make sure that there is some stack that can be legitimately read.  */
+  char dummy[64];
+
+  bar(dummy, 5.444567, 8.90765, 4.567789, INTEGER_ARG);
 
   return 0;
 }
Index: gcc.dg/builtin-apply2.c
===================================================================
--- gcc.dg/builtin-apply2.c	(.../GNU/fsf-gcc/trunk/gcc/testsuite)	(revision 2013)
+++ gcc.dg/builtin-apply2.c	(.../Customer-Projects/X/branches/Y-20110628/toolchain/gcc-4.7.0-20110701/gcc/testsuite)	(revision 2013)
@@ -36,6 +36,9 @@  void bar(char *name, ...)
 
 int main(void)
 {
+  /* Make sure that there is some stack that can be legitimately read.  */
+  char dummy[64];
+
   bar("eeee", 5.444567, 8.90765, 4.567789, INTEGER_ARG);
 
   return 0;