public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/51262] New: [4.7 Regression] ICE: SIGSEGV in primary_template_instantiation_p (pt.c:2874) with -flto -g
@ 2011-11-22  0:02 zsojka at seznam dot cz
  2011-12-05 14:25 ` [Bug debug/51262] " rguenth at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: zsojka at seznam dot cz @ 2011-11-22  0:02 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51262
           Summary: [4.7 Regression] ICE: SIGSEGV in
                    primary_template_instantiation_p (pt.c:2874) with
                    -flto -g
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: zsojka@seznam.cz
              Host: x86_64-pc-linux-gnu
            Target: x86_64-pc-linux-gnu


Created attachment 25875
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25875
reduced testcase

Compiler output:
$ gcc -flto -fcompare-debug testcase.C
==20321== Invalid read of size 2
==20321==    at 0x5C0904: primary_template_instantiation_p(tree_node const*)
(pt.c:2874)
==20321==    by 0x5C118D: get_primary_template_innermost_parameters(tree_node
const*) (pt.c:2902)
==20321==    by 0x899E19: gen_tagged_type_die(tree_node*, die_struct*,
debug_info_usage) (dwarf2out.c:20045)
==20321==    by 0x886C5F: gen_type_die_with_usage(tree_node*, die_struct*,
debug_info_usage) (dwarf2out.c:18952)
==20321==    by 0x89C8A6: gen_decl_die(tree_node*, tree_node*, die_struct*)
(dwarf2out.c:19512)
==20321==    by 0x8A1C2F: decls_for_scope(tree_node*, die_struct*, int)
(dwarf2out.c:19125)
==20321==    by 0x8A2043: gen_block_die(tree_node*, die_struct*, int)
(dwarf2out.c:18111)
==20321==    by 0x8A1CD5: decls_for_scope(tree_node*, die_struct*, int)
(dwarf2out.c:19139)
==20321==    by 0x89DB1E: gen_subprogram_die(tree_node*, die_struct*)
(dwarf2out.c:17555)
==20321==    by 0x89C214: gen_decl_die(tree_node*, tree_node*, die_struct*)
(dwarf2out.c:19489)
==20321==    by 0x8A5818: dwarf2out_function_decl(tree_node*)
(dwarf2out.c:19871)
==20321==    by 0x8FEF14: rest_of_handle_final() (final.c:4349)
==20321==    by 0xA6ED94: execute_one_pass(opt_pass*) (passes.c:2074)
==20321==    by 0xA6F134: execute_pass_list(opt_pass*) (passes.c:2129)
==20321==    by 0xA6F146: execute_pass_list(opt_pass*) (passes.c:2130)
==20321==    by 0xA6F146: execute_pass_list(opt_pass*) (passes.c:2130)
==20321==    by 0xBD0CED: tree_rest_of_compilation(tree_node*)
(tree-optimize.c:420)
==20321==    by 0x8249C9: cgraph_expand_function(cgraph_node*)
(cgraphunit.c:1819)
==20321==    by 0x826B05: cgraph_optimize() (cgraphunit.c:1984)
==20321==    by 0x826ED9: cgraph_finalize_compilation_unit()
(cgraphunit.c:1327)
==20321==    by 0x64880A: cp_write_global_declarations() (decl2.c:4050)
==20321==    by 0xB64033: toplev_main(int, char**) (toplev.c:581)
==20321==    by 0x674ED2C: (below main) (in /lib64/libc-2.12.2.so)
==20321==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==20321== 
testcase.C: In function 'bar<void>(int*)void*':
testcase.C:11:1: 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.
gcc: error: during -fcompare-debug recompilation
gcc: error: testcase.C: -fcompare-debug failure (length)

Tested revisions:
r181550 - crash
r181532 - crash
r181508 - crash
r181442 - OK


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

* [Bug debug/51262] [4.7 Regression] ICE: SIGSEGV in primary_template_instantiation_p (pt.c:2874) with -flto -g
  2011-11-22  0:02 [Bug debug/51262] New: [4.7 Regression] ICE: SIGSEGV in primary_template_instantiation_p (pt.c:2874) with -flto -g zsojka at seznam dot cz
@ 2011-12-05 14:25 ` rguenth at gcc dot gnu.org
  2011-12-06 14:08 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-12-05 14:25 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.7.0


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

