[omniORB] exception when returning from main when using CORBA::Any

Luke Deller ldeller@xplantechnology.com
Wed, 23 Jan 2002 14:48:55 +1100


Hi Andren,

This is the mailing list for omniORB, not for TAO.  The people on the TAO=
=20
mailing list might be able to help you better, since you seem to be using=
 TAO.

TAO has a mailing list called:
   tao-users@cs.wustl.edu
which is archived at:
   http://groups.yahoo.com/group/tao-users/

To address your question.. I can't spot a problem with your code.  The=20
debug assertion is probably being hit in the destructor of gOrb.  Since=20
gOrb is declared as a global variable, its destructor will not be called =

until after you return from main.

Regards,
Luke.

Andr=E9n Clas wrote:

> PROBLEM DESCRIPTION:
> When the program reaches the return o statement in main(), Visual C++ f=
ails with a
> Debug Assertion Failed, CrtIsValidHeapPointer(pUserData) exception. Why=
 ?=20
> I Would really appreciate any suggestions.
>=20
> / Clas Andr=E9n, Sweden
>=20
> CODE::
>=20
> #include <iostream>
> #include <tao/corba.h>
>=20
> CORBA::Any* ReadSubject()
> {
>   CORBA::Any_var any =3D new CORBA::Any();
>  =20
>   const char* text =3D "Any";
>   any <<=3D text;
>=20
>   return any._retn();
> }
>=20
>=20
> CORBA::ORB_var gOrb;
>=20
> int main ( int argc, char* argv[] )
> {
>   try=20
>   {
>     gOrb =3D CORBA::ORB_init(argc, argv, "TAO");
>     =20
>     CORBA::Any_var store =3D ReadSubject();
>    =20
>     const char* result;
>=20
>     *store >>=3D result;
>=20
>     // EVERYTHING IS FINE HERE!!!
>     cout << "Result: " << result << endl;
>    =20
>     gOrb->destroy();
>   }
>   catch(CORBA::Exception&)=20
>   {
>     cerr << "Caught CORBA::Exception." << endl;
>   }
>   catch(...)=20
>   {
>     cerr << "Caught unknown exception." << endl;
>   }
>=20
>   // THIS FAILS!!!
>   return 0;
> }
> ]
>=20
>=20
>=20