473,321 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Serious bug in VC++.NET 2003 -- invalid v-table

I've found what seems to be a very serious (although obscure) bug in
VC++.NET 2003 when using Loki's class hierarchy-generation facilities.
The compiler seems to generate an invalid v-table for my class, which
causes virtual method calls to dispatch incorrectly, causing run-time
errors and crashes. The problem seems to occur because the compiler
doesn't catch the case where I give a template method the same name as
a virtual method defined elsewhere in the same hierarchy.

I have a repro ready to go. It's about as simple as I can make it, but
familiarity with Loki's GenScatterHierarchy and GenLinearHierarchy is
essential to understanding what's going on. Loki is required for the
repro (http://sourceforge.net/projects/loki-lib). If anyone is
interested in the repro (MSVC++ team, take note!), please e-mail me
at:

c_kernel at hotmail dot com

I couldn't find a KB article about this problem, so I assume I'm the
first to find it (lucky me). Although there seems to be a simple
workaround for this instance of the bug, its symptoms are very, very
serious. I urge everyone to watch out for it, and I urge those
responsible to get a fix out ASAP.

Bruce Johnston
Simba Technologies Inc.
www.simba.com
Nov 16 '05 #1
5 1293
An update: I've created a (somewhat) simpler repro that doesn't rely
on Loki. If anyone is interested, please e-mail me.
Nov 16 '05 #2
Colonel Kernel <c_******@hotmail.com> wrote:
An update: I've created a (somewhat) simpler repro that doesn't rely
on Loki. If anyone is interested, please e-mail me.


could you post simplest repre code here ? I'm just curious (I know MC++D
book).
B.

Nov 16 '05 #3
Colonel Kernel wrote:
An update: I've created a (somewhat) simpler repro that doesn't rely
on Loki. If anyone is interested, please e-mail me.


You can post the code here, or email it to me (remove the obviously
removeable parts of my email address). If it repros for me and looks like a
bug (not some obscure undefined behavior) I'll get it into the bug pipeline.

-cd
Nov 16 '05 #4
I simplified the repro even further. Now it's actually small enough to post.
:)

I've already been in contact with the VC++ team via e-mail since yesterday,
so they have this repro already. But here it is anyway, for those who are
curious:

---------------------------------------------------
#include <iostream>
// All this code is an "unrolling" of Loki's class-hierarchy generation
// techniques. I've removed as much template stuff as possible in order to
// isolate the bug as much as possible. Keep in mind that this a repro, not
a
// motivating example. The pattern of inheritance and template instantiation
// that is in this repro occurs somewhat frequently when generating class
// hierarchies using Loki.
// Uncomment this to reproduce the bug.
//#define SHOWBUG
class Interface
{
public:

// This level of delegation is required in order to reproduce the bug.
// main() can't just call doFoo directly, or the bug won't occur.
void foo( int i )
{
this->doFoo( i ) ;
}

protected:

virtual void doFoo( int i ) = 0 ;

virtual ~Interface() {}
} ;

// This class must take its base class as a template parameter in order for
// the bug to occur.
template <class IFace>
class IntermediateBase : public IFace
{
protected:

// This operation needs to be in this intermediate base class in order
// for the bug to occur. Also, it needs to be a template. I think the
// fact that it is a template method with the same name as a virtual
// method in a class hierarchy that is established via template
paramters
// (see IFace above) is the key circumstance of this bug.
template <class T>
#ifndef SHOWBUG
void doFooImpl( T t )
#else
void doFoo( T t )
#endif
{
std::cout << typeid( t ).name() << ": " << t << std::endl ;
}
} ;

class Implementation : public IntermediateBase<Interface>
{
typedef IntermediateBase<Interface> Base ;

protected:

void doFoo( int i )
{
#ifndef SHOWBUG
this->Base::doFooImpl<int>( i ) ;
#else
this->Base::doFoo<int>( i ) ;
#endif
}
} ;

int main()
{
Implementation impl ;

impl.foo( 1 ) ;

return 0 ;
}

Nov 16 '05 #5
Colonel Kernel wrote:
I simplified the repro even further. Now it's actually small enough
to post. :)

I've already been in contact with the VC++ team via e-mail since
yesterday, so they have this repro already. But here it is anyway,
for those who are curious:


Thanks for sharing, and for taking the time to narrow down a concise repro
case - it really makes a difference in getting bugs like this fixed.

-cd
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ...
0
by: Severino | last post by:
Hi all, we have developed a .NET component for use inside Windows Forms: this component has been written using VC++.NET (2003) and is working perfectly when inserted inside VC#.NET or VB.NET...
0
by: Severino | last post by:
Hi all, we have developed a .NET component for use inside Windows Forms: this component has been written using VC++.NET (2003) and is working perfectly when inserted inside VC#.NET or VB.NET...
2
by: Qiao Yun | last post by:
I used vc++.net (visual studio .net ) to open a project which can work well in vc++6.0. I succeeded in compiling the project in vc++.net in release mode . But when I tried to compile the project...
27
by: Jason Doucette | last post by:
I'm getting an assertion fire from a list iterator being checked against NULL. This did not occur in VC++ 2003 (v7.1). Are there changes that have been made to the STL between these versions that...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.