[omniORB] RE: MSVC 5.0 bug: throw in ctor with virtual base class calls virtual base with wrong 'this'

Dietmar May dcmay@object-workshops.com
Sun, 2 May 1999 20:30:46 -0400


Well, it looks like Microsoft DOES fix bugs sometimes.

According to the updated MS Knowledge-base article Q168936, this problem 
has been fixed in MS VC++ 6.0. I guess I finally have a reason to upgrade 
:).

Dietmar

On Friday, September 04, 1998 1:02 AM, Dietmar May  wrote:
> Ran across this bug while debugging a program. Since it deals with 
calling the destructor of a virtual base class, which CORBA uses a little 
bit :-), thought it might be of interest to others.
>
> Essentially, if an exception is thrown by the constructor of a derived 
class (where apparently there is at least one level of intermediate 
derivation), the virtual base class' destructor is called with a 'this' 
pointer that is offset by 4 or more bytes. A second side effect, at least 
in the test program below, is that the virtual base class' destructor is 
called a second time with the correct this pointer! This, of course, is a 
problem if the virtual base class has any data to clean up, because 
integers may become pointers, and pointers may reference other objects...
>
> Sorry, there are no known work-arounds. Also, see MS Q168936 
Knowledge-base article.
>
> Regards,
> Dietmar May
>
> Software Architect
> Object Workshops, Inc.
> http://www.object-workshops.com
> dcmay@object-workshops.com
>