Bug 7788 - g++-3.2 internal error: Segmentation fault
g++-3.2 internal error: Segmentation fault
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: c++
3.2
: P3 normal
: ---
Assigned To: Nathan Sidwell
:
: 7743 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2002-08-31 00:06 UTC by jerrysiebe
Modified: 2003-07-25 17:33 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
foobar.cpp (44 bytes, application/octet-stream)
2003-05-21 15:16 UTC, jerrysiebe
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jerrysiebe 2002-08-31 00:06:00 UTC
foobar.cpp:3: internal error: Segmentation fault

class foo;
extern const foo bar;
class bar;  // kaBoom! :o

I think that says it all.  :)

The following versions don't exhibit this behaviour:
gcc version 2.96 20000731 (Mandrake Linux 8.2 2.96-0.76mdk)
gcc version 3.0.4 (Mandrake Linux 8.2 3.0.4-2mdk)
gcc version 3.1 (Thread model: single, otherwise similar to my 3.2 build)

Release:
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/specs  Configured with: ../gcc-3.2/configure  Thread model: posix  gcc version 3.2

Environment:
GNU/Linux, Mandrake 8.2
Athlon XP 1800+

How-To-Repeat:
g++ -c foobar.cpp
Comment 1 Nathan Sidwell 2002-09-13 13:39:32 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: confirmed as a regression
Comment 2 Nathan Sidwell 2002-09-29 10:44:01 UTC
Responsible-Changed-From-To: unassigned->nathan
Responsible-Changed-Why: patching
Comment 3 pop 2002-09-29 11:08:53 UTC
From: =?iso-8859-1?Q?Pop_S=E9bastian?= <pop@gauvain.u-strasbg.fr>
To: nathan@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org,
	jerrysiebe@mindspring.com, nobody@gcc.gnu.org,
	gcc-gnats@gcc.gnu.org
Cc: nathan@codesourcery.com
Subject: Re: c++/7788: g++-3.2 internal error: Segmentation fault
Date: Sun, 29 Sep 2002 11:08:53 +0200

 On Fri, Sep 13, 2002 at 08:39:32PM -0000, nathan@gcc.gnu.org wrote:
 > Synopsis: g++-3.2 internal error: Segmentation fault
 > 
 > State-Changed-From-To: open->analyzed
 > State-Changed-By: nathan
 > State-Changed-When: Fri Sep 13 13:39:32 2002
 > State-Changed-Why:
 >     confirmed as a regression
 > 
 > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7788
 
 
 The problem comes from cp/rtti.c in unemitted_tinfo_decl_p ().
 
 Associated patch with these changes is:
 
 Date: Fri, 21 Jun 2002 12:20:51 +0100
 From: Nathan Sidwell <nathan@codesourcery.com>
 Organization: Codesourcery LLC
 X-Accept-Language: en
 To: jason@redhat.com
 Cc: gcc-patches@gcc.org
 Subject: [C++ PATCH]: Rework typeinfo objects
 
 2002-06-20  Nathan Sidwell  <nathan@codesourcery.com>
 
 
   int
 ! tinfo_decl_p (t, data)
        tree t;
        void *data ATTRIBUTE_UNUSED;
   {
 !   return TREE_CODE (t) == VAR_DECL
 !          && IDENTIFIER_GLOBAL_VALUE (DECL_NAME (t)) == (t)
 !          && TREE_TYPE (t) == tinfo_decl_type
 !          && TREE_TYPE (DECL_NAME (t));
   }
 
 
 Changed into 
 
 
   int
 ! unemitted_tinfo_decl_p (t, data)
        tree t;
        void *data ATTRIBUTE_UNUSED;
   {
 !   if (/* It's a var decl */
 !       TREE_CODE (t) == VAR_DECL
 !       /* whos name points back to itself */
 !       && IDENTIFIER_GLOBAL_VALUE (DECL_NAME (t)) == t
 !       /* whos name's type is non-null */
 !       && TREE_TYPE (DECL_NAME (t))
 !       /* and whos type is a struct */
 !       && TREE_CODE (TREE_TYPE (t)) == RECORD_TYPE
 !       /* with a first field of our pseudo type info */
 !       && TREE_TYPE (TYPE_FIELDS (TREE_TYPE (t))) == ti_desc_type_node)
 !     return 1;
 !   return 0;
   }
 
 
 I rewrote the condition as :
 
 
 int
 unemitted_tinfo_decl_p (t, data)
      tree t;
      void *data ATTRIBUTE_UNUSED;
 {
   /* It's a var decl */
   if (TREE_CODE (t) == VAR_DECL)
     {
       tree dnt = DECL_NAME (t);
       /* whos name points back to itself */
       if (IDENTIFIER_GLOBAL_VALUE (dnt) == t)
         /* whos name's type is non-null */
         if (TREE_TYPE (dnt))
           {
             tree ttt = TREE_TYPE (t);
             /* and whos type is a struct */
             if (TREE_CODE (ttt) == RECORD_TYPE) 
               {
                 tree tfttt = TYPE_FIELDS (ttt);
                 /* with a first field of our pseudo type info */
 =>              if (TREE_TYPE (tfttt) == ti_desc_type_node)
                   return 1;
               }
           }
     }
   return 0;
 }
 
 
 
 The problem is here => since tfttt is NULL in this bug-report example.
 Nathan could you review this patch and the associated bug-report please?
 
 Thanks, 
 Sebastian
