Jump to content
  • Advertisement
Sign in to follow this  
geekalert

How the heck do you debug THIS? [SOLVED]

This topic is 4491 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 built an application using OpenGL and OpenAL. And everything worked until I hit an error at the very end of the program. I got one of those "instruction could not write to memory 0x0000000" errors. And the problem is, the problem is OUTSIDE my source code!!!
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrev, LPSTR lpCmdLine, int nCmdShow)
{
	if(!ISound::Instance()->Initialize())
		return 0;
	if(!GameMain())
		return 0;
MessageBox(0,0,0,0); // <-- works.

	IWindow::Instance()->setHinstance(hInstance);
MessageBox(0,0,0,0); // <-- we've gotten this far...

int retCode = (int) IWindow::Instance()->Run().wParam;

MessageBox(0,0,0,0); // <-- still chugging along

	return retCode; // <-- somewhere out in the twilight zone, Windows blames MY PROGRAM for trying to access 0x000000
}


Any help is appreciated greatly. (And BTW it IS from my game engine, hence the abstraction you see.) [Edited by - geekalert on April 5, 2006 8:01:12 PM]

Share this post


Link to post
Share on other sites
Advertisement
actually, what's most likely happening is that as a class is going out of scope its destructor is trying to blam a null pointer or something like that.

I'd suggest checking the callstack at the time of the crash.

Share this post


Link to post
Share on other sites
Is it possibly caused by destruction of variables in that scope? Once you return from main, any global variables will be deleted so your code in destructors will be called.

Share this post


Link to post
Share on other sites
Well I used SoftICE to catch some messages and here is the output (includes time of crash)


Unload32 MOD=oledlg
Break due to UnhandledException NTSTATUS=STATUS_ACCESS_VIOLATION
MSR LastExceptionFromIp=804D1378
MSR LastExceptionToIp=804D138E
HardError D0000133 ; STATUS_UNHANDLED_EXCEPTION
Exit32 PID=46C MOD=OpenGLTest
Unload32 MOD=OpenGLTest
Unload32 MOD=OpenGL32
Unload32 MOD=GLU32
Unload32 MOD=ddraw
Unload32 MOD=dciman32
Unload32 MOD=wrap_oal
Unload32 MOD=dsound
Unload32 MOD=ksuser


Thanks again for all your help!

Share this post


Link to post
Share on other sites
While evaluating it with SoftICE is fine, I'm just going to ask because I'm curious. Are you using Visual Studio? If so it has a Call Stack view built right in. It will return the plain text function names of the last accessed code blocks along with line numbers if it can. I can't personally tell much from that SoftICE dump without any context. But I'm unfamiliar with your project and with SoftICE, so forgive my ignorance.

Share this post


Link to post
Share on other sites
YES! I have solved the problem, and I thank all those who replied. It was, in fact, a destructor error. I did not allocate an array properly, so that when it was destroyed, it caused an access error, because, well, the array wasn't allocated in the first place. So once again thank you baldurk and M2tM for all your help!

Share this post


Link to post
Share on other sites
No probs, glad you got it. I know those errors can be a pain.

Also, let me clarify (correct) my first post. I didn't mean a null pointer, I meant an invalid or hanging pointer... But you've got it anyway :)

Share this post


Link to post
Share on other sites
Yes, the call stack would be the most useful piece of information here. Once you can get a look at the call stack, you can see exactly what the offending code is and formulate how to go about fixing it. Get that stack trace!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!