public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54828] New: [4.7 Regression] ICE in based_loc_descr at dwarf2out.c:10560 with -g -O0
@ 2012-10-05 21:15 jhb at FreeBSD dot org
  2012-10-06  8:06 ` [Bug c++/54828] " daniel.kruegler at googlemail dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: jhb at FreeBSD dot org @ 2012-10-05 21:15 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54828

             Bug #: 54828
           Summary: [4.7 Regression] ICE in based_loc_descr at
                    dwarf2out.c:10560 with -g -O0
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jhb@FreeBSD.org


Created attachment 28367
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28367
Test case

> g++47 -v --save-temps -c TestFault.cc -g
Using built-in specs.
COLLECT_GCC=g++47
Target: x86_64-portbld-freebsd8.2
Configured with: ./../gcc-4.7-20120818/configure --disable-nls
--enable-languages=c,c++,objc,fortran --libdir=/usr/local/lib/gcc47
--libexecdir=/usr/local/libexec/gcc47 --program-suffix=47
--with-as=/usr/local/bin/as --with-gmp=/usr/local
--with-gxx-include-dir=/usr/local/lib/gcc47/include/c++/
--with-ld=/usr/local/bin/ld --with-libiconv-prefix=/usr/local
--with-pkgversion='FreeBSD Ports Collection' --with-system-zlib
--enable-languages=c,c++,objc,fortran,java --prefix=/usr/local
--mandir=/usr/local/man --infodir=/usr/local/info/gcc47
--build=x86_64-portbld-freebsd8.2
Thread model: posix
gcc version 4.7.2 20120818 (prerelease) (FreeBSD Ports Collection) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-g' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
 /usr/local/libexec/gcc47/gcc/x86_64-portbld-freebsd8.2/4.7.2/cc1plus -E -quiet
-v TestFault.cc -mtune=generic -march=x86-64 -g -fworking-directory
-fpch-preprocess -o TestFault.ii
ignoring nonexistent directory
"/usr/local/lib/gcc47/gcc/x86_64-portbld-freebsd8.2/4.7.2/../../../../../x86_64-portbld-freebsd8.2/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc47/include/c++/
 /usr/local/lib/gcc47/include/c++//x86_64-portbld-freebsd8.2
 /usr/local/lib/gcc47/include/c++//backward
 /usr/local/lib/gcc47/gcc/x86_64-portbld-freebsd8.2/4.7.2/include
 /usr/local/include
 /usr/local/lib/gcc47/gcc/x86_64-portbld-freebsd8.2/4.7.2/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-g' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
 /usr/local/libexec/gcc47/gcc/x86_64-portbld-freebsd8.2/4.7.2/cc1plus
-fpreprocessed TestFault.ii -quiet -dumpbase TestFault.cc -mtune=generic
-march=x86-64 -auxbase TestFault -g -version -o TestFault.s
GNU C++ (FreeBSD Ports Collection) version 4.7.2 20120818 (prerelease)
(x86_64-portbld-freebsd8.2)
        compiled by GNU C version 4.7.2 20120818 (prerelease), GMP version
5.0.1, MPFR version 3.0.0, MPC version 0.8.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++ (FreeBSD Ports Collection) version 4.7.2 20120818 (prerelease)
(x86_64-portbld-freebsd8.2)
        compiled by GNU C version 4.7.2 20120818 (prerelease), GMP version
5.0.1, MPFR version 3.0.0, MPC version 0.8.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: bd38cbf26a83e7a65b138cf0b63e68eb
TestFault.cc: In constructor 'Foo::Foo()':
TestFault.cc:12:1: internal compiler error: Segmentation fault: 11
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Test case is attached.  4.7.2 release also segfaults in the same way. 
4.5.3.20110203 and 4.6.2.20110909 do not.

Enabling optimization prevents the crash.  The stack trace is below.  The
'cfun' global variable is NULL when the fault occurs.  It is set to NULL in
dwarf2out_abstract_function() via push_cfun() because
DECL_STRUCT_FUNCTION(decl) is NULL (verified by running cc1plus under gdb).

I am using the following hackish patch as a temporary workaround:

--- gcc/dwarf2out.c.orig        2012-10-05 13:11:57.000000000 -0400
+++ gcc/dwarf2out.c     2012-10-05 13:27:32.000000000 -0400
@@ -17046,6 +17046,10 @@
     /* We've already generated the abstract instance.  */
     return;

+  /* XXX: Workaround that probably isn't correct. */
+  if (DECL_STRUCT_FUNCTION(decl) == NULL)
+    return;
+
   /* We can be called while recursively when seeing block defining inlined
subroutine
      DIE.  Be sure to not clobber the outer location table nor use it or we
would
      get locations in abstract instantces.  */

GDB info:

Program terminated with signal 6, Aborted.
#0  0x0000000801c8e52c in kill () from /lib/libc.so.7
(gdb) where
#0  0x0000000801c8e52c in kill () from /lib/libc.so.7
#1  0x0000000801c8d32b in abort () from /lib/libc.so.7
#2  0x0000000000c92d45 in real_abort () at
.././../gcc-4.7-20120818/gcc/diagnostic.c:909
#3  diagnostic_action_after_output (context=context@entry=0x13c3c80,
diagnostic=<error reading variable: Unhandled dwarf expression opcode 0xfa>)
    at .././../gcc-4.7-20120818/gcc/diagnostic.c:216
#4  0x0000000000c92efe in diagnostic_report_diagnostic (context=0x13c3c80,
diagnostic=diagnostic@entry=0x7fffffffc920) at
.././../gcc-4.7-20120818/gcc/diagnostic.c:552
#5  0x0000000000c93bf0 in internal_error (gmsgid=<optimized out>) at
.././../gcc-4.7-20120818/gcc/diagnostic.c:845
#6  0x00000000008476e0 in crash_signal (signo=11) at
.././../gcc-4.7-20120818/gcc/toplev.c:346
#7  <signal handler called>
#8  based_loc_descr (reg=reg@entry=0x8020014a0, offset=-16,
initialized=VAR_INIT_STATUS_INITIALIZED) at
.././../gcc-4.7-20120818/gcc/dwarf2out.c:10560
#9  0x00000000006963bf in mem_loc_descriptor (rtl=0x80f00d4f8, mode=DImode,
mem_mode=mem_mode@entry=DImode,
initialized=initialized@entry=VAR_INIT_STATUS_INITIALIZED)
    at .././../gcc-4.7-20120818/gcc/dwarf2out.c:11948
#10 0x000000000069b6d1 in loc_descriptor (rtl=rtl@entry=0x80eec50f0,
mode=mode@entry=VOIDmode,
initialized=initialized@entry=VAR_INIT_STATUS_INITIALIZED)
    at .././../gcc-4.7-20120818/gcc/dwarf2out.c:12605
#11 0x000000000069a9d3 in loc_list_from_tree (loc=loc@entry=0x80e0f9280,
want_address=want_address@entry=2) at
.././../gcc-4.7-20120818/gcc/dwarf2out.c:13592
#12 0x000000000069ab5f in add_bound_info
(subrange_die=subrange_die@entry=0x80f0189b0,
bound_attr=bound_attr@entry=DW_AT_upper_bound, bound=bound@entry=0x80e0f9280)
    at .././../gcc-4.7-20120818/gcc/dwarf2out.c:15656
#13 0x000000000069eadc in add_subscript_info (collapse_p=<optimized out>,
type=<optimized out>, type_die=<optimized out>) at
.././../gcc-4.7-20120818/gcc/dwarf2out.c:15745
#14 gen_array_type_die (type=0x80b493a80, context_die=0x80f0188c0) at
.././../gcc-4.7-20120818/gcc/dwarf2out.c:16460
#15 0x000000000068cf05 in gen_type_die_with_usage (type=0x80b493a80,
context_die=context_die@entry=0x80f0188c0,
usage=usage@entry=DINFO_USAGE_DIR_USE)
    at .././../gcc-4.7-20120818/gcc/dwarf2out.c:19057
#16 0x000000000068d28a in gen_type_die (type=<optimized out>,
context_die=context_die@entry=0x80f0188c0) at
.././../gcc-4.7-20120818/gcc/dwarf2out.c:19103
#17 0x000000000069196a in gen_decl_die (decl=0x80b489e60, origin=0x0,
context_die=0x80f0188c0) at .././../gcc-4.7-20120818/gcc/dwarf2out.c:19647
#18 0x000000000068eee5 in decls_for_scope (stmt=stmt@entry=0x80b745460,
context_die=context_die@entry=0x80f0188c0, depth=depth@entry=2)
    at .././../gcc-4.7-20120818/gcc/dwarf2out.c:19237
#19 0x000000000069f0f2 in gen_lexical_block_die (depth=2,
context_die=<optimized out>, stmt=0x80b745460) at
.././../gcc-4.7-20120818/gcc/dwarf2out.c:18222
#20 gen_block_die (stmt=stmt@entry=0x80b745460,
context_die=context_die@entry=0x80f018730, depth=depth@entry=2) at
.././../gcc-4.7-20120818/gcc/dwarf2out.c:19187
#21 0x000000000068ef4e in decls_for_scope (stmt=stmt@entry=0x80b7454b0,
context_die=context_die@entry=0x80f018730, depth=depth@entry=1)
    at .././../gcc-4.7-20120818/gcc/dwarf2out.c:19251
#22 0x000000000069f0f2 in gen_lexical_block_die (depth=1,
context_die=<optimized out>, stmt=0x80b7454b0) at
.././../gcc-4.7-20120818/gcc/dwarf2out.c:18222
#23 gen_block_die (stmt=stmt@entry=0x80b7454b0,
context_die=context_die@entry=0x80f0185f0, depth=depth@entry=1) at
.././../gcc-4.7-20120818/gcc/dwarf2out.c:19187
#24 0x000000000068ef4e in decls_for_scope (stmt=stmt@entry=0x80b745500,
context_die=context_die@entry=0x80f0185f0, depth=depth@entry=0)
    at .././../gcc-4.7-20120818/gcc/dwarf2out.c:19251
#25 0x000000000068f434 in gen_subprogram_die (decl=decl@entry=0x808ea6800,
context_die=context_die@entry=0x80202e000) at
.././../gcc-4.7-20120818/gcc/dwarf2out.c:17666
#26 0x0000000000691bda in gen_decl_die (decl=decl@entry=0x808ea6800,
origin=<optimized out>, origin@entry=0x0, context_die=0x80202e000)
    at .././../gcc-4.7-20120818/gcc/dwarf2out.c:19601
#27 0x000000000068be5b in dwarf2out_decl (decl=decl@entry=0x808ea6800) at
.././../gcc-4.7-20120818/gcc/dwarf2out.c:19977
#28 0x000000000068c0ec in dwarf2out_abstract_function (decl=0x808ea6800) at
.././../gcc-4.7-20120818/gcc/dwarf2out.c:17080
#29 0x0000000000691e1b in gen_decl_die (decl=0x808f73c00,
origin=origin@entry=0x0, context_die=0x80202e000) at
.././../gcc-4.7-20120818/gcc/dwarf2out.c:19558
#30 0x000000000068be5b in dwarf2out_decl (decl=<optimized out>) at
.././../gcc-4.7-20120818/gcc/dwarf2out.c:19977
#31 0x00000000006a1e39 in dwarf2out_function_decl (decl=<optimized out>) at
.././../gcc-4.7-20120818/gcc/dwarf2out.c:19985
#32 0x00000000006d6c3d in rest_of_handle_final () at
.././../gcc-4.7-20120818/gcc/final.c:4350
#33 0x00000000007b8638 in execute_one_pass (pass=pass@entry=0x1258fa0) at
.././../gcc-4.7-20120818/gcc/passes.c:2084
#34 0x00000000007b8981 in execute_pass_list (pass=0x1258fa0) at
.././../gcc-4.7-20120818/gcc/passes.c:2139
#35 0x00000000007b8993 in execute_pass_list (pass=0x1259d40) at
.././../gcc-4.7-20120818/gcc/passes.c:2140
#36 0x00000000007b8993 in execute_pass_list (pass=0x1259da0) at
.././../gcc-4.7-20120818/gcc/passes.c:2140
#37 0x000000000088e609 in tree_rest_of_compilation (fndecl=0x808f73c00) at
.././../gcc-4.7-20120818/gcc/tree-optimize.c:422
#38 0x000000000064764a in cgraph_expand_function (node=0x80b74e480) at
.././../gcc-4.7-20120818/gcc/cgraphunit.c:1837
#39 0x0000000000649022 in cgraph_output_in_order () at
.././../gcc-4.7-20120818/gcc/cgraphunit.c:2002
#40 cgraph_optimize () at .././../gcc-4.7-20120818/gcc/cgraphunit.c:2213
#41 0x00000000006492aa in cgraph_finalize_compilation_unit () at
.././../gcc-4.7-20120818/gcc/cgraphunit.c:1344
#42 0x000000000052b0cb in cp_write_global_declarations () at
.././../gcc-4.7-20120818/gcc/cp/decl2.c:4057
#43 0x0000000000849257 in compile_file () at
.././../gcc-4.7-20120818/gcc/toplev.c:573
#44 do_compile () at .././../gcc-4.7-20120818/gcc/toplev.c:1938
#45 toplev_main (argc=44, argv=0x7fffffffda10) at
.././../gcc-4.7-20120818/gcc/toplev.c:2014
#46 0x00000000004cde4e in _start ()
(gdb) frame 8
#8  based_loc_descr (reg=reg@entry=0x8020014a0, offset=-16,
initialized=VAR_INIT_STATUS_INITIALIZED) at
.././../gcc-4.7-20120818/gcc/dwarf2out.c:10560
10560     dw_fde_ref fde = cfun->fde;
(gdb) p cfun
$1 = (function *) 0x0
(gdb) frame 28
#28 0x000000000068c0ec in dwarf2out_abstract_function (decl=0x808ea6800) at
.././../gcc-4.7-20120818/gcc/dwarf2out.c:17080
17080     dwarf2out_decl (decl);
(gdb) p decl->function_decl.f
$3 = (function *) 0x0
(gdb) l
17075     current_function_decl = decl;
17076     push_cfun (DECL_STRUCT_FUNCTION (decl));
17077
17078     was_abstract = DECL_ABSTRACT (decl);
17079     set_decl_abstract_flags (decl, 1);
17080     dwarf2out_decl (decl);
17081     if (! was_abstract)
17082       set_decl_abstract_flags (decl, 0);
17083
17084     current_function_decl = save_fn;


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-04-12 16:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-05 21:15 [Bug c++/54828] New: [4.7 Regression] ICE in based_loc_descr at dwarf2out.c:10560 with -g -O0 jhb at FreeBSD dot org
2012-10-06  8:06 ` [Bug c++/54828] " daniel.kruegler at googlemail dot com
2012-10-08 12:06 ` [Bug debug/54828] [4.6/4.7/4.8 " rguenth at gcc dot gnu.org
2012-10-23  9:08 ` jakub at gcc dot gnu.org
2012-10-24  9:09 ` jakub at gcc dot gnu.org
2012-10-24  9:21 ` [Bug debug/54828] [4.6/4.7 " jakub at gcc dot gnu.org
2012-11-05 15:09 ` jakub at gcc dot gnu.org
2012-11-07 14:06 ` jhb at FreeBSD dot org
2012-12-03 15:47 ` [Bug debug/54828] [4.6 " rguenth at gcc dot gnu.org
2013-04-12 16:29 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).