Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Unhandled exception in .....

Author
Message
Chiblue
15
Years of Service
User Offline
Joined: 6th Nov 2009
Location: NE PA, USA
Posted: 10th Aug 2010 19:42
I have been working on a project for a couple of weeks now, and I am plagued by the same problem...

Often when I run the project in debug I get the following message

Unhandled exception at 0x7c91b21a in game.exe: 0xC0000005: Access violation writing location 0x30303040.

Strange thing about this is I place a break point on the first executable line in the main.cpp and the error occurs before the break point...



In the code above I placed the break point on the "string logmsg;" line and the error occurs before the break point... I can run the project a couple of times then it will launch without a problem... and run fine... but then I will change the code, recompile, even do a clean and rebuild, but I still get the error... and again after a few attempts it will clear... I belive that something is not getting correctly generated in my projects which is causing the issue... or the memory is not being release from a previous run...

Any thoughts on what could be the issue, I am using VC++ 2008.
3d point in space
15
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 11th Aug 2010 00:41
oh strings you need to include iostram and using namespace std
and use \mt in opions.

Go through yourself at a wall.
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 11th Aug 2010 01:36
Just so you know, that line is not actually executable since it's just a variable declaration. In fact, it's likely that all variables before the first real line of code are having their constructors called (if a class), and perhaps there's something going wrong in one of them.

If you can't solve the problem, try removing parts of the code until it's as small as possible - basically try to recreate the problem with as little code as possible. Then it should be easy to see what is wrong.
DBAlex
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: United Kingdom
Posted: 11th Aug 2010 02:50
@Benjamin:

"Divide and conquer" right?

I use that technique a lot. Remove a portion of code to see if the error stops... then add it back in and remove specific lines etc. Works well.

For heavy duty memory debugging valgrind for Linux is great. VS has a memory debugger too I think.

Learning DarkGDK for phun.

AMD X2 7750, 2GB, 250GB HD, Nvidia 9600GT, XP SP3 & Ubuntu
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 11th Aug 2010 03:35
If you have a lot of static or global variables, c++ doesn't have a standard for initializing orders. Therefore, during one execution variable a gets initialized before variable b whereas the next execution could reverse the initialization order.

If your classes rely heavily on one another, this could be the source of your problems. Check to see if you have a lot of dependencies between classes. If you already know of such dependencies, check those first. Otherwise your back to the divide and conquer approach mentioned above.

Hope this helps,

JTK
Chiblue
15
Years of Service
User Offline
Joined: 6th Nov 2009
Location: NE PA, USA
Posted: 11th Aug 2010 16:44
Thanks, I have found that if I delete the exe and pdb files when this happens it seems to clear the problem, which to me indicates either an initialization error as mentioned or memory issue...

Will continue to fight the pain... lol

Login to post a reply

Server time is: 2024-11-19 20:33:50
Your offset time is: 2024-11-19 20:33:50