Bug#134262: g++-3.0: Use of dynamic_cast makes compiled program segfault
On 2002-02-16 23:01:21, Martin v. Loewis wrote:
> Daniel Sj�ölie <deepone@acc.umu.se> writes:
>
> > 0x400a9c59 in osgDB::ReaderWriter::ReadResult::getNode() (this=0xbffff2a0)
> > at /home/source/osg/cvs/include/osgDB/ReaderWriter:64
> > 64 osg::Node* getNode() { return dynamic_cast<osg::Node*>(_object.get()); }
> > (gdb) s
> >
> > Program received signal SIGSEGV, Segmentation fault.
>
> Can you give a precise specification of the source code you have
> compiled to generate this problem?
The problem is in the code of Open Scene Graph (osg)
(http://www.openscenegraph.org/)
The gdb-info above was from my own program but the demos included with
osg also segfaults... osgcube segfaults on a dynamic_cast like my
program and I didn't check the rest...
> Are you sure that you are not invoking undefined behaviour? More
> specifically, are you sure that 0x808f170 really represents an
> osg::Object* to an object that has been allocated but not yet deleted?
Not sure, not my code, but would gdb say this if it wasn't true?
> > (gdb) print _ptr
> > $5 = (Object *) 0x808f170
And it works fine with g++-2.9x...
osg maintainter cc:ed...
> If this address was a pointer to some character string, or to
> something that is not an osg::Object, or delete was already executed
> for the pointer, then the crash would be completely understandable,
> and would indicate a bug in the application. A dynamic_cast has
> undefined behaviour if the static type of its argument is incorrect.
/Daniel
--
Now take a deep breath, smile and don't take life so seriously... :)
Reply to: