Sign in to follow this  
Evil Booger

How do I debug a bug that crashes the debugger?

Recommended Posts

Evil Booger    100
There is a problem with my program that causes the game to end with an error. I think it is an error with my ship class' destructors because I can run the game for as long as I want but when I end it, it crashes with an error that says some memory can't be read. Another reason why I think it is the destructor is because I the program is a console application and I use std::cout to print out a message whenever a ship is constructed or destructed and I get many constructor messages (sorry, too lazy to count them) and only 4 destructor messages. Even if I run the program with the debugger on(Visual C++ 2005 EE), when I exit, the program freezes and I have to ctr-alt-del it off my screen. Can someone point me in the direction of either what's wrong or what I can do to find out what's wrong? Thank you in advance.

Share this post


Link to post
Share on other sites
ukdeveloper    264
Please post your code, it'll hopefully help us see what the problem is.

Do you get as far as knowing what line the debugger reaches before it crashes, or does it just bail immediately as soon as you start the debug run? So it only crashes while the destructors are running?

The error you're describing suggests to me that you might be trying to access something which has already been deleted, or that should maybe be an assert error. It could be your debugger installation is hosed also.

Like I say, code please :-).

Share this post


Link to post
Share on other sites
Evil Booger    100
No, the program runs with the debugger fine until I exit the program. Then the program freezes. When the debugger is not running, there is just the "memory could not be read" error when I exit the program.

Share this post


Link to post
Share on other sites
DvDmanDT    1941
Do you run your game in fullscreen? If so, have you tried windowed mode? Have you tried multimon debugging? If debugging a fullscreen app and you find an error, the game will be stuck all over the screen untill you press space (break in the error dialog), shift-f5 (stop debugging).. Sometimes you'll have to tab into VS first as well. [edit]This will take you to the exakt place it's crashing as well.[/edit]

This is why you want multimon (as in two monitors where you have VS on one and the game on the other) or windowed debugging. It doesn't crash the debugger if this is what happends, it's just that the debugger freezes the app in fullscreen mode, and since the app is frozen, it's unable to minimize or leave fullscreen mode.

[Edited by - DvDmanDT on November 21, 2007 8:13:32 PM]

Share this post


Link to post
Share on other sites
pinacolada    834
I would try to find the exact place where it's crashing. It might take a little trial-and-error. Put breakpoints at the beginning of every destructor. Step over every line. If a function call causes the crash, restart and step through that function. Once you narrow it down, it will be a lot easier to figure out.

Share this post


Link to post
Share on other sites
brandonman    102
you could do it the old fashioned way like me, and read through the code >.<
wish I had a debugger with Dev C++, but I love it better then VC++ express.

Share this post


Link to post
Share on other sites
Spoonbender    1258
Quote:
Original post by brandonman
you could do it the old fashioned way like me, and read through the code >.<
wish I had a debugger with Dev C++, but I love it better then VC++ express.

If you don't like VC++, then use another IDE. There are plenty of free ones. But don't use the only one that was a piece of shit when it was developed, and has been abandoned for years now which makes it even shittier.
Or, here's an idea, try taking an hour or two to learn some of the vastly superior tools that are available for *free* so you don't have to waste your time on a crippled IDE like that.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this