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

Author
Message
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 1st Apr 2012 20:33
This problem occurs in the same place at a seemingly random times. Let me run this by some of you and let me know if there's a problem with my method:
I have a main menu function that resets the screen with dbSetDisplayMode(..). (I am using my desktop resolution in all cases)
I load my "main menu GUI".
I set my variables to use the GUI.
I do the dbSync loop and show/handle input for my GUI.
The first time I go into the game, it runs fine.... I click [New Game] and follow the normal method for creating a single player game.
This takes me to the main part of the game. At this point, the resolution is changed using dbSetDisplayMode(..) (again using default desktop res). I go through loading all the images, objects, and the in-game GUI. Up to this point, everything works as expected. I've used this method before, so no surprises.
Pressing [ESC], I bring up the in-game main menu and select [Exit To Main] button. This causes the program to unload all the images, objects, and the in-game GUI, and with a "goto" I jump back to the beginning of my code, taking me back to the main menu.
It show up fine, and sometimes I can go in and out multiple times before I get a problem (using EXACTLY the same method as before).
So I use debug.... I get the following error when it finally occurs:
Quote: "Unhandled exception at 0x76ef15de in Star Test.exe: 0xC0000005: Access violation reading location 0x160f4ff0."

I look at the variables on that line, and they are fine. They all show up as having the correct numbers and NOTHING has a NULL pointer..... What's going on? If you need the entire code, I'll post it. For now, here is a chunk. This is where it crashed:


The fastest code is the code never written.
Fallout
22
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 1st Apr 2012 22:56
Are you using any external libraries which could be running on a separate thread and potentially modifying those resources/references?

Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 1st Apr 2012 23:31
Possible.....

I'm using DarkShader. I also have Multisync included, but it even occurs when I take it out. I have also take out DarkShader to see if that's the culprit-- still crashes.....

My concern is the number of times I change the screen resolution. Most people won't go back and forth between the game and the main multiple times, but I want this to be bug-free. Sometimes it takes only one switch to kill it and sometimes it keeps going until I get tired of trying to crash it. If it was consistant, I could narrow it down to something.

The fastest code is the code never written.
Fallout
22
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 2nd Apr 2012 09:58
Hmmm. Yeah, that's a properly frustrating problem. You say there are no null pointers, but have you checked to see if the pointers are actually pointing to something that's ready?

If "MainGUI.ShowGUI();" works every time, MainGUI must be initialised, but could "MenuGroup[0]" not be ready? It may be a valid array reference, but is element 0 initialised?

Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 2nd Apr 2012 18:51
I thought of "MenuGroup[0]" being the issue, so I moved it down and I get the error on whatever is after "MainGUI.ShowGUI();"... Each of them are called multiple times in various ways without incident (until the error occurs). It happens only at mouseclick (clicking on one of the menu items). I thought it might be the click sound--nope.
I may have to restructure the way I do my menus. Right now, to get to the main menu, the screen is reset to the windows resolution. This is so that if you select a resolution that is not supported by your machine, you will always have the main menu set to windows res so you can fix it. I'm thinking of making a seperate interface that pops up a window for this. When you transition to the game, this window is no longer available until you restart the game. This will negate the need to continueously go between resolutions when going between game and main.....

The fastest code is the code never written.
Fallout
22
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 2nd Apr 2012 19:24 Edited at: 2nd Apr 2012 19:25
I think that's the right approach mate. If you're having strange problems, and you know it's a symptom of the dbSetDisplayMode command, then if you can eliminate using that command, you've solved the problem in a decent way.

It's a scary command to use anyway, knowing it's deleting a lot of stuff behind the scenes and resetting everything. You don't know how good a job of it it's actually doing. I know in Carnage when I reset the display mode, I created a few interesting bugs. So yeah, if you can not use it unless the user changes res, that's definite a good move.

WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 2nd Apr 2012 21:54
Yeah, been reading this and the only thing I can think of is, if it is happening 'after' resolution swapping then the GUI may be using a resource that been dumped by the resolution change and has not been tracked.

The only way to find it is to step through after a resolution change using the debugger.

Good luck...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 3rd Apr 2012 00:17
I'm going to try a two-pronged approach. Remove the rez swapping and remove the GUI swapping. If I didn't mention it earlier, I have to unload one GUI and load a different one between main and game. I allocate memory when I load and deallocate when I unload. That could also be the problem. I'll let you know if it works when I'm finished.

The fastest code is the code never written.
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 3rd Apr 2012 02:02
I think this is working.....
I made a simple "splash" menu 320x200 that only gives the option to change the game resolution, start the game, or exit.
I combined the MainGUI and the in-game GUI.
Now I only change resolution twice: the initial 320x200 and when you enter the game for the first time. I'm still going to do a butt-load of going between in-game and main to see if it crashes. Wish me luck!

I'll only post if I still have issues. Thanks everyone.

The fastest code is the code never written.
JIMAC
12
Years of Service
User Offline
Joined: 25th Nov 2011
Location: Scotland
Posted: 28th Apr 2012 00:26
It all in here

Login to post a reply

Server time is: 2024-11-19 02:31:29
Your offset time is: 2024-11-19 02:31:29