This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PR 20225
- From: Jan Hubicka <jh at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org, rth at redhat dot com, mark at codesourcery dot com
- Date: Tue, 15 Mar 2005 22:15:52 +0100
- Subject: PR 20225
Hi,
the (quite complex) C++ testcase causes GGC to crash since we happen to
leak next_needed pointer to removed cgraph node that has bogus prev/next
double linked chain. This happens by fact that
cgraph_mark_reachable_node is called late in the game (after all
reachable nodes are discovered) from assemble_alias that is produced by
C++ frotend thunk handling code. THis is wrong since the effect of the
call is just memory corruption and node won't get added into live list.
The aliases comes mostly from alias attribute and thunk constructs. In
the first case we need to make the function as needed, while for tunks
this hopefully should happen transparently. Since the first happens
early, I think it is safe to just avoid the mark_needed_node being done
late.
Bootstrapped/regtested i686-pc-gnu-linux, I will commit it tomorrow if
no one objects. (basically I would be interested if Mark thinks it is
OK to emit the alias for function that won't get output to assembly file
because it gets inlined in all callers. The patch is probably good idea
even if this is wrong, but we will have to do something about the C++ fe
bug then)
Honza
2005-03-15 Jan Hubicka <jh@suse.cz>
* cgraph.c (cgraph_mark_reachable_node): Check that it is not
called too late.
* varasm.c (assemble_alias): Do not call cgraph_mark_reachable_node
too late.
Index: cgraph.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraph.c,v
retrieving revision 1.65
diff -c -3 -p -r1.65 cgraph.c
*** cgraph.c 2 Mar 2005 11:09:47 -0000 1.65
--- cgraph.c 13 Mar 2005 21:36:32 -0000
*************** cgraph_mark_reachable_node (struct cgrap
*** 472,477 ****
--- 472,478 ----
{
if (!node->reachable && node->local.finalized)
{
+ gcc_assert (!cgraph_global_info_ready);
notice_global_symbol (node->decl);
node->reachable = 1;
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.479
diff -c -3 -p -r1.479 varasm.c
*** varasm.c 2 Mar 2005 21:33:44 -0000 1.479
--- varasm.c 13 Mar 2005 21:36:33 -0000
*************** assemble_alias (tree decl, tree target)
*** 4463,4469 ****
specific and tell cgraph about the relationship between the two
symbols, but given that aliases virtually always exist for a reason,
it doesn't seem worthwhile. */
! if (flag_unit_at_a_time)
{
struct cgraph_node *fnode = NULL;
struct cgraph_varpool_node *vnode = NULL;
--- 4463,4469 ----
specific and tell cgraph about the relationship between the two
symbols, but given that aliases virtually always exist for a reason,
it doesn't seem worthwhile. */
! if (flag_unit_at_a_time && !cgraph_global_info_ready)
{
struct cgraph_node *fnode = NULL;
struct cgraph_varpool_node *vnode = NULL;