Bug 28659 - [4.2 regression] ICE (segfault) while compiling kdelibs 4.0 snapshot
Summary: [4.2 regression] ICE (segfault) while compiling kdelibs 4.0 snapshot
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P1 normal
Target Milestone: 4.2.0
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code
: 28863 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-08-08 20:06 UTC by bero
Modified: 2006-08-28 06:18 UTC (History)
7 users (show)

See Also:
Host: i586-pc-linux-gnu
Target: i586-pc-linux-gnu
Build: i586-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2006-08-13 12:48:44


Attachments
Preprocessed source (33.47 KB, application/x-bzip2)
2006-08-08 20:08 UTC, bero
Details
Simplified test case (176 bytes, text/x-c++src)
2006-08-08 20:17 UTC, bero
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bero 2006-08-08 20:06:37 UTC
/usr/src/ark/BUILD/kdelibs/phonon/objectdescription.cpp: In member function 'Phonon::ObjectDescription<T>& Phonon::ObjectDescription<T>::operator=(const Phonon::ObjectDescription<T>&)':
/usr/src/ark/BUILD/kdelibs/phonon/objectdescription.cpp:54: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 bero 2006-08-08 20:08:08 UTC
Created attachment 12043 [details]
Preprocessed source
Comment 2 bero 2006-08-08 20:17:57 UTC
Created attachment 12044 [details]
Simplified test case
Comment 3 bero 2006-08-08 20:19:29 UTC
The problem in the simplified test case goes away when removing the __attribute__((visibility("default")))
Comment 4 Martin Michlmayr 2006-08-08 20:50:39 UTC
Confirmed.

 test::TestDescription<T>& test::TestDescription<T>::operator=(const test::TestDescription<T>&)
Program received signal SIGSEGV, Segmentation fault.
0x0000000000477cd3 in min_vis_r (tp=<value optimized out>, walk_subtrees=0x7fffcc62fa84,
    data=0x7fffcc62fc24) at /home/tbm/scratch/gcc/gcc/cp/decl2.c:1550
1550          if (!TREE_PUBLIC (TYPE_MAIN_DECL (*tp)))
(gdb) where
#0  0x0000000000477cd3 in min_vis_r (tp=<value optimized out>, walk_subtrees=0x7fffcc62fa84,
    data=0x7fffcc62fc24) at /home/tbm/scratch/gcc/gcc/cp/decl2.c:1550
#1  0x000000000086e318 in walk_tree (tp=0x2aaedebb40b8, func=0x477c90 <min_vis_r>,
    data=0x7fffcc62fc24, pset=0xd517b0) at /home/tbm/scratch/gcc/gcc/tree.c:7427
#2  0x000000000086ed3e in walk_tree (tp=0x2aaedebb4218, func=0x477c90 <min_vis_r>,
    data=0x7fffcc62fc24, pset=0xd517b0) at /home/tbm/scratch/gcc/gcc/tree.c:7652
#3  0x000000000086f211 in walk_type_fields (type=0x2aaedebb4210, func=0x477c90 <min_vis_r>,
    data=0x7fffcc62fc24, pset=dwarf2_read_address: Corrupted DWARF expression.
) at /home/tbm/scratch/gcc/gcc/tree.c:7355
#4  0x000000000086ed3e in walk_tree (tp=0x7fffcc62fc10, func=0x477c90 <min_vis_r>,
    data=0x7fffcc62fc24, pset=0xd517b0) at /home/tbm/scratch/gcc/gcc/tree.c:7652
#5  0x000000000086f11a in walk_tree_without_duplicates (tp=0x7fffcc62fc10,
    func=0x477c90 <min_vis_r>, data=0x7fffcc62fc24) at /home/tbm/scratch/gcc/gcc/tree.c:7672
#6  0x00000000004793f2 in type_visibility (type=0x2aaedebb4210)
    at /home/tbm/scratch/gcc/gcc/cp/decl2.c:1568
#7  0x0000000000479bb7 in determine_visibility (decl=0x2aaedeba9ee0)
    at /home/tbm/scratch/gcc/gcc/cp/decl2.c:1782
#8  0x0000000000413914 in start_preparsed_function (decl1=0x2aaedeba9ee0,
    attrs=<value optimized out>, flags=<value optimized out>)
    at /home/tbm/scratch/gcc/gcc/cp/decl.c:10644
#9  0x000000000042cfaf in start_function (declspecs=<value optimized out>,
    declarator=<value optimized out>, attrs=0x0) at /home/tbm/scratch/gcc/gcc/cp/decl.c:10690
