Intermittend pointer error.
Hey.
I'm getting pointer errors (windows error report, pointer error code) at random times, for seemingly no reason.
How can I diagnose where the problem is?
If this is in a program that you coded, run it in a debugger to pinpoint it. If it's in a third-party app, I couldn't say.
It's in mine.
Could you please explain how to debug? Because I've never done it in C++, i've actually got pretty far without it.
Could you please explain how to debug? Because I've never done it in C++, i've actually got pretty far without it.
Sure, I'll try to give a brief rundown.
Hopefully you're working in a visual IDE -- something like Visual Studio, Dev-C++, or Code::Blocks. If you are, try the "debug" command -- in Visual Studio, one of the most-used build menu options. It'll run your program, and when it crashes take you straight to the line of code that caused it to crash.
Visual Studio shows you a "stack trace" by default, which is the functions that your program went through to make it crash: this is very handy, because a lot of times it'll crash inside a library function and you have to get back out to one of your functions to see where it went wrong. In other IDEs, you might have to choose a menu option to see the stack trace once it's broken out into the debugger.
You can also check on the values of your variables in the debugger, and set "breakpoints", which is a place to pause your program and go back to the debugger to see what's going on.
If you aren't using a visual IDE, you'll have to download WinDBG or use a command-line debugger. This is a different can of worms that I won't open right now.
Hope that helps,
Twilight Dragon
Hopefully you're working in a visual IDE -- something like Visual Studio, Dev-C++, or Code::Blocks. If you are, try the "debug" command -- in Visual Studio, one of the most-used build menu options. It'll run your program, and when it crashes take you straight to the line of code that caused it to crash.
Visual Studio shows you a "stack trace" by default, which is the functions that your program went through to make it crash: this is very handy, because a lot of times it'll crash inside a library function and you have to get back out to one of your functions to see where it went wrong. In other IDEs, you might have to choose a menu option to see the stack trace once it's broken out into the debugger.
You can also check on the values of your variables in the debugger, and set "breakpoints", which is a place to pause your program and go back to the debugger to see what's going on.
If you aren't using a visual IDE, you'll have to download WinDBG or use a command-line debugger. This is a different can of worms that I won't open right now.
Hope that helps,
Twilight Dragon
I think I found out what it is.
Using the backtrace the "blue" line was room, but it couldn't actually take me to that, for some reason, and it had an odd line number 4304, and i don't have that many lines of code.
Anyway, I then noticed that the line before it was an action on a pointer.
Well it's a pointer error. Hmmmm.
This is the line:
sprite_index->draw(varx - view_x - 12, vary - view_y - 20, frame);
The variable frame is then put into a pointer (to an array), and I think effectively the error is something like a GM error "Array index out of bounds".
I think for some reason my programme has made the frame go to more than max_frames, and overstepped the end of the array.
Thanks for the help.
:)
Using the backtrace the "blue" line was room, but it couldn't actually take me to that, for some reason, and it had an odd line number 4304, and i don't have that many lines of code.
Anyway, I then noticed that the line before it was an action on a pointer.
Well it's a pointer error. Hmmmm.
This is the line:
sprite_index->draw(varx - view_x - 12, vary - view_y - 20, frame);
The variable frame is then put into a pointer (to an array), and I think effectively the error is something like a GM error "Array index out of bounds".
I think for some reason my programme has made the frame go to more than max_frames, and overstepped the end of the array.
Thanks for the help.
:)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement