Bug 48354 - internal compiler error: in splice_child_die, at dwarf2out.c:8064
Summary: internal compiler error: in splice_child_die, at dwarf2out.c:8064
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Richard Biener
URL:
Keywords: lto
: 50279 (view as bug list)
Depends on:
Blocks: mozillametabug 47819
  Show dependency treegraph
 
Reported: 2011-03-30 07:59 UTC by Wouter Vermaelen
Modified: 2011-12-13 14:44 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.6.0
Last reconfirmed: 2011-03-30 09:24:04


Attachments
patch (960 bytes, patch)
2011-05-24 14:43 UTC, Richard Biener
Details | Diff
updated patch (1.21 KB, patch)
2011-05-30 11:59 UTC, Richard Biener
Details | Diff
another update (911 bytes, patch)
2011-06-01 13:49 UTC, Richard Biener
Details | Diff
update (744 bytes, patch)
2011-12-12 15:58 UTC, Richard Biener
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wouter Vermaelen 2011-03-30 07:59:00 UTC
I got this ICE when trying to compile the openMSX package using -flto. I managed to reduce it to this:

> cat bug.ii
template<typename T> struct Identity { typedef T type; };
struct S {
        typedef void (S::*FP)();
        FP fp;
};
void g();
void f() {
        typedef Identity<S>::type Dummy;
        S s;
        g();
}

> g++-snapshot -r -nostdlib -g -flto bug.ii
...
bug.ii:11:1: internal compiler error: in splice_child_die, at dwarf2out.c:8064
...

I'm using revision trunk@171714.


This may or may not be a duplicate of bug 46135. Though the testcase looks very different.
Comment 1 Richard Biener 2011-03-30 09:24:04 UTC
Confirmed.
Comment 2 Jan Hubicka 2011-04-25 00:05:15 UTC
Same ICE now reproduces with Mozilla build
Comment 3 H.J. Lu 2011-04-25 04:17:21 UTC
It is caused by revision 170321:

http://gcc.gnu.org/ml/gcc-cvs/2011-02/msg00866.html
Comment 4 Richard Biener 2011-05-24 14:21:57 UTC
In the cc1plus case the type for s is already output and we return in

static void
gen_type_die_with_usage (tree type, dw_die_ref context_die,
                         enum debug_info_usage usage)
{
...
  if (TREE_ASM_WRITTEN (type))
    return;

that isn't the case for lto1.

Called from cc1plus via

#4  0x00000000009e9d25 in dwarf2out_type_decl (decl=0x7ffff5b86450, local=0)
    at /space/rguenther/src/svn/trunk/gcc/dwarf2out.c:21985
21985       dwarf2out_decl (decl);
(gdb) 
#5  0x0000000000cd1e8c in rest_of_type_compilation (type=0x7ffff5b7f7e0, 
    toplev=1) at /space/rguenther/src/svn/trunk/gcc/passes.c:230
230       debug_hooks->type_decl (TYPE_STUB_DECL (type), !toplev);
(gdb) 
#6  0x000000000062c460 in finish_struct_1 (t=0x7ffff5b7f7e0)
    at /space/rguenther/src/svn/trunk/gcc/cp/class.c:5760
5760      rest_of_type_compilation (t, ! LOCAL_CLASS_P (t));

not doing that does not make us ICE the same way from cc1plus but we
are outputting the type then via the Dummy typedef instead.

The scope blocks look the same for cc1plus and lto1:

{ Scope block 0x7ffff5b42058#2 
  typedef struct Dummy Dummy; (unused)
  struct S s; (unused)

}

