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]

[PATCH] PR java/13284: EXIT_BLOCK_EXPR vs. safe_for_reeval


The following patch is my proposed solution to PR java/13284, which is
a segmentation fault on legal.  The problem is caused by unbounded
recursion in unsafe_for_reeval causing gcj to run out of stack space.

The problem is with EXIT_BLOCK_EXPR nodes, one of whose operands points
back to the containging LABELED_BLOCK_EXPR node, i.e. the binding contour
to jump out of.  Unfortunately, the code in unsafe_for_reeval treats
all 'e' class expressions identically, recursing over each operand in
turn.

The "obvious" fix is to handle EXIT_BLOCK_EXPR separately.


The following patch has been tested on i686-pc-linux-gnu with a complete
"make bootstrap", all languages except treelang, and regression tested
with a top-level "make -k check" with no new failures.

Ok for 3.3, 3.4 and mainline?


2004-01-25  Roger Sayle  <roger@eyesopen.com>

	PR java/13824
	* tree.c (unsafe_for_reeval): Handle EXIT_BLOCK_EXPR nodes specially
	as their EXIT_BLOCK_LABELED_BLOCK operands can lead to unbounded
	recursion.


Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.c,v
retrieving revision 1.342
diff -c -3 -p -r1.342 tree.c
*** tree.c	16 Jan 2004 07:20:28 -0000	1.342
--- tree.c	25 Jan 2004 15:59:45 -0000
*************** unsafe_for_reeval (tree expr)
*** 1656,1661 ****
--- 1656,1668 ----
        unsafeness = 1;
        break;

+     case EXIT_BLOCK_EXPR:
+       /* EXIT_BLOCK_LABELED_BLOCK, a.k.a. TREE_OPERAND (expr, 0), holds
+ 	 a reference to an ancestor LABELED_BLOCK, so we need to avoid
+ 	 unbounded recursion in the 'e' traversal code below.  */
+       exp = EXIT_BLOCK_RETURN (expr);
+       return exp ? unsafe_for_reeval (exp) : 0;
+
      default:
        tmp = (*lang_hooks.unsafe_for_reeval) (expr);
        if (tmp >= 0)


Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833


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