[omniORB] VC++ 5: omniORB client: Destructor called twice after throw!!!
David Morgenlender
dmorgen@alum.mit.edu
Thu, 15 Oct 1998 02:03:13 GMT
I'm using omniORB 2.5 for both my CORBA client & server. The client is
implemented using Visual C++ 5.0, under Win95. I've encountered what =
appears to
be a VERY serious compiler bug in the client, as shown in the excerpts =
below
from the actual code.
The throw in _proxy_DvtDiagnostics::echoString() looks essentially like:
AppUnknownException ex;
throw ex;
This invokes the AppUnknownException copy constructor, passing the new =
object
via the throw. The destructor for this object is invoked as the stack =
frame is
unwound for the throw. The destructor for this object is invoked a 2nd =
time
when the catch(CORBA::UserException& ex) block in HandleException() =
exits.
Needless to say, calling the destructor twice results in all kinds of =
crashes!
I've confirmed the double destructor call. Is this really a VC++ bug? =
Any
suggestions for a workaround?
=09
=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
// From .IDL:
typedef struct tagExceptionInfo
{
string strFileName;
unsigned short usLineNum;
string strErrorMsg;
} ExceptionInfo;
exception AppUnknownException
{
ExceptionInfo excInfo;
};
// In the client:
void DoEchoString(
BSTR bstrIn,
BSTR __RPC_FAR *pbstrOut)
{
try
{
CORBA::String_var src;
CORBA::String_var dest;
// ...
// Invoke _proxy_DvtDiagnostics::echoString(),
// which correctly throws an AppUnknownException
// exception:
dest =3D =
INTERFACE_DVTDIAGNOSTICS->echoString(src);
// ...
}
catch(...)
{
HandleException();
}
}
void HandleException()
{
try
{
throw;
}
catch(CORBA::COMM_FAILURE&)
{
// ...
}
// more catches ...
// the following catches the AppUnknownException =
exception
catch(CORBA::UserException& ex)
{
//...
// falls through
}
// more catches ...
catch(...)
{
//...
}
}
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
Dave Morgenlender
e-mail: dmorgen@alum.mit.edu
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D