One difference is that cc1plus sees DECL_ORIGINAL_TYPE for the TYPE_DECL
while lto1 does not (it's not streamed), and thus is_typedef_decl will
always return false as well.

I have a patch.
Comment 5 Richard Biener 2011-05-24 14:43:00 UTC
Created attachment 24343 [details]
patch

Honza, can you try this on mozilla?
Comment 6 Richard Biener 2011-05-24 14:58:53 UTC
It seems that we can pull in types via that link that have function-decls in
them (methods) that do not have an assembler name set.  But we happily
enter them into symtab merging and so we ICE.  See also PR48437 for a
related case.  Hohumm.
Comment 7 Jan Hubicka 2011-05-24 18:53:14 UTC
> Honza, can you try this on mozilla?
Can try, but only after returning from Bertinoro.  All connections I found here filters VPN.

Honza
Comment 8 Jan Hubicka 2011-05-27 21:37:46 UTC
Hmm, so shall I still try the patch?
The ICE is now more common. We used to fail twice during mozilla build, now we fail about approximately 5 different shared libraries.
Comment 9 rguenther@suse.de 2011-05-30 09:02:55 UTC
On Fri, 27 May 2011, hubicka at gcc dot gnu.org wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48354
> 
> --- Comment #8 from Jan Hubicka <hubicka at gcc dot gnu.org> 2011-05-27 21:37:46 UTC ---
> Hmm, so shall I still try the patch?
> The ICE is now more common. We used to fail twice during mozilla build, now we
> fail about approximately 5 different shared libraries.

The patch isn't complete.  It at least misses walking DECL_ORIGINAL_TYPE
in free-lang-data.
Comment 10 Richard Biener 2011-05-30 11:59:30 UTC
Created attachment 24395 [details]
updated patch

Updated patch containing the fld hunk.  See also the dwarf2out.c commented
change which might be necessary (ISTR to run into this).  I also seem to
remember that the gimple.c change has issues during LTO bootstrap for some reason.

So, I'm not entirely happy, but somehow we have to stream DECL_ORIGINAL_TYPE.
Comment 11 Jan Hubicka 2011-05-31 16:05:49 UTC
The patch seems to work.  I now get the ICE at output_die (already reported) but also new
/abuild/jh/trunk-install/bin/g++ -flto=24 -fuse-linker-plugin -o dump_syms  -fno-rtti -fno-exceptions -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wcast-align -Wno-invalid-offsetof -Wno-variadic-macros -Werror=return-type -pedantic -Wno-long-long -fno-strict-aliasing -std=gnu++0x -pthread -pipe  -DNDEBUG -DTRIMMED -g -O3 -lpthread    -Wl,-rpath-link,/abuild/jh/build-mozilla-new12/dist/bin -Wl,-rpath-link,/usr/local/lib  -static host_dump_syms.o ../../../../../../../toolkit/crashreporter/google-breakpad/src/common/linux/libhost_breakpad_linux_common_s.a ../../../../../../../toolkit/crashreporter/google-breakpad/src/common/libhost_breakpad_common_s.a ../../../../../../../toolkit/crashreporter/google-breakpad/src/common/dwarf/libhost_breakpad_dwarf_s.a  
In file included from /abuild/jh/trunk-install/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_tree.h:930:0,
                 from :311:
/abuild/jh/mozilla-central2/mozilla-central/toolkit/crashreporter/google-breakpad/src/common/linux/file_id.cc: In function 'FindElfClassTextSection':
/abuild/jh/mozilla-central2/mozilla-central/toolkit/crashreporter/google-breakpad/src/common/linux/file_id.cc:133:73: internal compiler error: in gen_typedef_die, at dwarf2out.c:21064
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
make[6]: *** [/tmp/ccaKinu0.ltrans21.ltrans.o] Error 1


Shall I try to get testcase?
Comment 12 rguenther@suse.de 2011-06-01 08:54:43 UTC
On Tue, 31 May 2011, hubicka at gcc dot gnu.org wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48354
> 
> --- Comment #11 from Jan Hubicka <hubicka at gcc dot gnu.org> 2011-05-31 16:05:49 UTC ---
> The patch seems to work.  I now get the ICE at output_die (already reported)
> but also new
> /abuild/jh/trunk-install/bin/g++ -flto=24 -fuse-linker-plugin -o dump_syms 
> -fno-rtti -fno-exceptions -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth
> -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wcast-align -Wno-invalid-offsetof
> -Wno-variadic-macros -Werror=return-type -pedantic -Wno-long-long
> -fno-strict-aliasing -std=gnu++0x -pthread -pipe  -DNDEBUG -DTRIMMED -g -O3
> -lpthread    -Wl,-rpath-link,/abuild/jh/build-mozilla-new12/dist/bin
> -Wl,-rpath-link,/usr/local/lib  -static host_dump_syms.o
> ../../../../../../../toolkit/crashreporter/google-breakpad/src/common/linux/libhost_breakpad_linux_common_s.a
> ../../../../../../../toolkit/crashreporter/google-breakpad/src/common/libhost_breakpad_common_s.a
> ../../../../../../../toolkit/crashreporter/google-breakpad/src/common/dwarf/libhost_breakpad_dwarf_s.a 
> In file included from
> /abuild/jh/trunk-install/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/stl_tree.h:930:0,
>                  from :311:
> /abuild/jh/mozilla-central2/mozilla-central/toolkit/crashreporter/google-breakpad/src/common/linux/file_id.cc:
> In function 'FindElfClassTextSection':
> /abuild/jh/mozilla-central2/mozilla-central/toolkit/crashreporter/google-breakpad/src/common/linux/file_id.cc:133:73:
> internal compiler error: in gen_typedef_die, at dwarf2out.c:21064
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <http://gcc.gnu.org/bugs.html> for instructions.
> make[6]: *** [/tmp/ccaKinu0.ltrans21.ltrans.o] Error 1
> 
> 
> Shall I try to get testcase?

No, that's another expected one.  I'll attach an updated patch.
Comment 13 Richard Biener 2011-06-01 13:49:47 UTC
Created attachment 24407 [details]
another update

Try this instead.
Comment 14 Jan Hubicka 2011-06-02 01:02:10 UTC
Same get_typedef_die ICE with this patch, too.
Comment 15 Jack Howarth 2011-11-01 18:59:45 UTC
This issue appears to still exist in gcc trunk. The same failure is seen building libnmrPot.dylib in xplor-nih with -flto...

g++-fsf-4.7 -dynamiclib -Ofast -funroll-loops -g -flto -fdefault-integer-8 -flat_namespace -undefined suppress -single_module noePot.o atomProb.o rdcPot1.o csaPot.o jCoupPot.o shapePot.o atomDensity.o probDistPot.o cosRatioPot.o ncsPot.o prePot.o rdcWavePot.o varTensor.o surfaceArea.o psolPot.o orderPot.o posRMSDPot.o utils.o posSymmPot.o sphereFun.o volume.o planeDistPot.o selNBPot.o gyrPot.o cstMagPot.o diffPot.o relaxRatioPot.o distSymmPot.o sardcPot.o surfTessellation.o torsionDBPot.o nbTargetPot.o solnScatPot.o -o libnmrPot.dylib    -lcrypto -L/Users/howarth/xplor-nih-2.27/bin.Darwin_11_x86_64/ -lspecfun -lsurfD -llapack -lblas
In file included from surfaceArea.cc:1276:0,
                 from /Users/howarth/xplor-nih-2.27/CDSlib/cdsSStream.cc:327,
                 from :1669:
/Users/howarth/xplor-nih-2.27/nmrPot/relaxRatioPot.hh: In member function ‘numRestraints’:
/Users/howarth/xplor-nih-2.27/nmrPot/relaxRatioPot.hh:163:37: internal compiler error: in splice_child_die, at dwarf2out.c:5009
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: g++-fsf-4.7 returned 1 exit status
collect2: error: lto-wrapper returned 1 exit status
Comment 16 Jack Howarth 2011-11-02 18:08:37 UTC
The original test case still fails on x86_64-apple-darwin11 as well at r180780...

g++-fsf-4.7 -r -nostdlib -g -flto bug.ii
In file included from bug.ii:8:0,
                 from :2:
bug.ii: In function ‘f’:
bug.ii:11:1: internal compiler error: in splice_child_die, at dwarf2out.c:5009
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: g++-fsf-4.7 returned 1 exit status
collect2: error: lto-wrapper returned 1 exit status
Comment 17 Richard Biener 2011-12-09 12:31:36 UTC
*** Bug 50279 has been marked as a duplicate of this bug. ***
Comment 18 Richard Biener 2011-12-12 15:58:07 UTC
Created attachment 26058 [details]
update

I'm testing an updated patch.
Comment 19 Richard Biener 2011-12-13 14:43:50 UTC
Author: rguenth
Date: Tue Dec 13 14:43:44 2011
New Revision: 182286

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182286
Log:
2011-12-13  Richard Guenther  <rguenther@suse.de>

	PR lto/48354
	* tree.c (find_decls_types_r): Also walk DECL_ORIGINAL_TYPE.
	* tree-streamer-in.c (lto_input_ts_decl_non_common_tree_pointers):
	Stream DECL_ORIGINAL_TYPE.
	* tree-streamer-out.c (write_ts_decl_non_common_tree_pointers):
	Likewise.

	lto/
	* lto.c (lto_ft_decl_non_common): When we merged DECL_ORIGINAL_TYPE
	with the type of the TYPE_DECL clear DECL_ORIGINAL_TYPE.

	* g++.dg/lto/pr48354-1_0.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/lto/pr48354-1_0.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/lto/ChangeLog
    trunk/gcc/lto/lto.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-streamer-in.c
    trunk/gcc/tree-streamer-out.c
    trunk/gcc/tree.c
Comment 20 Richard Biener 2011-12-13 14:44:43 UTC
Fixed.