[ace-users] ACE_TP_Reactor:random crash sometimes
Mihai Bucica
misu200 at yahoo.com
Tue Jun 12 10:10:01 CDT 2007
Thanks,
It seems everything works just fine now.
I give up using notification mechanism for the event
handler' message queue and now I just register
manually for write events when I place a message in
the handler queue
this->reactor ()->register_handler
(this, ACE_Event_Handler::WRITE_MASK);
--- Steve Huston <shuston at riverace.com> wrote:
> Hi Mihai,
>
> > Ok ..I've managed to simplify to the following
> > problem:
> >
> > While one thread from the reactor thread pool
> > (ACE_TP_Reactor is inside the handle_input() of a
> > handle another thread from the reactor thread pool
> is
> > calling handle_output() on the same handle.
>
> Ok.
>
> > Is this behaviour possible?
>
> Since it's happening, it's possible ;-)
>
> > In C++NPv2 it is stated about ACE_TP_Reactor:
> > "It prevents multiple I/O events from being
> dispatched
> > to the same event handler simultaneously in
> different
> > threads. This constraint preserves the I/O
> dispatching
> > behavior of ACE_Select_Reactor, alleviating the
> need
> > to add synchronization locks to a handler's I/O
> > processing."
> >
> > I'm a little puzzled
>
> The key phrase in the above is "I/O events" - this
> does not include
> notifications. Notifications and I/O can be
> dispatched in different
> threads to the same handler. Same thing with timers.
>
> I recommend you investigate the reference counted
> handlers way of
> dealing with this. I'm available for consulting this
> week if you get
> into a jam and would like some help.
>
> -Steve
>
> --
> Steve Huston, Riverace Corporation
> Would you like ACE to run great on your platform?
> See http://www.riverace.com/sponsor.htm
>
> > --- Steve Huston <shuston at riverace.com> wrote:
> >
> > > Hi Mihai,
> > >
> > > It could be that the reactor is still
> dispatching
> > > notifications after
> > > the handler is unregistered. You can investigate
> two
> > > ways to avoid
> > > this:
> > >
> > > 1. See sidebar 22 on page 94 in C++NPv2
> > > 2. Use event handler reference counting to avoid
> > > deleting a handler
> > > while there's a reference pending (the notify).
> See
> > > ACE News and Tips
> > > Newsletter from October 2005
> > >
> >
>
(http://www.riverace.com/newsletters/October2005.htm)
> > >
> > > Best regards,
> > > -Steve
> > >
> > > --
> > > Steve Huston, Riverace Corporation
> > > Would you like ACE to run great on your
> platform?
> > > See http://www.riverace.com/sponsor.htm
> > >
> > >
> > > > -----Original Message-----
> > > > From: ace-users-bounces at cse.wustl.edu
> > > > [mailto:ace-users-bounces at cse.wustl.edu] On
> Behalf
> > > Of Mihai Bucica
> > > > Sent: Tuesday, June 12, 2007 6:17 AM
> > > > To: ace-users at cse.wustl.edu
> > > > Subject: Re: [ace-users] ACE_TP_Reactor:random
> > > crash sometimes
> > > >
> > > >
> > > >
> > > > --- "Douglas C. Schmidt"
> > > <schmidt at dre.vanderbilt.edu>
> > > > wrote:
> > > > > > ACE VERSION: 5.5
> > > > >
> > > > > ACE 5.5 is rather old, so could you please
> try
> > > > > upgrading to ACE+TAO+CIAO
> > > >
> > > >
> > > > I've compiled it the latest beta kit ACE 5.5.8
> and
> > > the
> > > > issue is valid.
> > > >
> > > > PRF:
> > > >
> > > > ACE_TP_Reactor:random crash sometimes
> > > >
> > > > ACE VERSION: 5.5.8 (latest beta kit)
> > > >
> > > > HOST MACHINE and OPERATING SYSTEM:
> > > > AMD Turion 64 & Windows XP Pro 32
> > > >
> > > > COMPILER NAME AND VERSION (AND
> PATCHLEVEL):
> > > > Microsoft Visual C++ .NET 2003
> > > >
> > > > THE $ACE_ROOT/ace/config.h FILE :
> > > > #include "ace/config-win32.h"
> > > >
> > > > AREA/CLASS/EXAMPLE AFFECTED:
> > > > ACE_TP_Reactor & Acceptor
> > > >
> > > > DOES THE PROBLEM AFFECT:
> > > > EXECUTION
> > > >
> > > > SYNOPSIS:
> > > > sometimes one thread from
> ACE_TP_Reactor'
> > > pool
> > > > is trying to access a recently removed handle
> > > >
> > > > DESCRIPTION:
> > > > I'm trying to build a server starting
> from
> > > > examples/APG/TreadPools/TP_Reactor project and
> > > I've
> > > > performed the following small modifications:
> > > > I've added a
> > > 'ACE_Reactor_Notification_Strategy
> > > > _notifier' to our Request_Handler class and
> also
> > > done
> > > > the proper initialization stuff:
> > > >
> > > > Request_Handler: notifier_ (0, this,
> > > > ACE_Event_Handler::WRITE_MASK)
> > > > Request_Handler::open ->
> > > this->notifier_.reactor
> > > > (this->reactor ());
> > > > this->msg_queue
> > > > ()->notification_strategy (&this->notifier_);
>
> > > >
> > > > I'm also doing a strange thing in
> > > handle_input()
> > > >
> > > > int Request_Handler::handle_input() {
> > > > ..............
> > > > ACE_Message_Block *mb = new
> > > > ACE_Message_Block(sizeof(buffer)+1);
> > > > mb->copy(buffer,sizeof(buffer));
> > > > this->putq(mb);
> > > >
> > > > return -1;
> > > > }
> > > >
> > > > int Request_Handler::handle_close
> > > (ACE_HANDLE
> > > > fd, ACE_Reactor_Mask)
> > > > {
> > > > ACE_DEBUG ((LM_DEBUG,
> > > > ACE_TEXT ("(%t) svr close; fd:
> > > 0x%x\n"),
> > > > fd));
> > > >
> > > > return super::handle_close();
> > > > }
> > > >
> > > > This will cause the program to crash
> > > > sometimes.The 'handle' is removed from reactor
> and
> > > > deleted but another thread from the thread
> pool
> > > will
> > > > try to output our ACE_Message_Block object
> from
> > > the
> > > > event handler internal queue.
> > > > (5200) handling events ....
> > > > (3672) handling events ....
> > > > (5676) handling events ....
> > > > Request_Handler::open
> > > > (3672) handling events ....
> > > > (5676) handling events ....
>
=== message truncated ===
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search
that gives answers, not web links.
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
More information about the Ace-users
mailing list