Hi there! I've got this problem, and I'm not sure how to fix it. I'm using c++ with sdl.
So when I run my game everything works fine.. but after awhile (2-3minutes) it suddenly breaks and tells me this:
Unhandled exception at 0x6f4c237b in Project Z.exe: 0xC0000005: Access violation reading location 0x00000000.
and when I look at the disassembly it tells me that this is the problem: 6F4C237B mov eax,dword ptr [edx]
I've been searching on google and havn't found anything. I am running my project with Visual studio 2008 and in release mode.
Thanks for any answer.
program breaks after awhile
Moderator: Coders of Rage
-
- Chaos Rift Demigod
- Posts: 991
- Joined: Thu Nov 13, 2008 3:16 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Amiga, PSOne, NDS
- Programming Language of Choice: C++
- Location: Sweden
Re: program breaks after awhile
Please post some relevant code to your problem.
-
- Respected Programmer
- Posts: 387
- Joined: Fri Dec 19, 2008 3:33 pm
- Location: Dallas
- Contact:
Re: program breaks after awhile
A 0c5 error indicates that you're trying to access memory that does not exist (was never allocated, or was already freed) whether it be attempting to delete memory that does not exist, trying to de-reference, call functions from...etc etc.
"...reading location 0x00000000" indicates that the invoker is null.
You're trying to free, de-reference, or invoke functions from memory that does not exist. Run in debug and see if the problem exists in a debug build. When it pops up saying whether you want to break, ignore, or what have you. You want to break. Look at the call stack window and see what ultimately leads up to the problem.
"...reading location 0x00000000" indicates that the invoker is null.
You're trying to free, de-reference, or invoke functions from memory that does not exist. Run in debug and see if the problem exists in a debug build. When it pops up saying whether you want to break, ignore, or what have you. You want to break. Look at the call stack window and see what ultimately leads up to the problem.
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: program breaks after awhile
If you're a bit confused by all this, don't worry, I usually still am.qpHalcy0n wrote:A 0c5 error indicates that you're trying to access memory that does not exist (was never allocated, or was already freed) whether it be attempting to delete memory that does not exist, trying to de-reference, call functions from...etc etc.
"...reading location 0x00000000" indicates that the invoker is null.
You're trying to free, de-reference, or invoke functions from memory that does not exist. Run in debug and see if the problem exists in a debug build. When it pops up saying whether you want to break, ignore, or what have you. You want to break. Look at the call stack window and see what ultimately leads up to the problem.
Basically what he's saying is that at some point one of your pointers is being used when it's NULL, and it's causing a segfault (also known as the error that is a a certified pain in the ass). Use a debugger (most good IDEs have them) and figure out where the error occurs. After that, it's just a fairly simple matter of making sure that none of your pointers are NULL when they aren't supposed to.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
Re: program breaks after awhile
Yes it's now fixed Stupid mistake not running in debug mode <.< The problem was abit strange though. Had to do with TTF_RenderText_Solid. I wanted to only display some text when clicking on a place, so when you were not clicking I did
surface = TTF_RenderText_Solid(font, " ", white) and somehow that didn't work so well. So I removed it and put the drawing function inside a if(clicked == true) ... Anyway thank you all for your help
surface = TTF_RenderText_Solid(font, " ", white) and somehow that didn't work so well. So I removed it and put the drawing function inside a if(clicked == true) ... Anyway thank you all for your help
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: program breaks after awhile
well the funny thing about the SDL_ttf functions is that most of them don't work if you pass them NULL pointers. In the docs it actually mentions a lot that passing most of the functions null pointers will cause it to segfault. That's an example of a lib not letting users be ignorant.sharpedge wrote:Yes it's now fixed Stupid mistake not running in debug mode <.< The problem was abit strange though. Had to do with TTF_RenderText_Solid. I wanted to only display some text when clicking on a place, so when you were not clicking I did
surface = TTF_RenderText_Solid(font, " ", white) and somehow that didn't work so well. So I removed it and put the drawing function inside a if(clicked == true) ... Anyway thank you all for your help
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
Re: program breaks after awhile
I'll keep that in mind thanks