Visual C++ Express Unhandled Excpetion

closed account (N36fSL3A)
Well I'm working on a little game called Kyden which is posted under Minecraftforums.com my code won't compile because a Unhandled Exception error. I'm really getting fed up with Visual C++ Right now, but I wont use anyhting else because I'm so used to it. Anyway this is my output box.:


'Kyden(Game).exe': Loaded 'C:\Documents and Settings\bc\My Documents\Visual Studio 2010\Projects\Kyden(Game)\Debug\Kyden(Game).exe', Symbols loaded.
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', Cannot find or open the PDB file
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', Cannot find or open the PDB file
'Kyden(Game).exe': Loaded 'C:\Documents and Settings\bc\My Documents\Visual Studio 2010\Projects\Kyden(Game)\Debug\SDL.dll', Binary was not built with debug information.
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', Cannot find or open the PDB file
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', Cannot find or open the PDB file
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\secur32.dll', Cannot find or open the PDB file
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', Cannot find or open the PDB file
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\user32.dll', Cannot find or open the PDB file
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', Cannot find or open the PDB file
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\winmm.dll', Cannot find or open the PDB file
'Kyden(Game).exe': Loaded 'C:\Documents and Settings\bc\My Documents\Visual Studio 2010\Projects\Kyden(Game)\Kyden(Game)\SDL_image.dll', Binary was not built with debug information.
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\msvcp100d.dll', Symbols loaded.
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\msvcr100d.dll', Symbols loaded.
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\msvcr100.dll', Cannot find or open the PDB file
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\imm32.dll', Cannot find or open the PDB file
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\imagehlp.dll', Cannot find or open the PDB file
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\ole32.dll', Cannot find or open the PDB file
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', Cannot find or open the PDB file
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\wininet.dll', Cannot find or open the PDB file
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\normaliz.dll', Cannot find or open the PDB file
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\urlmon.dll', Cannot find or open the PDB file
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll', Cannot find or open the PDB file
'Kyden(Game).exe': Loaded 'C:\WINDOWS\system32\iertutil.dll', Cannot find or open the PDB file
'Kyden(Game).exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.5512_x-ww_35d4ce83\comctl32.dll', Cannot find or open the PDB file
First-chance exception at 0x6812591f in Kyden(Game).exe: 0xC0000005: Access violation reading location 0x0000013c.
Unhandled exception at 0x6812591f in Kyden(Game).exe: 0xC0000005: Access violation reading location 0x0000013c.
First-chance exception at 0x6812591f in Kyden(Game).exe: 0xC0000005: Access violation reading location 0x0000013c.
Unhandled exception at 0x6812591f in Kyden(Game).exe: 0xC0000005: Access violation reading location 0x0000013c.
The program '[3132] Kyden(Game).exe: Native' has exited with code 0 (0x0).




I posted a picture of my problem on IMG Shack... here's the link:
http://img703.imageshack.us/img703/8119/unhandledexceptiont.png
Access violation is another way of saying that you tried to write to memory that you don't own. an example of this is:

1
2
3
int buffer[10];

int value = buffer[20];


notice that you are accessing the value at a position that isn't there. although this example is extreme, its usually more like this:

1
2
3
int buffer[10];

int value = buffer[10];


because the index into the array starts at position 0, 10 positions actually end on 9, and not 10. accessing position 10 creates an access violation.
closed account (N36fSL3A)
Now to go through the painstakingly hard process of searching through my 500+ lines of code...
Use the debugger to help find the issue. Set strategic break points.
closed account (N36fSL3A)
Any more examples? I not using Arrays...
closed account (N36fSL3A)
What?
Use the debugger and step through the program until you find what line it crashes on.
Also, you can get access violations from deleting pointers that you don't own, or deleting things that don't exist.

Typically, if you had a working compile of the program (i assume you tested bits and pieces along the way before you arrived at 500 lines, which only makes sense), it stands to reason that whatever is causing the access violation is whatever you put in last. I'd start looking there first.

EDIT: (spelling)
Last edited on
First run the program in debug mode if crash occurs find out the actual code where it is crashing by using application stack(used to trace current execution location).

It will help you defiantly am sure.
closed account (N36fSL3A)
Do you want me to click on the error line in the "output" box? Well if so, it doesn't work.
I think the recommended course of action was to run the program until you get your little pop up saying there is an unhandled exception, click on "Break", and inspect the call stack. In the image you linked it's in the upper right hand corner where it says "Stack Frame: " on the same toolbar as "Process: " and "Thread: ". In the stack frame you can see which functions were called. You want to navigate down the stack until you find the first function that is your code. That's where, in your code, the problem manifested. That should give you a reasonable place to start from.
closed account (N36fSL3A)
So it shows the function?
closed account (N36fSL3A)
BUMP
Do you got it?
closed account (N36fSL3A)
Got what?
closed account (3qX21hU5)
Lol try googling how to use the debugger in visual c++. This is a very powerful tool and you should learn it.
We've given you several suggestions as to how you can go about solving your issue. Whether or not you do anything with that information is all you man.
closed account (N36fSL3A)
I know how to use the debugger in VSC++. I'm not sure what you guys are trying to tell me. When the errors show in the output box, the debugger won't let me trace the line of the error, I'm trying to say this, but you guys aren't understanding what I'm trying to ask. I'm trying to do what cire is telling me.
EDIT: Spelling
Last edited on by Fredbill30
closed account (3qX21hU5)
Actually you don't understand what they are trying to tell you. If you knew how to use the debugger you would understand what they were trying to tell you. So again I suggest you look at a article or tutorial on the debugger here is some links


Visual studios - http://www.codeproject.com/Articles/79508/Mastering-Debugging-in-Visual-Studio-2010-A-Beginn all versions are basically the same.

Code::blocks - http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks might now be the best one but it tells some things
Last edited on
When the errors show in the output box, the debugger won't let me trace the line of the error, I'm trying to say this, but you guys arent understanding what I'm trying to ask.


All I saw after I posted was.. "Did you mean what you said" and "BUMP," neither of which conveys what you just said. Do you click on break when the pop up occurs? Do you then look at the stack trace? Do you look down from the top until you find the first function that is your code? Do you then double click on that so it brings up the last line of your code that was executed before the exception was thrown? Do you then inspect the variables in that function to see what their values are?

At what point is the process breaking down for you? Can you supply a little more information than "BUMP?"
Last edited on
closed account (N36fSL3A)
I typed bump so the topic didn't die off. I know what you are saying now, thanks. Once I do that and get it working, I'll hit solve on the topic.

EDIT: I don't use CodeBlocks btw.
Last edited on by Fredbill30
Topic archived. No new replies allowed.