Bug 45089 - -Os -g -fwhopr dwarf2out ICE
Summary: -Os -g -fwhopr dwarf2out ICE
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Richard Biener
URL: http://gcc.gnu.org/ml/gcc-patches/201...
Keywords: ice-checking
Depends on:
Blocks: mozillametabug 47819
  Show dependency treegraph
Reported: 2010-07-26 21:03 UTC by Jan Hubicka
Modified: 2012-07-05 14:18 UTC (History)
2 users (show)

See Also:
Host: x86_64-linux
Target: x86_64-linux
Build: x86_64-linux
Known to work:
Known to fail:
Last reconfirmed: 2010-10-02 09:17:50

testcase (418.22 KB, application/x-bzip-compressed-tar)
2010-07-26 21:04 UTC, Jan Hubicka
testcase (661 bytes, text/plain)
2010-07-27 11:06 UTC, Richard Biener

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Hubicka 2010-07-26 21:03:41 UTC
This is introduced by the new type merging code

jh@evans:~> /abuild/jh/trunk-install/bin/g++ -r -nostdlib -Os -g ~/d?.ii -fwhopr
In file included from ../../../dist/include/nsThreadUtils.h:49:0,
                 from /abuild/jh/mozilla-central/accessible/src/base/a11yGeneric.h:42,
                 from /abuild/jh/mozilla-central/accessible/src/base/nsAccessNode.h:49,
                 from /abuild/jh/mozilla-central/accessible/src/base/../atk/nsAccessNodeWrap.h:46,
                 from /abuild/jh/mozilla-central/accessible/src/base/nsAccessible.h:42,
                 from /abuild/jh/mozilla-central/accessible/src/base/../atk/nsAccessibleWrap.h:46,
                 from /abuild/jh/mozilla-central/accessible/src/base/../html/nsHyperTextAccessible.h:48,
                 from /abuild/jh/mozilla-central/accessible/src/base/../atk/nsHyperTextAccessibleWrap.h:42,
                 from /abuild/jh/mozilla-central/accessible/src/base/nsARIAGridAccessible.h:44,
                 from /abuild/jh/mozilla-central/accessible/src/base/nsARIAGridAccessible.cpp:39:
../../../dist/include/nsAutoPtr.h: In member function ‘void nsAutoPtr<T>::assign(T*) [with T = AccGroupInfo]’:
../../../dist/include/nsAutoPtr.h:134:11:   instantiated from ‘nsAutoPtr<T>& nsAutoPtr<T>::operator=(T*) [with T = AccGroupInfo]’
/abuild/jh/mozilla-central/accessible/src/base/nsAccessible.h:332:18:   instantiated from here
../../../dist/include/nsAutoPtr.h:71:11: warning: possible problem detected in invocation of delete operator: [enabled by default]
../../../dist/include/nsAutoPtr.h:69:14: warning: ‘oldPtr’ has incomplete type [enabled by default]
/abuild/jh/mozilla-central/accessible/src/base/nsAccessible.h:55:7: warning: forward declaration of ‘struct AccGroupInfo’ [enabled by default]
../../../dist/include/nsAutoPtr.h:71:11: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined.
lto1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: /abuild/jh/trunk-install/bin/g++ returned 1 exit status
collect2: lto-wrapper returned 1 exit status
Comment 1 Jan Hubicka 2010-07-26 21:04:26 UTC
Created attachment 21321 [details]
Comment 2 Richard Biener 2010-07-27 09:17:49 UTC
Trying to reduce ... it happens only with whopr.

Program received signal SIGSEGV, Segmentation fault.
0x00000000005d33ba in prune_unused_types_mark (die=0x0, dokids=1)
    at /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:21729
21729     if (die->die_mark == 0)

#1  0x00000000005d3349 in prune_unused_types_walk_attribs (die=0x7ffff5a12d68)
    at /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:21711
21711               prune_unused_types_mark (a->dw_attr_val.v.val_die_ref.die, 1);
(gdb) p a->dw_attr_val.v.val_die_ref
$1 = {die = 0x0, external = 0}

