This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/9796: dynamic cast in shared library failed


>Number:         9796
>Category:       c++
>Synopsis:       dynamic cast in shared library failed
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 22 00:06:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     raymond at cdlsystems dot com
>Release:        GCC 3.2
>Organization:
>Environment:
linux
>Description:
When a class is created in the main function and passing it off to a shared library for downcasting, dynamic cast returns null.  

typedef void ( *PFN )( Parent* );

int main()
{
   Parent parent;
   Child child;
   void* pDl = dlopen ( "libshared.so",  
                        RTLD_GLOBAL|RTLD_NOW);
   PFN pfnAcquire = ( PFN )dlsym( pDl, "function1" );

   printf( "before %x %x\n", &child,  dynamic_cast<Child*>( &child ));
   pfnAcquire( &child );
}

In the acquired function from the shared library, if the same dynamic cast operation is done again, the result is always null.

When compiling the so file, -Wl,-E is used. See the attached script
 
>How-To-Repeat:
use the provided script to recompile the program and run it.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/x-zip-compressed; name="dynamiccast.zip"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="dynamiccast.zip"

UEsDBBQAAAAIAC+CVS7gQl6EgwAAAKsAAAAKAAAAc2hhcmVkLmN4eE2NQQrCMBRE9/8UQ0RISxFc
K256gR5AkJCk9kP7I+mvVMS7SxDF2c3wHrNh8eMSIoxP05RkNxiiuGrMAtMauicO6Bfxykn2Fp3L
UbSGunyNioqeBOCWWbS3MCyYE7YrvJs1BmgpZzENCvbNR27+p/AQN7G/FO/YDjyG+mR/L9WBXvQG
UEsDBBQAAAAIAMuCVS6vh+4RlQAAADUBAAAIAAAAY29tbW9uLmiV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Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]