I have a problem with a object of class A that has inherited a base class B with some pure virtual functions and i have a list of ptr objects A where i'm adding objects of type B. The problem is that sometimes when i try to access a virtual method from a object in the list the __vfptr table is corrupted. The objects are there in the list and are not deleted, i'll pot a pic with the autos. Does anybody has some idea of why this is happening? Thing is that if i start one or two instances of the application that error doesn't occur, but when i start more instances, it gives access violation reading at the third or the forth instance of the application, strange.
Or at least do you have any idea on how to track when that pointer to the vftable is changing? because that method gets called from a bunch of places and i can't possibly track all down with the debugger let alone that this error occurs randomly.
Thank you a lot
UPDATE 1
example here: http://rextester.com/live/MRHR24728
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x86
#include <iostream>
#include <stdint.h>
typedef struct
{
uint8_t name;
}sName;
class Base1
{
public:
virtual ~Base1(){};
virtual const sName* GetName() = 0;
};
class Base2 : public Base1
{
public:
Base2(){};
virtual ~Base2(){}
virtual const sName* GetName() { return &_name; }
private:
sName _name;
};
class Base3 : public Base2
{
public:
Base3(){}
virtual ~Base3(){}
};
class Object : public Base3
{
public:
Object(){}
~Object(){}
};
int main()
{
Object object;
Base1 *_logicalDevices[1] = {&object};
const sName * test = _logicalDevices[0]->GetName(); // this is where it breaks sometimes when trying to access the GetName method
std::cout<<test->name;
}