Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Qoy

Access Violation Problem

This topic is 6697 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am currently getting as Access Violation from KERNEL32.DLL whenever I exit my game. It says: First-chance exception in Invasion2.exe (KERNEL32.DLL): 0xC0000005: Access Violation. This is happening AFTER WinMain returns, which is the weird part... People said before that it could be an error in one of my constructors, but right now I don't have any class objects being instantiated. Well, I do have a struct object (a Bitmap type). Actually, I do have one class being instantiated, for my level, but it doesn't define a constructor or destructor. I have Create and Destroy methods in it, and I don't think there's a problem with my destroy causing this, because then the AV would occur when I called Destroy... Does anyone have any suggestions? (sorry if this is not well written, it's very late.. ) ------------------------------ Jonathan Little invader@hushmail.com http://www.crosswinds.net/~uselessknowledge Edited by - Qoy on 4/18/00 3:40:22 AM Edited by - Qoy on 4/19/00 1:18:33 AM

Share this post


Link to post
Share on other sites
Advertisement
My only thought, is your program multi-threaded? You might have orphaned a thread and it decided to run amok.

Share this post


Link to post
Share on other sites
I''ve had 0xc0000005: Access Violation a couple of time before when I have run a program that tries to access the contence of an object pointer.

I''m sorry if this is no help.

Share this post


Link to post
Share on other sites
0xC0000005 Access violation is usually when the program is trying to access the contents of a NULL pointer.
>>>
and I don't think there's a problem with my destroy causing this, because then the AV would occur when I called Destroy...
>>>
Not necessarily. Objects are automatically deleted when they go out of scope.


ZoomBoy
Developing a 2D RPG with skills, weapons, and adventure.
See my character editor, Tile editor, diary, 3D Art resources at Check out my web-site


Edited by - ZoomBoy on 4/18/00 6:35:19 AM

Share this post


Link to post
Share on other sites
The debugger tells me that I get about 3 First Chance exceptions before my program even runs! I have no idea how to find out more about this, but since it doesn''t seem to affect my program''s execution, I''m doing nothing for now.

Share this post


Link to post
Share on other sites
Qoy: Your access violation is probably the result of an invalid pointer being accessed in a class destructor. I''ve also encountered this problem when I forgot to release a DirectDraw surface. Without being able to view your code, all we can do here is speculate.

Kylotan: If they occur before WinMain (or main) is called, then they are probably occuring in the constructor of a global variable. You might want to look into that. To prevent things like this, I always use pointers when I need globals and then I dynamically allocate them when the program starts.


Josh
http://www.jh-software.com

Share this post


Link to post
Share on other sites
OK, I seem to have found the origin of the problem.. First of all, as it turns out, the AV wasn''t being thrown after WinMain returned, it was just displaying it on the debug window after.. It turns out it''s being thrown when I release the DirectDraw object (very weird).

Here''s the code:


void ShutdownDirectDraw()
{
if(backBuffer)
backBuffer->Release();
if(primaryBuffer)
primaryBuffer->Release();
if(dDraw)
dDraw->Release();
} // end ShutdownDirectDraw


The AV is being shown on the line dDraw->Release();

dDraw is an LPDIRECTDRAW, and primaryBuffer and backBuffer are LPDIRECTDRAWSURFACEs.

Is there any other code I need to show for this? I can''t think of what could be the problem...

Share this post


Link to post
Share on other sites
OK, some more information..

I turned DDraw debugging up to the HIGHEST debug level I could, and this is what came out around the Access Violation:

DDraw:INFO:Resetting primary surface
DDraw:DeleteOneAttachment: 840ca664,840cb71c
DDraw:Leaving AddRef early to prevent recursion
DDraw:DeleteOneLink: 840cb71c,840ca664
DDraw:DeleteOneLink: 840ca664,840cb71c
DDraw:Leaving Release early to prevent recursion
DDraw:Unsubclassing window 000000c0
DDraw: ProcessSurfaceCleanup
DDraw:Leaving ProcessSurfaceCleanup
DDraw: ProcessPaletteCleanup, ppal=00000000
DDraw: ProcessClipperCleanup
DDraw:Not cleaning up clippers not owned by a driver object
DDraw: ProcessVideoPortCleanup
DDraw:Leaving ProcessVideoPortCleanup
DDraw: ProcessMotionCompCleanup
DDraw:Leaving ProcessMotionCompCleanup
DDraw:In RestoreDisplayMode
DDraw:Redrawing all windows
DDraw:DoneExclusiveMode
DDraw:Enabling error mode, hotkeys
DDraw:FREEING DRIVER OBJECT
DDraw:Calling HEL DestroyDriver
DDraw:0 surfaces allocated - 0 bytes total
DDraw:*********** DDHEL TIMING INFO ************
DDraw:******************************************
DDraw:Calling DestroyDriver
DDraw:Heap aliases reference count is zero: discarding aliases
DDraw:Driver is now FREE
First-chance exception in Invasion2.exe (KERNEL32.DLL): 0xC0000005: Access Violation.
-WinMain: Returning...
DDraw:====> ENTER: DLLMAIN(bab004c7): Process Detach fffa8269, tid=fffa52b5
DDraw:====> EXIT: DLLMAIN(bab004c7): Process Detach fffa8269


I hope that wasn't too much Anyway, just thought that might be of some help..

Thanks!

Edited by - Qoy on 4/18/00 3:54:44 PM

Share this post


Link to post
Share on other sites
Hmmm, this is a longshot, but it''s possible that if you didn''t initialize your buffers to NULL when you started they might not be NULL when you check them if you never did anything with them and it would try to release something that isn''t there.
Also I''ve gotten into trouble doing if (backbuffer) rather than if (backbuffer != NULL) type things though not with DDraw, you might want to do the second type just in case.

-fel

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!