• Advertisement
Sign in to follow this  

Access Violation

This topic is 3233 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

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 ;)

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement