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]

sibling/tail call opts vs sjlj EH



Some systems (like the PA) are failing to bootstrap due to a segfault/bus
error compiling tinfo.cc.

We're dying in stmt_loop_nest_empty because cfun->stmt is NULL.

It has been claimed this can not/should not happen.  But in fact it can
and does happen.

Consider a deferred inline function which has EH regions..

We'll parse the function, build up a bunch of tree & rtl nodes in the
process, then call free_after_parsing when we're done parsing.

That call will zero cfun->stmt.

Later we decide we really need to emit code for the inline function, so we
call output_inline_function, which gets us our original cfun pointer which
has the stmt field zero'd out.

We've already got tree/rtl code for the function, so it shouldn't matter
that cfun->stmt was cleared, right?  Bzzt.  For sjlj based EH target we
call emit_eh_context.

emit_eh_context walks down the insn chain and finds the first insn with a
REG_EH_CONTEXT note.  If it finds one, then we build up a new CALL_EXPR
and expand it.

In an attempt to see if there is sibcall/tailcall optimization opportunity
that expansion of the CALL_EXPR will call stmt_loop_nest_empty and we die
due to a null pointer dereference.

We never saw this in the Cygnus tree because we never did sibcall/tailcall
optimizations in code that might need exception handling.

Anyway, the simple and obvious fix is (as far as I can tell) the right fix.

With this fix the PA port will bootstrap and tests pass with no regressions
(note there are several test failures that need to be addressed, but none are
caused by this fix).


	* stmt.c (stmt_loop_nest_empty): Allow cfun->stmt to be NULL.

Index: stmt.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/stmt.c,v
retrieving revision 1.134
diff -c -3 -p -r1.134 stmt.c
*** stmt.c	2000/03/27 00:50:27	1.134
--- stmt.c	2000/03/29 17:51:24
*************** expand_exit_loop_if_false (whichloop, co
*** 2618,2624 ****
  int
  stmt_loop_nest_empty ()
  {
!   return (loop_stack == NULL);
  }
  
  /* Return non-zero if we should preserve sub-expressions as separate
--- 2618,2627 ----
  int
  stmt_loop_nest_empty ()
  {
!   /* cfun->stmt can be NULL if we are building a call to get the
!      EH context for a setjmp/longjmp EH target and the current
!      function was a deferred inline function.  */
!   return (cfun->stmt != NULL && loop_stack == NULL);
  }
  
  /* Return non-zero if we should preserve sub-expressions as separate





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