Sign in to follow this  

Virtual functions

This topic is 3373 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am working with Visual Studio, in C++. I have an abstract class with a big list of virtual functions. And a class that inherits from this abstract class which provides its own definitions for these virtual functions. Recently I added 2 new virtual functions to this list, and everything seemed to work fine. Until it was run in release, which crashed the game and even trashed the stack (so probably some horrific memory override deal). This happens without the functions being called at all, and by commenting out the virtual function declarations (leaving in their counterparts in the inheriting class) everything seems to work fine. It seems to me that there must be some issue with the virtual lookup table, but I have no idea why something like that would be happening. Any help would be greatly appreciated. [Edited by - Ultraseamus on September 17, 2008 12:23:39 PM]

Share this post


Link to post
Share on other sites
There's a non-zero chance that what you are describing could occur due to different translation units seeing different versions of your base class. If this is the case, then cleaning and rebuilding your project may fix things.

Share this post


Link to post
Share on other sites
I think I figured it out, it is not exactly what you said, but close, and it got me on the right track. This program runs between multiple projects creating .dlls and .exes. It looks like this base class may have been updated in one but not the other. So each part of the program had a different idea of how large the virtual lookup table was. From here the idea of memory corruption happening seems reasonable, so while I am still testing my theory I feel confident that this was the problem. Thanks for your help.

Share this post


Link to post
Share on other sites

This topic is 3373 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this