#10 0x00000000004942c7 in cp_parser_init_declarator (parser=0x2aaedea23500,
    decl_specifiers=0x7fffcc62fdb0, checks=0x0, function_definition_allowed_p=1 '\001',
    member_p=0 '\0', declares_class_or_enum=<value optimized out>,
    function_definition_p=0x7fffcc62fe0f "\001") at /home/tbm/scratch/gcc/gcc/cp/parser.c:15374
#11 0x00000000004947dd in cp_parser_single_declaration (parser=0x2aaedea23500, checks=0x0,
    member_p=0 '\0', friend_p=<value optimized out>) at /home/tbm/scratch/gcc/gcc/cp/parser.c:15684
#12 0x00000000004a2404 in cp_parser_template_declaration_after_export (parser=0x2aaedea23500,
    member_p=0 '\0') at /home/tbm/scratch/gcc/gcc/cp/parser.c:15543
#13 0x00000000004a41f7 in cp_parser_declaration (parser=0x2aaedea23500)
    at /home/tbm/scratch/gcc/gcc/cp/parser.c:7108
#14 0x00000000004a475a in cp_parser_declaration_seq_opt (parser=0x2aaedea23500)
    at /home/tbm/scratch/gcc/gcc/cp/parser.c:7031
#15 0x00000000004a4195 in cp_parser_declaration (parser=0x2aaedea23500)
    at /home/tbm/scratch/gcc/gcc/cp/parser.c:10559
---Type <return> to continue, or q <return> to quit---
#16 0x00000000004a475a in cp_parser_declaration_seq_opt (parser=0x2aaedea23500)
    at /home/tbm/scratch/gcc/gcc/cp/parser.c:7031
#17 0x00000000004a4e49 in c_parse_file () at /home/tbm/scratch/gcc/gcc/cp/parser.c:2755
#18 0x00000000005331b5 in c_common_parse_file (set_yydebug=<value optimized out>)
    at /home/tbm/scratch/gcc/gcc/c-opts.c:1164
#19 0x0000000000866f33 in toplev_main (argc=<value optimized out>, argv=<value optimized out>)
    at /home/tbm/scratch/gcc/gcc/toplev.c:999
#20 0x00002aaede5ab4ca in __libc_start_main () from /lib/libc.so.6
#21 0x000000000040273a in _start () at ../sysdeps/x86_64/elf/start.S:113
(gdb)
Comment 5 Janis Johnson 2006-08-11 18:46:09 UTC
A regression hunt on powerpc-linux using the test case added for comment #3 identified the following patch:

    http://gcc.gnu.org/viewcvs?view=rev&rev=115086

    r115086 | jason | 2006-06-30 01:15:56 +0000 (Fri, 30 Jun 2006)
Comment 6 Dirk Mueller 2006-08-13 12:48:44 UTC
I'm currently testing this patch: 

--- cp/decl2.c  (revision 116108)
+++ cp/decl2.c  (working copy)
@@ -1541,7 +1541,7 @@ static tree
 min_vis_r (tree *tp, int *walk_subtrees, void *data)
 {
   int *vis_p = (int *)data;
-  if (! TYPE_P (*tp))
+  if (! TYPE_P (*tp) || ! IS_AGGR_TYPE (*tp))
     {
       *walk_subtrees = 0;
     }
Comment 7 Dirk Mueller 2006-08-18 17:55:29 UTC
struct o<T>D.1993:
 <record_type 0xb7dd49b4 o<T> type_0 type_5 type_6 BLK
    size <integer_cst 0xb7d1c930 type <integer_type 0xb7d3105c bit_size_type> constant invariant 0>
    unit size <integer_cst 0xb7d1c180 type <integer_type 0xb7d31000 unsigned int> constant invariant 0>
    align 8 symtab 0 alias set -1
    attributes <tree_list 0xb7da1d08
        purpose <identifier_node 0xb7da816c visibility
        bindings <(nil)>
        local bindings <(nil)>>
        value <tree_list 0xb7da1c90
            value <string_cst 0xb7da0640 type <array_type 0xb7dd4564>
                readonly constant invariant static "default\000">>>
    no-binfo use_template=1 interface-unknown>

the original type is:
o<T>D.1985::

 <method_type 0xb7dd4a6c
    type <record_type 0xb7dd49b4 o<T> type_0 type_5 type_6 BLK
        size <integer_cst 0xb7d1c930 constant invariant 0>
        unit size <integer_cst 0xb7d1c180 constant invariant 0>
        align 8 symtab 0 alias set -1
        attributes <tree_list 0xb7da1d08
            purpose <identifier_node 0xb7da816c visibility
            bindings <(nil)>
            local bindings <(nil)>>
            value <tree_list 0xb7da1c90
                value <string_cst 0xb7da0640 type <array_type 0xb7dd4564>
                    readonly constant invariant static "default\000">>>
        no-binfo use_template=1 interface-unknown>
    QI
    size <integer_cst 0xb7d1c1e0 type <integer_type 0xb7d3105c bit_size_type> constant invariant 8>
    unit size <integer_cst 0xb7d1c1f8 type <integer_type 0xb7d31000 unsigned int> constant invariant 1>
    align 8 symtab 0 alias set -1 method basetype <record_type 0xb7dd45c0 o<T>>
    arg-types <tree_list 0xb7da1fc0
        value <pointer_type 0xb7dd46d4 type <record_type 0xb7dd45c0 o<T>>
            unsigned SI
            size <integer_cst 0xb7d1c3d8 constant invariant 32>
            unit size <integer_cst 0xb7d1c168 constant invariant 4>
            align 32 symtab 0 alias set -1>
        chain <tree_list 0xb7d1cc30 value <void_type 0xb7d318a0 void>>>>

Comment 8 Jason Merrill 2006-08-21 22:04:07 UTC
Subject: Re:  [4.2 regression] ICE (segfault) while compiling
 kdelibs 4.0 snapshot

I think this patch fixes the bug, but don't have time to test before 
going out for the evening.
Index: decl2.c
===================================================================
*** decl2.c	(revision 116310)
--- decl2.c	(working copy)
*************** min_vis_r (tree *tp, int *walk_subtrees,
*** 1547,1553 ****
      }
    else if (CLASS_TYPE_P (*tp))
      {
!       if (!TREE_PUBLIC (TYPE_MAIN_DECL (*tp)))
  	{
  	  *vis_p = VISIBILITY_ANON;
  	  return *tp;
--- 1547,1553 ----
      }
    else if (CLASS_TYPE_P (*tp))
      {
!       if (!TREE_PUBLIC (TYPE_NAME (*tp)))
  	{
  	  *vis_p = VISIBILITY_ANON;
  	  return *tp;
Comment 9 Dirk Mueller 2006-08-22 09:19:46 UTC
Thanks Jason! I'll regtest immediately. 
Comment 10 Jason Merrill 2006-08-22 16:38:28 UTC
That patch didn't fix it, but I do have a fix now; I'll check it in soon.
Comment 11 Jason Merrill 2006-08-22 18:27:34 UTC
Subject: Bug 28659

Author: jason
Date: Tue Aug 22 18:27:26 2006
New Revision: 116329

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116329
Log:
        PR c++/28659
        * typeck.c (merge_types): If either of the types have the right
        attributes, return that one.

        * tree.c (cp_build_type_attribute_variant): Make sure we aren't
        doing this to class types.
        * typeck.c (original_type): Deal with type quals properly.

Added:
    trunk/gcc/testsuite/g++.dg/ext/attrib26.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/tree.c
    trunk/gcc/cp/typeck.c

Comment 12 Andrew Pinski 2006-08-22 20:12:06 UTC
Fixed.
Comment 13 Andrew Pinski 2006-08-27 15:41:29 UTC
*** Bug 28863 has been marked as a duplicate of this bug. ***
Comment 14 Bernardo Innocenti 2006-08-28 00:59:46 UTC
Please also backport to 4.1 (see #28863).
Comment 15 Andrew Pinski 2006-08-28 01:38:57 UTC
(In reply to comment #14)
> Please also backport to 4.1 (see #28863).
This never existed on 4.1.
Comment 16 Bernardo Innocenti 2006-08-28 05:05:50 UTC
(In reply to comment #15)
> This never existed on 4.1.

gcc 4.1.1 from FC6 crashes with the testcase of bug 28863.
Maybe it's some redhat specific patch, but they follow
gcc's 4.0-branch quite closely these days:

Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.1 20060825 (Red Hat 4.1.1-19)

Comment 17 Andrew Pinski 2006-08-28 05:13:35 UTC
(In reply to comment #16)
> (In reply to comment #15)
> > This never existed on 4.1.
> 
> gcc 4.1.1 from FC6 crashes with the testcase of bug 28863.
> Maybe it's some redhat specific patch, but they follow
> gcc's 4.0-branch quite closely these days:

And that is Redhat's branch which has the patch which caused this in the first place on it.  The FSF's 4.1 never had this bug.  Also redhat does not follow the 4.1 branch closely at all, they backport features like crazy still.
Comment 18 Bernardo Innocenti 2006-08-28 06:18:45 UTC
(In reply to comment #17)

> And that is Redhat's branch which has the patch which caused this in the first
> place on it.

Thus, I've filed a bug report in RedHat's bugzilla:

 https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=204277