* [Bug debug/51262] [4.7 Regression] ICE: SIGSEGV in primary_template_instantiation_p (pt.c:2874) with -flto -g
  2011-11-22  0:02 [Bug debug/51262] New: [4.7 Regression] ICE: SIGSEGV in primary_template_instantiation_p (pt.c:2874) with -flto -g zsojka at seznam dot cz
  2011-12-05 14:25 ` [Bug debug/51262] " rguenth at gcc dot gnu.org
@ 2011-12-06 14:08 ` rguenth at gcc dot gnu.org
  2011-12-06 14:24 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-12-06 14:08 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1


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

* [Bug debug/51262] [4.7 Regression] ICE: SIGSEGV in primary_template_instantiation_p (pt.c:2874) with -flto -g
  2011-11-22  0:02 [Bug debug/51262] New: [4.7 Regression] ICE: SIGSEGV in primary_template_instantiation_p (pt.c:2874) with -flto -g zsojka at seznam dot cz
  2011-12-05 14:25 ` [Bug debug/51262] " rguenth at gcc dot gnu.org
  2011-12-06 14:08 ` rguenth at gcc dot gnu.org
@ 2011-12-06 14:24 ` rguenth at gcc dot gnu.org
  2011-12-07  7:22 ` reichelt at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-12-06 14:24 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |reichelt at gcc dot gnu.org

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-12-06 14:21:44 UTC ---
*** Bug 51325 has been marked as a duplicate of this bug. ***


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

* [Bug debug/51262] [4.7 Regression] ICE: SIGSEGV in primary_template_instantiation_p (pt.c:2874) with -flto -g
  2011-11-22  0:02 [Bug debug/51262] New: [4.7 Regression] ICE: SIGSEGV in primary_template_instantiation_p (pt.c:2874) with -flto -g zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2011-12-06 14:24 ` rguenth at gcc dot gnu.org
@ 2011-12-07  7:22 ` reichelt at gcc dot gnu.org
  2011-12-08 17:06 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: reichelt at gcc dot gnu.org @ 2011-12-07  7:22 UTC (permalink / raw)
  To: gcc-bugs

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

Volker Reichelt <reichelt at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-12-07
     Ever Confirmed|0                           |1

--- Comment #2 from Volker Reichelt <reichelt at gcc dot gnu.org> 2011-12-07 07:22:02 UTC ---
Confirmed.


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

