This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/12640] [tree-ssa] strlen builtin causes stack overflow building tk
- From: "steven at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Nov 2003 18:22:22 -0000
- Subject: [Bug optimization/12640] [tree-ssa] strlen builtin causes stack overflow building tk
- References: <20031016144712.12640.green@redhat.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From steven at gcc dot gnu dot org 2003-11-12 18:22 -------
Small, smaller, smallest...
int i;
static void
SendEventProc (char *resultString)
{
char *p;
resultString = "";
while (*p == '-')
{
if (p[2] == ' ')
{
resultString = p + 3;
}
}
for (;;)
{
i = strlen (resultString) + 1;
}
}
The thing is that we have this PHI:
resultString_1 = PHI <(char *)""(0), resultString_1(1), resultString_9(2)>;
and we go on to try and get the lentgh of all the PHI args, by looking at the
DEF stmts of each PHI arg... and resultString_1 has itself as an argument.
There's your infinite loop.
Probably need a patch like this (perhaps just return NULL_TREE, but I don't
think we have to...) No time to test or think, so I've just put it here so
that it doesn't get lost in my messy file system.
ndex: tree-ssa-ccp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-ccp.c,v
retrieving revision 1.1.2.108
diff -c -3 -p -r1.1.2.108 tree-ssa-ccp.c
*** tree-ssa-ccp.c 11 Nov 2003 18:04:46 -0000 1.1.2.108
--- tree-ssa-ccp.c 12 Nov 2003 18:20:25 -0000
*************** get_strlen (tree arg)
*** 1922,1928 ****
arg_len = prev_arg_len = NULL_TREE;
for (i = 0; i < PHI_NUM_ARGS (def_stmt); i++)
{
! arg_len = get_strlen (PHI_ARG_DEF (def_stmt, i));
if (arg_len == NULL_TREE)
return NULL_TREE;
--- 1922,1939 ----
arg_len = prev_arg_len = NULL_TREE;
for (i = 0; i < PHI_NUM_ARGS (def_stmt); i++)
{
! tree arg_def_stmt = PHI_ARG_DEF (def_stmt, i);
!
! /* If this PHI has itself as an argument, we cannot
! determine the string length of this argument. However,
! if we can find a constant string length for the other
! PHI args then we can still be sure that this is a
! constant string length. So be optimistic and just
! continue with the next argument. */
! if (arg_def_stmt == def_stmt)
! continue;
!
! arg_len = get_strlen (arg_def_stmt);
if (arg_len == NULL_TREE)
return NULL_TREE;
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12640