[omniORB] omniORB conflicts with boost shared pointer shared_ptr (V2)

Luke luke.snow at diskstream.net
Mon Apr 17 20:08:55 BST 2006


Hi all,

Sorry in the first letter the creation of shared pointer was wrong. Thanks Scott to point it out.
All the two test programs can run to the end and can return correct result. The only difference between them was at the end of second program an exception was thrown out.
Thanks again.

I come across a strange exception when I am using boost shared pointer with omniORB.
Iam trying to wrap the CORBA operations (creating orb, resolving remoteobject) into a class then my coleagues can use it without knowing anything about CORBA.
The interface of remote object is like this:
interface IA
{
 void fa();
 void fb();
}

The C++ class I defined is like this:
class CA
{
 public:

 CA();
 ~CA();
 void fa();
 void fb();

 private: 
 CORBA::ORB_var m_orb;
};

Allthe CORBA related operations (creating orb, finding NameService,creating reference of remote object) have been encapsulated into theconstructor CA::CA().
In the destructor CA::~CA() I shutdown the orb. It is like this: { m_orb->shutdown(true); m_orb->destroy(); }

Then I have two test program all use boost shared pointer and one can work well one can not.
The one can work well:

int main(int argc, char** argv)
{
 {
 CA ca();
 ca.fa();
 ca.fb();
 }

 {
 Ca* pa= new CA();
 pa->fa();
 pa->fb();
 delete pa;
 }

 {
shared_ptr<CA> sa(new CA);
 sa->fa();
 sa->fb();
 }

}

The one can not work well:

int main(int argc, char** argv)
{

 CA ca();
 ca.fa();
 ca.fb();


 Ca* pa= new CA();
 pa->fa();
 pa->fb();
 delete pa;


 {
shared_ptr<CA> sa(new CA);
 sa->fa();
 sa->fb();
 }

}
The omniORB reports this:
omniORB: throw OBJECT_NOT_EXIST from corbaOrb.cc:842 (NO,OBJECT_NOT_EXIST_NoMatch)
terminate called after throwing an instance of 'CORBA::OBJECT_NOT_EXIST'

Itlooks like when I am using shared_ptr the shared pointer and omniORBall try to delete someone so they conflict with each other. But how?Why the first program can work well but the second would throw outexception all the time?

Thanks a lot for your help.

Regards


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20060417/5cac60f3/attachment.htm


More information about the omniORB-list mailing list