Skip to main content
gamedev.net
🔒 Locked

Access Violation

Started by Mantrid Apr 18, 2009 at 1:14 PM 5 replies 1.3k views
Original Post
Mantrid
Mantrid
Hi all I've an annoying issue here. My program runs fine when launched from within vis using either debug or release. outside of vis it hangs. when i use "attach to process" and select the program it's giving me an access violation whenever i try to allocate memory by the looks of it. the line it stops at right now is


	Cloud* temp;

	for (int i=0;i<(MAXCLOUDS-num);i++)
	{
		if (rand()%CLOUDPROB == 1)
			//generate new cloud
		{

>>DIES BECAUSE OF THIS 'NEW'>>   temp=new Cloud;
			temp->pos[y]=700;
			temp->pos[x]=rand()%800;

			temp->spriteID=rand()%16;

			temp->velocity=1+(rand()%6);

			clouds.push_back(temp);

		}


	}

}
after a few google searches i've downloaded winDbg but it's not very useful at all, shouting at me for possible exceptions from 3rd party apis long before it gets to the above function and doesn't let me skip past it, but then i've never used it before and might be doing it all wrong Corrupt heap seems to be a phrase cropping up a few times on google but other than that i'm pretty lost! Does anyone have any ideas about this? (before anyone points out, i know how crappy the random number generator is there but it serves its purpose for what i need in that function ;)
Black Knight
Black Knight
Sometimes when you corrupt the heap it doesn't crash instantly,instead it crashes somewhere else making you think the problem is there.
You are probably doing something wrong elsewhere.
Mantrid
Mantrid
that sounds like tonnes of fun i must say

is there any way of diagnosing it do you reckon? visual studio has no warnings on compile to give me a lead either
Black Knight
Black Knight
Try commenting out parts of code that you think are causing the problem one by one until the problem goes away.Check you arrays and bounds and see if you are doing anything nasty.
You can increase the warning level from the project settings to see other warnings during compile but I don't know if that will help you.
Mantrid
Mantrid
aye i increased the warnings to w4 and still getting nothing

ah well, i think it's gonna be a long coffee-filled night then

any ideas on what i'm looking for, typical things that can make a heap sad like not remembering it's anniversary or something?
Mantrid
Mantrid
all fixed up finally! cheers black knight. i'd rated you up before but i'll give you another boost tomorrow for sticking through it!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.