c++/8847: dynamic_cast segfaults with shared lib

Hans Utz hans.utz@informatik.uni-ulm.de
Fri Dec 6 09:26:00 GMT 2002


The following reply was made to PR c++/8847; it has been noted by GNATS.

From: Hans Utz <hans.utz@informatik.uni-ulm.de>
To: bangerth@dealii.org, gcc-bugs@gcc.gnu.org,
 	gcc-prs@gcc.gnu.org, hans.utz@informatik.uni-ulm.de,
 	nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/8847: dynamic_cast segfaults with shared lib
Date: Fri, 06 Dec 2002 18:19:18 +0100

 bangerth@dealii.org wrote:
 > 
 > Synopsis: dynamic_cast segfaults with shared lib
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: bangerth
 > State-Changed-When: Fri Dec  6 09:12:57 2002
 > State-Changed-Why:
 >     I can confirm the problem with a slightly smaller program:
 >     ------------------------------
 >     struct Foo {
 >       virtual ~Foo(){};
 >     };
 > 
 >     struct myBar : public Foo {
 >       virtual ~myBar(){};
 >     };
 > 
 >     int main(int, char **)
 >     {
 >       dynamic_cast<myBar *>((Foo*)new myBar());
 > 
 >       return 0;
 >     }
 >     ----------------------------------
 >     Linking with libGLU alone suffices to crash the program.
 > 
 >     However: on my system, which is very much like yours,
 >     libGLU and libGL are located in /usr/lib, i.e. are
 >     system libraries and are thus probably compiled with
 >     gcc 2.95. In contrast to libGL, libGLU has C++ symbols
 >     in it, so I am pretty sure that the problem stems from
 >     the ABI incompatibilities between the 2.95 C++ compiler
 >     and the 3.2 C++ compiler. This has to be expected. Linking
 >     C++ libraries together that have not been created with the
 >     same compiler asks for trouble (or at least did, prior to
 >     the standard gcc is trying to follow since 3.2). Can you
 >     report what happens if you try to use a libGLU that is
 >     compiled with the same compiler as the one you use
 >     for the rest of the project, i.e. 3.2.1?
 > 
 >     Thanks
 >       Wolfgang
 > 
 > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8847
 
 I didn't know libGLU contains C++ symbols. I will look for the sources, compile
 them and try again.
 
 Thanks,
 Hans



More information about the Gcc-prs mailing list