* [Bug debug/51262] [4.7 Regression] ICE: SIGSEGV in primary_template_instantiation_p (pt.c:2874) with -flto -g
  2011-11-22  0:02 [Bug debug/51262] New: [4.7 Regression] ICE: SIGSEGV in primary_template_instantiation_p (pt.c:2874) with -flto -g zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2011-12-07  7:22 ` reichelt at gcc dot gnu.org
@ 2011-12-08 17:06 ` rguenth at gcc dot gnu.org
  2011-12-09  3:49 ` jason at redhat dot com
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-12-08 17:06 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dodji at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-12-08 16:46:41 UTC ---
Program received signal SIGSEGV, Segmentation fault.
0x0000000000569d33 in primary_template_instantiation_p (t=0x7ffff5b8f930)
    at /space/rguenther/src/svn/trunk/gcc/cp/pt.c:2874
2874      else if (CLASS_TYPE_P (t) && !TYPE_DECL_ALIAS_P (TYPE_NAME (t)))
(gdb)

but TYPE_NAME (t) is NULL:

(gdb) call debug_tree (t)
 <union_type 0x7ffff5b8f930 sizes-gimplified type_5 type_6 DI
    size <integer_cst 0x7ffff5a20f40 type <integer_type 0x7ffff5a390a8
bitsizetype> constant 64>
    unit size <integer_cst 0x7ffff5a20f60 type <integer_type 0x7ffff5a39000
sizetype> constant 8>
    align 64 symtab -173746304 alias set -1 canonical type 0x7ffff5b8f930
    fields <field_decl 0x7ffff5b8c8e8 p
        type <pointer_type 0x7ffff5a472a0 type <integer_type 0x7ffff5a395e8
int>
            sizes-gimplified asm_written unsigned type_6 DI size <integer_cst
0x7ffff5a20f40 64> unit size <integer_cst 0x7ffff5a20f60 8>
            align 64 symtab -173747024 alias set -1 canonical type
0x7ffff5a472a0>
        used unsigned nonlocal decl_3 DI file t.C line 6 col 12 size
<integer_cst 0x7ffff5a20f40 64> unit size <integer_cst 0x7ffff5a20f60 8>
        align 64 offset_align 128
        offset <integer_cst 0x7ffff5a20f80 constant 0>
        bit offset <integer_cst 0x7ffff5a20fe0 constant 0> context <union_type
0x7ffff5b8f930>> context <function_decl 0x7ffff5b8ef00 bar>
    full-name "union<anonymous>"
    X() X(constX&) this=(X&)
    chain <type_decl 0x7ffff5ba52e0 ._0>>

cleared by the C++ free_lang_data langhook:

  if (CP_AGGREGATE_TYPE_P (t)
      && TYPE_NAME (t))
    {
      tree name = TYPE_NAME (t);
      if (TREE_CODE (name) == TYPE_DECL)
        name = DECL_NAME (name);
      /* Drop anonymous names.  */
      if (name != NULL_TREE
          && ANON_AGGRNAME_P (name))
        TYPE_NAME (t) = NULL_TREE;

the type is anonymous before:

 <union_type 0x7ffff5b8f930 ._0 sizes-gimplified type_5 type_6 DI

it's name:

 <type_decl 0x7ffff5ba52e0 ._0
...
    public decl_2 VOID file t.C line 5 col 5
    align 8 context <function_decl 0x7ffff5b8ef00 bar> chain <var_decl
0x7ffff5a2c3c0 u>>

does not have DECL_LANG_FLAG_6 set (TYPE_DECL_ALIAS_P).

Dodji, Jason, can such anonymous name types ever have TYPE_DECL_ALIAS_P
set?  Thus, is a valid fix

Index: pt.c
===================================================================
--- pt.c        (revision 182117)
+++ pt.c        (working copy)
@@ -2871,7 +2871,8 @@ primary_template_instantiation_p (const_
     return DECL_LANG_SPECIFIC (t)
           && DECL_TEMPLATE_INSTANTIATION (t)
           && PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t));
-  else if (CLASS_TYPE_P (t) && !TYPE_DECL_ALIAS_P (TYPE_NAME (t)))
+  else if (CLASS_TYPE_P (t)
+          && TYPE_NAME (t) && !TYPE_DECL_ALIAS_P (TYPE_NAME (t)))
     return CLASSTYPE_TEMPLATE_INSTANTIATION (t)
           && PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t));
   else if (TYPE_P (t)

?

Technically clearing the anonymous names is probably no longer necessary,
I'm testing a patch to remove that.


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

* [Bug debug/51262] [4.7 Regression] ICE: SIGSEGV in primary_template_instantiation_p (pt.c:2874) with -flto -g
  2011-11-22  0:02 [Bug debug/51262] New: [4.7 Regression] ICE: SIGSEGV in primary_template_instantiation_p (pt.c:2874) with -flto -g zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2011-12-08 17:06 ` rguenth at gcc dot gnu.org