so we created a dw_val_class_die_ref attr with a null DIE.  Which we do

#1  0x00000000005c9c14 in add_pure_or_virtual_attribute (die=0x7ffff5a12d68, 
    at /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:17409
17407         if (debug_info_level > DINFO_LEVEL_TERSE
17408             && DECL_CONTEXT (func_decl))
17409           add_AT_die_ref (die, DW_AT_containing_type,
17410                           lookup_type_die (DECL_CONTEXT (func_decl)));


Supposedly the type is unused and thus doesn't get output.

Note that we're arriving here via

#5  0x0000000000c74a47 in expand_call_inline (bb=0x7ffff54782d8, 
    stmt=0x7ffff52c89b0, id=0x7fffffffd970)
    at /space/rguenther/src/svn/trunk/gcc/tree-inline.c:4024
4024      (*debug_hooks->outlining_inline_function) (cg_edge->callee->decl);

Comment 3 Richard Biener 2010-07-27 09:26:56 UTC
So the issue may be that the LTO FE doesn't announce any decls to the debug

> grep debug_hooks cp/*.c
cp/decl.c:    debug_hooks->type_decl (tdecl, 0);
cp/decl.c:              /*debug_hooks->set_name (t, decl);*/
cp/name-lookup.c:    (*debug_hooks->global_decl) (alias);
cp/name-lookup.c:       (*debug_hooks->imported_module_or_decl) (name_space, NULL_TREE,
cp/name-lookup.c:         (*debug_hooks->imported_module_or_decl) (t, NULL_TREE, context, false);
cp/optimize.c:  (*debug_hooks->deferred_inline_function) (fn);
Comment 4 Jan Hubicka 2010-07-27 09:43:22 UTC
Subject: Re:  -Os -g -fwhopr dwarf2out ICE

> So the issue may be that the LTO FE doesn't announce any decls to the debug
> machinery.
Because they are already announced before streaming ;).  I am not at all
familiar with this, can we just announce every type streamed in? Or do we need
to stream whatever frontend did?  deferred_inline_function should be all fine.

Comment 5 Richard Biener 2010-07-27 09:46:38 UTC
Well - I have no idea ;)  We can look at what the FE announces after I finished
testcase reduction.
Comment 6 Richard Biener 2010-07-27 11:06:21 UTC
Created attachment 21325 [details]

> g++ -r -nostdlib -O[s23] -g -flto d2.3.3.C d3.3.3.C

The key is that nsAccessible are not merged because one instance has
a complete nsRoleMapEntry while the other one an incomplete one.
Comment 7 Jan Hubicka 2010-10-02 14:16:08 UTC
Reconfirmed.  Probably major show stopper for mozilla now as there is no workaround.
Comment 8 Richard Biener 2010-10-11 13:02:32 UTC
I have a patch.
Comment 9 Jan Hubicka 2010-10-15 02:43:12 UTC
If you send me this patch and path for the other Mozilla -g PR, I will give them a try on full Mozilla build.
Comment 10 Richard Biener 2010-10-15 08:32:39 UTC
See the URL.
Comment 11 Richard Biener 2010-11-18 14:11:04 UTC
Author: rguenth
Date: Thu Nov 18 14:11:00 2010
New Revision: 166904

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=166904
2010-11-18  Richard Guenther  <rguenther@suse.de>

	PR lto/45089
	* dwarf2out.c (add_AT_die_ref): Work around LTO losing types
	when checking is not enabled.

Comment 12 Richard Biener 2010-11-18 14:11:39 UTC
Now ice-checking only.
Comment 13 Jan Hubicka 2011-01-08 21:22:42 UTC
Confirmed that mozilla now builds with debug info.
Comment 14 Richard Biener 2012-01-03 11:57:56 UTC
Would be interesting to see if (with checking enabled) the ICE still happens
on trunk.
Comment 15 Richard Biener 2012-07-05 14:18:40 UTC
Assuming fixed.