Bug 19567 - dynamic_cast failure in dlopen-ed shared object
Summary: dynamic_cast failure in dlopen-ed shared object
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.2
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-21 17:24 UTC by David Daeschler
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

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


Attachments
Example program that demonstrates the bug (1.67 KB, application/octet-stream)
2005-01-21 17:29 UTC, David Daeschler
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Daeschler 2005-01-21 17:24:43 UTC
Please note this is not a duplicate of #4993, because I am using RTLD_GLOBAL and
-Wl,-E.

This test project demonstatrates a problem when using dynamic_cast from inside a
shared object to attempt to convert a base class (interface) to a derived class
(another interface) whose definitions are in header files shared between the
application and the shared object.

When casting from a base class to the derived class from inside the main
executable, dynamic_cast works as expected and returns a non null pointer. 
However, from inside of the dlopen-ed shared library, the dynamic_cast function
incorrectly returns zero.

Attachment will follow.
Comment 1 David Daeschler 2005-01-21 17:29:38 UTC
Created attachment 8032 [details]
Example program that demonstrates the bug
Comment 2 David Daeschler 2005-01-21 17:30:04 UTC
Tested on fedora core 2 and 3, results are the same.
more info:  fc2: gcc version 3.3.3 20040412

Works on windows 3.4.2 (mingw-special) most likely because of the lack of
support for weak symbols.
Comment 3 Chris Jefferson 2005-01-28 14:53:50 UTC
I don't think this bug has anything to do with libstdc++ (which over covers
errors in the c++ standard library). I would suggest changing the Component to
c++, which I suspect a closer match for where the bug lives (although I'm not
certain I will admit).
Comment 4 David Daeschler 2005-01-28 15:10:17 UTC
Hi Chris,

I beleive that this problem may be related to the typeinfo header or other 
related headers that are involved with RTTI.

I have also refered to an older bug that involved this same problem which was 
posted under libstdc++ and appeared to have been resolved in this category:  
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4292

However, I could be wrong, so if you are positive I have this in the wrong 
category I will move it.

Thank you,
- Dave
Comment 5 David Daeschler 2005-02-02 03:28:38 UTC
This is becoming a real showstopper for me, so I am changing the component to
C++ in the hopes that it is a closer match and this bug will be looked at.
Comment 6 Andrew Pinski 2005-02-02 03:52:16 UTC
You messed up you used -W1, not -Wl which is different.

you need to use l as in the lowercase L.
I changed the Makefile to use -Wl,-E and it worked.