Comment 4 Nathan Sidwell 2002-09-29 11:28:15 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: 2002-09-29  Nathan Sidwell  <nathan@codesourcery.com>
    
    	PR c++/7788
    	* rtti.c (unemitted_tinfo_decl_p): Check it has a field.
Comment 5 Nathan Sidwell 2002-09-29 18:27:02 UTC
From: nathan@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/7788
Date: 29 Sep 2002 18:27:02 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	nathan@gcc.gnu.org	2002-09-29 11:27:02
 
 Modified files:
 	gcc/cp         : ChangeLog rtti.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/rtti: crash1.C 
 
 Log message:
 	cp:
 	PR c++/7788
 	* rtti.c (unemitted_tinfo_decl_p): Check it has a field.
 	testsuite:
 	* g++.dg/rtti/crash1.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.2970&r2=1.2971
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/rtti.c.diff?cvsroot=gcc&r1=1.142&r2=1.143
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2106&r2=1.2107
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/rtti/crash1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 

Comment 6 pop 2002-09-29 20:50:05 UTC
From: =?iso-8859-1?Q?Pop_S=E9bastian?= <pop@gauvain.u-strasbg.fr>
To: nathan@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org,
	gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/7788: g++-3.2 internal error: Segmentation fault
Date: Sun, 29 Sep 2002 20:50:05 +0200

 Hi Nathan,
 
 On Sun, Sep 29, 2002 at 06:28:15PM -0000, nathan@gcc.gnu.org wrote:
 > Synopsis: g++-3.2 internal error: Segmentation fault
 > 
 > State-Changed-From-To: analyzed->closed
 > State-Changed-By: nathan
 > State-Changed-When: Sun Sep 29 11:28:15 2002
 > State-Changed-Why:
 >     2002-09-29  Nathan Sidwell  <nathan@codesourcery.com>
 >     
 >     	PR c++/7788
 >     	* rtti.c (unemitted_tinfo_decl_p): Check it has a field.
 >     
 > 
 > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7788
 
 
 This also solves PR#7743
 
 
 Sebastian

Comment 7 Nathan Sidwell 2002-11-11 12:42:18 UTC
From: nathan@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/7788
Date: 11 Nov 2002 12:42:18 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_2-branch
 Changes by:	nathan@gcc.gnu.org	2002-11-11 04:42:17
 
 Modified files:
 	gcc/cp         : ChangeLog rtti.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/rtti: crash1.C 
 
 Log message:
 	cp:
 	PR c++/7788
 	* rtti.c (unemitted_tinfo_decl_p): Check it has a field.
 	testsuite:
 	PR c++/7788
 	* g++.dg/rtti/crash1.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.2685.2.114.2.40&r2=1.2685.2.114.2.41
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/rtti.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.130.6.1&r2=1.130.6.2
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.1672.2.166.2.47&r2=1.1672.2.166.2.48
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/rtti/crash1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=NONE&r2=1.1.14.1
 

Comment 8 Nathan Sidwell 2002-11-11 12:42:18 UTC
From: nathan@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/7788
Date: 11 Nov 2002 12:42:18 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_2-branch
 Changes by:	nathan@gcc.gnu.org	2002-11-11 04:42:17
 
 Modified files:
 	gcc/cp         : ChangeLog rtti.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/rtti: crash1.C 
 
 Log message:
 	cp:
 	PR c++/7788
 	* rtti.c (unemitted_tinfo_decl_p): Check it has a field.
 	testsuite:
 	PR c++/7788
 	* g++.dg/rtti/crash1.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.2685.2.114.2.40&r2=1.2685.2.114.2.41
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/rtti.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.130.6.1&r2=1.130.6.2
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.1672.2.166.2.47&r2=1.1672.2.166.2.48
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/rtti/crash1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=NONE&r2=1.1.14.1