[omniORB] omniORB conflicts with boost shared pointer shared_ptr

Luke luke.snow at diskstream.net
Mon Apr 17 19:20:00 BST 2006


Hi all,

I come across a strange exception when I am using boost shared pointer with omniORB.
I am trying to wrap the CORBA operations (creating orb, resolving remote object) into a class then my coleagues can use it without knowing any thing 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;
};

All the CORBA related operations (creating orb, finding NameService, creating reference of remote object) have been encapsulated into the constructor 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();
 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();
 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'

It looks like when I am using shared_ptr the shared pointer and omniORB all try to delete someone so they conflict with each other. But how? Why the first program can work well but the second would throw out exception 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/0cea5cf4/attachment.htm


More information about the omniORB-list mailing list