Pointer Error inside irrlicht

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Thomas_
Posts: 34
Joined: Mon May 08, 2006 1:51 am
Location: Corvallis/Eugene, Oregon

Pointer Error inside irrlicht

Post by Thomas_ »

So I have been getting a pointer error:

An Instruction at [HEX-address] referenced memory at [HEX-address]. The memory could not be "read".


I have tracked down the error and it always occurs during the method GetSceneManager()->drawAll();

I have been trying to figure out what could be the problem but have had no luck. What could be the problem. If I knew what could cause this I will be able to track it down better.

I dont know enough about how irrlicht works internally to figure this one out. Perhaps someone could give me some ideas.

Thanks!
Thomas_
Posts: 34
Joined: Mon May 08, 2006 1:51 am
Location: Corvallis/Eugene, Oregon

Post by Thomas_ »

I figure i must have somehow deleted an internal object or perhaps messed one up somehow... but I have been looking over my code with a fine tooth comb and havent found anything... I just dont see how this is possible!

Also, if it matters, the error doesn't always happen at the same time, usually around .5-5 seconds into the rendering. I am using an ortho view and 20-30 billboards.

Please tell me what you think!

Thanks...
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Make absolutely sure that you are not calling drop() on a pointer that you shouldn't be dropping.
Thomas_
Posts: 34
Joined: Mon May 08, 2006 1:51 am
Location: Corvallis/Eugene, Oregon

Post by Thomas_ »

Nope,

I never use drop...

just remove()

...
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

I would hope that you are calling drop() at least once. Are you using remove() from inside a function called by the scene manager? i.e. is the child list being iterated over when you call remove()?

There is a method on the scene manager for removing scene nodes at a safe time [see ISceneManager::addToDeletionQueue()]. Under some conditions you should be using it.

At the very least, you should be getting a stack dump that tells you where it is crashing. That would be a good hint to what the cause of the problem is. If you don't know how to deal with a stack you could post it here and I can probably help you.

Travis
Thomas_
Posts: 34
Joined: Mon May 08, 2006 1:51 am
Location: Corvallis/Eugene, Oregon

Post by Thomas_ »

sure, Ill try getting a stack dump. Ive used them a bit before, but i doubt it will help too much because I know basically where it crashes. Basically, My code runs, manipulates billboards, does a bunch of other stuff, maybe calls remove() on a few billboards it doesn't need and then calls my Draw() function shich uses gui->DrawAll() and manager->DrawAll() to render the scene.

I dont think I do anything while it does that. I never remove a billboard while its rendering.

Btw,

I can see it render for that first 1-4 seconds or so. It does work, it just crashes.

And its odd, because it WAS fully working before, and i had a bunch of 2d ships flying around in front of my ortho camera, but the ships wern't going where i wanted them to go. So i fixed some of my code so it would actually work, and now this problem. So, since the problem occurs inside the drawAll function, it must have to do with irrlicht, but somehow it probably existed before and my *fix* brought it into the open.
Thomas_
Posts: 34
Joined: Mon May 08, 2006 1:51 am
Location: Corvallis/Eugene, Oregon

Post by Thomas_ »

Wow,

This might be IRRelevant (bad pun) to my problem, but:

I ran it just now, in the hopes that it would crash and I could click debug and perhaps get a call stack, but it lasted almost 15 seconds before crashing, and I noticed that all the Ship::EnemyShip::BasicEnemy1 objects sought out their Goal* goal object which specifies where they should be heading, but once they reached it, they continued on the seek out the players ships goal, which at the time was the mouse curser, because I told it to use mouse control for this go.

So clearly I am doing something very wrong here already, even without the pointer error, which was stopping the program so early i could not see the problem.

So ill try to fix this problem and with any luck that will uncover the pointer problem, thanks....
Thomas_
Posts: 34
Joined: Mon May 08, 2006 1:51 am
Location: Corvallis/Eugene, Oregon

Post by Thomas_ »

Ok...

So this is a really odd bug,

I have written some testing flags around my code like this:

Code: Select all

    GetDriver()->beginScene(true, true, SColor(0,0,0,0));
    DrawStars();
    std::cout << "Flag 1" << std::endl;
    GetManager()->drawAll();
    std::cout << "Flag 2" << std::endl;
    GetGui()->drawAll();
    GetDriver()->endScene();
and When the program crashes, the last three lines of output are always:

...
Flag 1
Flag 2
Flag 1


So i presume that the error MUST occur inside "GetManager()->drawAll();"

However, when i just take that line out, like this:

Code: Select all

    GetDriver()->beginScene(true, true, SColor(0,0,0,0));
    DrawStars();
    //GetManager()->drawAll();
    GetGui()->drawAll();
    GetDriver()->endScene();
It never draws anything, but after a few seconds, I have the same error!

I am really confused by the problem, I have indications that there might be a pointer error inside my code, but before every access I have created a pointer check, and I really dont have any proof of what is happening!

The error seems to happen inside irrlicht, but still happens when I take that code away!

I would check the call stack but I dont know how to do this inside codeblocks...

Please offer any suggestions you have!

Thanks...

-Tom
Thomas_
Posts: 34
Joined: Mon May 08, 2006 1:51 am
Location: Corvallis/Eugene, Oregon

Post by Thomas_ »

Huh,

This time I ran the code:

Code: Select all

    GetDriver()->beginScene(true, true, SColor(0,0,0,0));
    DrawStars();
    std::cout << "Flag 1" << std::endl;
    //GetManager()->drawAll();
    std::cout << "Flag 2" << std::endl;
    GetGui()->drawAll();
    GetDriver()->endScene();
And the result was:

Flag1
Flag2
Flag1
Flag2
Has Goal Check: Goal Accessed, at address: 0xbaadfood


At first I thought this was pretty funny, but then i realized it might be special. If I remember right, baadfood indicates forbidden memory or something...

So im still not sure why it seems to crash inside irrlicht but I seem to be allocating or accessing memory at a bad address or something when dealing with my Goal* thegoal. I dont do much with it, I create it with new, I access it a few times, only when it is non 0, and then (again, only if its non 0) use delete on it. It not used inside irrlicht, it is just to keep track of a 2d position and generate vectors toward it.

Any ideas how this is happening?[/b][/code]
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

When using the debug CRT libraries 0xbaadfood is the value of uninitialized memory. It sounds like someone may be forgetting to initialize a member variable.

Travis
Thomas_
Posts: 34
Joined: Mon May 08, 2006 1:51 am
Location: Corvallis/Eugene, Oregon

Post by Thomas_ »

Hmm

Sounds about right, but all members of the class Goal are initialized in the constructor, and the instance of goal itself is initialized in the class Ship. The error seems to still be there...

I brought up a call stack and there was only one entry:

Nr: 0
Address: 7C901231
Function: ntdll!DbgUiConnectToDbg()
File: ntdll.dll
Post Reply