Finding a wild pointer in msvc 8?

uzik

22-03-2007 00:02:01

Can anyone suggest a good method of tracking down what looks like a buffer overrun/loose pointer bug?

I'm trying to use PLSM2.

In the frameEnded event I call pScenemanager->getPageManager()
to get the page manager:

PagingLandScapePageManager* pm = mSceneMgr->getPageManager();
unsigned int CurrentCameraPageX = pm->getCurrentCameraPageX();
unsigned int CurrentCameraPageZ = pm->getCurrentCameraPageZ();


It blows up because PagingLandScapePageManager::mCurrentcam
is 0xfeeefeee. I understand this is the value STL writes to invalid
locations. I assumed someplace the camera was part of a vector or
stl list and it's being invalidated, or perhaps just a pointer to a local
variable was passed and it went out of scope.

In the page manager mCurrentCam is set when ogre calls it. I set a break
point to make sure it's only called once. The code saves a good pointer
to the camera and it's not changed anywhere else in this class.

void PagingLandScapePageManager::updatePaging(PagingLandScapeCamera *cam)
{
mCurrentcam = cam;


Any suggestions how to find this bug?

uzik

22-03-2007 02:03:53

Well, to answer my own question, MSVC already includes a specialized breakpoint that will show when a value is changed.

http://www.flipcode.com/cgi-bin/fcarticles.cgi?show=63915

But... That's not the problem. Whenever I call the accessor functions
of the PLSM code the 'this' pointer is wrong...

inline PagingLandScapePageManager* getPageManager()