This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Fix PR 9516
- From: "Christian Ehrhardt" <ehrhardt at mathematik dot uni-ulm dot de>
- To: p dot allix at ifrance dot com, gcc-bugs at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Sat, 5 Apr 2003 11:38:43 +0200
- Subject: PATCH: Fix PR 9516
- References: <20030404174841.22521.qmail@thales.mathematik.uni-ulm.de>
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9516
This PR is a stack overfow when initializing a very large array.
The problem is that the initializer is a TREE_LIST that is passed
to safe_from_p which handles TREE_LISTs recursivly. With the testcase
in the PR this is deadly if the stack size limit is around 50 Megabytes.
This patch removes the recursion. Bootstrapped and regtested on x86.
Can someone please commit this?
regards Christian
PR c/9516
* expr.c (safe_from_p): Don't recurse on TREE_LISTs.
Index: expr.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/expr.c,v
retrieving revision 1.517
diff -u -r1.517 expr.c
--- expr.c 1 Apr 2003 13:40:07 -0000 1.517
+++ expr.c 5 Apr 2003 09:11:29 -0000
@@ -6093,10 +6093,13 @@
case 'x':
if (TREE_CODE (exp) == TREE_LIST)
- return ((TREE_VALUE (exp) == 0
- || safe_from_p (x, TREE_VALUE (exp), 0))
- && (TREE_CHAIN (exp) == 0
- || safe_from_p (x, TREE_CHAIN (exp), 0)));
+ {
+ tree tmp;
+ for (tmp = exp; tmp; tmp = TREE_CHAIN (tmp))
+ if (TREE_VALUE (tmp) && safe_from_p (x, TREE_VALUE (tmp), 0))
+ return 0;
+ return 1;
+ }
else if (TREE_CODE (exp) == ERROR_MARK)
return 1; /* An already-visited SAVE_EXPR? */
else
--
THAT'S ALL FOLKS!