[omniORB] Exceptions in constructors
David Hyde
davidh@cavendish.co.uk
Wed, 28 Nov 2001 11:10:45 -0000
Hi,
I'm using OmniORB 3.0.2 on Windows 2000 and VC++ 6.
A CORBA object that I am working on is written in such a way that the
constructor is liable to throw an exception in certain circumstances. (This
is legacy code that I avoid making fundamental architectural changes to
unless there is a good reason). I have converted this code from using a
proprietry ORB to use OmniORB and it used to work.
Now I am getting the situation where, if the exception in the constructor is
called (whether the object has been activated in the POA or not) the
application crashes when it is shut down.
The call stack is:
omniServant::_removeIdentity(omniLocalIdentity * 0x009d1920) line 198 + 3
bytes
omni::deactivateObject(const unsigned char * 0x009d1924, int 14) line 558
omniOrbPOA::deactivate_objects(omniLocalIdentity * 0x009d1920) line 2225 +
23 bytes
omniOrbPOA::do_destroy(unsigned char 1) line 1585
omniOrbPOA::destroy(unsigned char 1, unsigned char 1) line 526
omniOrbPOA::shutdown() line 1886
omniOrbORB::actual_shutdown() line 603
shutdown_thread_fn(void * 0x009a9598) line 636
omni_thread_wrapper(void * 0x009ca298) line 485 + 13 bytes
_threadstartex(void * 0x009c5ce0) line 212 + 13 bytes
KERNEL32! 77e837cd()
The failure is at:
void
omniServant::_removeIdentity(omniLocalIdentity* id)
{
ASSERT_OMNI_TRACEDMUTEX_HELD(*omni::internalLock, 1);
OMNIORB_ASSERT(id);
omniLocalIdentity** p = &pd_identities;
----> while( *p != id ) {
OMNIORB_ASSERT(*p);
p = (*p)->addrOfServantsNextIdentity();
}
*p = id->servantsNextIdentity();
*(id->addrOfServantsNextIdentity()) = 0;
}
I've a feeling that I am going to have to rewrite the code so that the
constructor doesn't throw an exception, but is this right??? Presumably the
ORB thinks that it has a reference to an object even though it hasn't been
activated in the POA and it is crashing when it is erroneously trying to
destroy it. What happens if an exception that is out of my control is
called while I'm in my constructor? Do I have to put try - catches in all
of my constructors?
Thanks very much
David
________________________________________________________
David Hyde
The Cavendish Organisation Ltd.
Admiral House
St. Leonards Rd Tel: +44 1753 836600
Windsor Fax: +44 1753 855021
Berkshire SL4 3BL
United Kingdom
email: davidh@cavendish.co.uk
http://www.cavendish.co.uk/
Confidential Information may be in this message. If you are not the intended
addressee please treat it as confidential, contact us immediately. Thank
you.
______________________________________________________________