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

孤街醉人 提交于 2019-12-01 03:14:25

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

If you start the program, put a break point at where you create the object. Then add a memory break point. This will fire if you overwrite or delete the memory. Well, or change it in any way.

Your object will look correct if the memory isn't overwritten, but your vtable may not be depending on compiler specifics.

It could also be a size problem if you are using inheritance. If you are using any kind of bucket memory or storing objects by anything but the pointer.

If pMyObject->someMethod() ultimately ends up modifying the myObjects list it will invalidate any of the current iterators.

Additionally if the pointer data is already deleted this will trigger the same issue.

Okay wow, so I've been programming in c++ for years and never discovered this until now... There are actually magic numbers/magic debug values that you can lookup to see what's going on with your raw pointers while debugging!

See here: In Visual Studio C++, what are the memory allocation representations?

and here: https://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_debug_values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!