On Mon, 2008-06-02 at 18:32 +0200, Manuel Teira wrote:
> ...
> So, I've added some traces to my addFd, delFd, modFd, and wait 
> implementations, also a log in Dispatcher::run(), showing:
> 
>         QPID_LOG(trace, "Got an event with handle: " << event.handle
>                  << " Type: " << typeid(*(event.handle)).name());
> 
> Just between the reception of the event, and the downcast attempt.
> 
> 
> What I see is::

> ...
> Type: qpid::sys::AsynchIO
> Assertion failed: dynamic_cast<Target>(x) == x, file 
> /opt/dslap/contrib/include/boost/cast.hpp, line 97
> Abort (core dumped)

I think you should see a DispatchHandle type not an AsynchIO type (even
if that is the dynamic type), not 100% sure though - this because you do
actually put a DispatchHandle in there (in the Dispatcher code).

The problem could be caused by compiling without typeinfo - I don't know
the default settings for the Sun Forte compiler.

> 
> I can see an event for the handle bound to the file descriptor 4. This 
> is due to the activity in the socket, and sounds like the poller is 
> doing its job.
> The event reaches the Dispatcher::run, a new Handle is added with fd=5, 
> probably the result of the accept call on the socket.
> But then, a new event is generated on the handle bound to the fd=5. Once 
> it reaches the Dispatcher::run() method, its type is 
> qpid::sys::AsynchIO. and surprisingly, the assertion fails.

This could alternatively be due to the code relying on some gcc specific
feature of casting to private bases, but I think not. That's because the
type sent to the Poller is DispatcherHandle* which gets upcast to
PollerHandle*, and that is what we try to convert to our
DispatcherHandle* later on. The fact that we are really using an
AsynchIO as the most derived type shouldn't matter.

> 
> Surprisingly, looking at qpid::sys::AsynchIO, in the class definition:
> 
> class AsynchIO : private DispatchHandle
> 

I don't think this bit is that relevant in any case as you can't do the
conversion of AsynchIO -> DispatchHandle unless you are in AsynchIO as
it's a private base class.

But given a DispatchHandle which is passed as a PollerHandle you should
be able to dynamically cast the PollerHandle->DispatchHandle.

> Humm, weird.

I'd go look at the compiler options, and make sure that you are
generating proper typeinfo. Or it could be a Sun compiler bug (not very
likely).

Hope this helps.

Andrew


Reply via email to