What could cause the VTable pointer to be 0xdddddddd in the Win32 debug build?

I am debugging the defect and narrowing it down to the vtable pointer for the 0xdddddddd object. This answer indicates that Win32 debugging assemblies usually install dead memory, or memory that has been deleted, to this special value.

Please note that the pointer itself looks correct, it is just a vtable 0xdddddddd .

Here is the code snippet:

 std::list<IMyObject*>::const_iterator it; for (it = myObjects.begin(); it != myObjects.end(); ++it) { IMyObject* pMyObject = *it; if (pMyObject == 0) continue; pMyObject->someMethod(); // Access violation } 

If I break the access violation string and look at pMyObject , I see that pMyObject itself has a valid address ( 0x08ede388 ), but the __vfptr member __vfptr invalid ( 0xdddddddd ).

Some notes:

  • This is a single-threaded application, so this is most likely not a race condition or a mutex problem.
  • There seems to be no obvious problems like deleting an object in the call stack before it is accessed.
  • This issue seems to play only on a Windows 2008 server, but not on Windows 7.

Any suggestions for further debugging?

+6
source share
3 answers

You use the pointer after it is released. Get the stack trace from the breakpoint in the destructor to see what deletes it. Or better yet, use shared_ptr <> to avoid the problem.

+7
source

If you run the program, place a breakpoint where you create the object. Then add a memory breakpoint. This will work if you overwrite or delete the memory. Well, or change it in any way.

Your object will look correct if the memory is not overwritten, but your vtable may not depend on the features of the compiler.

It can also be a size issue if you use inheritance. If you use any bucket memory or save objects with anything but a pointer.

0
source

If pMyObject-> someMethod () eventually completes the modification of the myObjects list, this will invalidate any of the current iterators.

Also, if the pointer data is already deleted, this will cause the same problem.

0
source

Source: https://habr.com/ru/post/886216/


All Articles