@ 2011-12-09  3:49 ` jason at redhat dot com
  2011-12-09  9:22 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at redhat dot com @ 2011-12-09  3:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jason Merrill <jason at redhat dot com> 2011-12-09 03:25:17 UTC ---
On 12/08/2011 11:46 AM, rguenth at gcc dot gnu.org wrote:
> Dodji, Jason, can such anonymous name types ever have TYPE_DECL_ALIAS_P
> set?

They can't, but

> -  else if (CLASS_TYPE_P (t) &&  !TYPE_DECL_ALIAS_P (TYPE_NAME (t)))
> +  else if (CLASS_TYPE_P (t)
> +           && TYPE_NAME (t) && !TYPE_DECL_ALIAS_P (TYPE_NAME (t)))
>       return CLASSTYPE_TEMPLATE_INSTANTIATION (t)
>             && PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t));

I would reverse the sense here so that the condition is satisfied by a 
null TYPE_NAME, since an anonymous union is a non-alias class.

Jason


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

* [Bug debug/51262] [4.7 Regression] ICE: SIGSEGV in primary_template_instantiation_p (pt.c:2874) with -flto -g
  2011-11-22  0:02 [Bug debug/51262] New: [4.7 Regression] ICE: SIGSEGV in primary_template_instantiation_p (pt.c:2874) with -flto -g zsojka at seznam dot cz
                   ` (5 preceding siblings ...)
  2011-12-09  3:49 ` jason at redhat dot com
@ 2011-12-09  9:22 ` rguenth at gcc dot gnu.org
  2011-12-12  8:39 ` rguenth at gcc dot gnu.org
  2011-12-12  8:40 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-12-09  9:22 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |rguenth at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-12-09 09:17:13 UTC ---
Patch no longer freeing TYPE_NAME in cp_free_lang_data posted.


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

* [Bug debug/51262] [4.7 Regression] ICE: SIGSEGV in primary_template_instantiation_p (pt.c:2874) with -flto -g
  2011-11-22  0:02 [Bug debug/51262] New: [4.7 Regression] ICE: SIGSEGV in primary_template_instantiation_p (pt.c:2874) with -flto -g zsojka at seznam dot cz
                   ` (6 preceding siblings ...)
  2011-12-09  9:22 ` rguenth at gcc dot gnu.org
@ 2011-12-12  8:39 ` rguenth at gcc dot gnu.org
  2011-12-12  8:40 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-12-12  8:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-12-12 08:37:27 UTC ---
Author: rguenth
Date: Mon Dec 12 08:37:22 2011
New Revision: 182221

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

    PR lto/51262
    * tree.c (cp_free_lang_data): No longer clear anonymous names.

    * g++.dg/opt/pr51262.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/opt/pr51262.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/tree.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug debug/51262] [4.7 Regression] ICE: SIGSEGV in primary_template_instantiation_p (pt.c:2874) with -flto -g
  2011-11-22  0:02 [Bug debug/51262] New: [4.7 Regression] ICE: SIGSEGV in primary_template_instantiation_p (pt.c:2874) with -flto -g zsojka at seznam dot cz
                   ` (7 preceding siblings ...)
  2011-12-12  8:39 ` rguenth at gcc dot gnu.org
@ 2011-12-12  8:40 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-12-12  8:40 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #7 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-12-12 08:37:38 UTC ---
Fixed.


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

end of thread, other threads:[~2011-12-12  8:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-22  0:02 [Bug debug/51262] New: [4.7 Regression] ICE: SIGSEGV in primary_template_instantiation_p (pt.c:2874) with -flto -g zsojka at seznam dot cz
2011-12-05 14:25 ` [Bug debug/51262] " rguenth at gcc dot gnu.org
2011-12-06 14:08 ` rguenth at gcc dot gnu.org
2011-12-06 14:24 ` rguenth at gcc dot gnu.org
2011-12-07  7:22 ` reichelt at gcc dot gnu.org
2011-12-08 17:06 ` rguenth at gcc dot gnu.org
2011-12-09  3:49 ` jason at redhat dot com
2011-12-09  9:22 ` rguenth at gcc dot gnu.org
2011-12-12  8:39 ` rguenth at gcc dot gnu.org
2011-12-12  8:40 ` rguenth 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).