Problem with dynamic_cast when using dynamic libraries and x86

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with dynamic_cast when using dynamic libraries and x86

Johnny Willemsen
Hi,

The correct usage of declspec export/import has fixed several problems. We
have now been able to narrow another runtime problem we see.

We have a base class, ACE_Reactor_Impl, from that we have derived
ACE_Select_Reactor_Impl (all in the ACE library). In our code we do:

      this->select_reactor_ =
        dynamic_cast<ACE_Select_Reactor_Impl *> (r);

      if (select_reactor_ == 0)
        {
          errno = EINVAL;
          return -1;
        }

We now see that this->select_reactor_ is 0, so the dynamic cast fails.

When we print the typename or *r we get:
20ACE_Select_Reactor_TI19ACE_Reactor_Token_TI9ACE_TokenEE20ACE_Select_Reacto
r_TI19ACE_Reactor_Token_TI9ACE_TokenEE

ACE_Select_Reactor_T is a template derived from ACE_Select_Reactor_Impl. So,
we should be able to do a dynamic cast to AE_Select_Reactor_Impl. Could this
be a problem with rtti or again symbol exports?

Anyone an idea?

Danny, the cast is in Select_Reactor_Base.cpp, line 614. Reproducable by
running tests/Reactor_Exception_Test

Johnny



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Cegcc-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/cegcc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Problem with dynamic_cast when using dynamic libraries and x86

Danny Backx
I believe the patch just applied (imported from gcc svn, work by Jason
Merrill) fixes this :

\network\x86\ace> Reactor_Exceptions_Test
(78512150|78577686) Starting Reactor_Exceptions_Test test at Tue Aug 18
2009 21:43:16.859000
Starting tracing
Activity occurred on handle 7!
got buf = Hello
(78512150|91619350) throw exception
 (91619350) catch exception
 (91619350) exception return
 (78577686) exiting main
(78512150|78577686) Ending Reactor_Exceptions_Test test t Tue Aug 18
2009 21:43:16.985000
\network\x86\ace>

Also the test you privately sent me is fixed :

\network\x86> static
cFoo constructor
cBar constructor
Foo pointer 16020630 Bar pointer 16020630
I am cBar.
cBar destructor
cFoo destructor
\network\x86> dll
cFoo constructor
cBar constructor
Foo pointer 180206b0 Bar pointer 180206b0
I am cBar.
cBar destructor
cFoo destructor
\network\x86>

        Danny

On Thu, 2009-08-13 at 21:33 +0200, Johnny Willemsen wrote:

> Hi,
>
> The correct usage of declspec export/import has fixed several problems. We
> have now been able to narrow another runtime problem we see.
>
> We have a base class, ACE_Reactor_Impl, from that we have derived
> ACE_Select_Reactor_Impl (all in the ACE library). In our code we do:
>
>       this->select_reactor_ =
>         dynamic_cast<ACE_Select_Reactor_Impl *> (r);
>
>       if (select_reactor_ == 0)
>         {
>           errno = EINVAL;
>           return -1;
>         }
>
> We now see that this->select_reactor_ is 0, so the dynamic cast fails.
>
> When we print the typename or *r we get:
> 20ACE_Select_Reactor_TI19ACE_Reactor_Token_TI9ACE_TokenEE20ACE_Select_Reacto
> r_TI19ACE_Reactor_Token_TI9ACE_TokenEE
>
> ACE_Select_Reactor_T is a template derived from ACE_Select_Reactor_Impl. So,
> we should be able to do a dynamic cast to AE_Select_Reactor_Impl. Could this
> be a problem with rtti or again symbol exports?
>
> Anyone an idea?
>
> Danny, the cast is in Select_Reactor_Base.cpp, line 614. Reproducable by
> running tests/Reactor_Exception_Test
>
> Johnny
>
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Cegcc-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/cegcc-devel
--
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Cegcc-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/cegcc-devel