Solving an access violation
by Daniel Buckmaster · in Torque Game Engine · 02/02/2008 (11:10 pm) · 3 replies
Sometimes I hate Torque. It's so fragile.
Anyway, I added some changed to ShapeBase's mounting system. Specifically, I added a bool to the mMount struct, and two extra methods to ShapeBase. Now when running Torque, I get an immediate crash with an access violation in Convex::unlink.
On a more general note - what is an access violation trying to tell me? I figured it was trying to access a private member, but that generates a compiler warning, doesn't it?
EDIT: I took all my changes out. Torque was fine. I added in a bool to ShapeBase::mMount (in the header file) and initialised it (in the cc file). Now I get the problem.
Anyway, I added some changed to ShapeBase's mounting system. Specifically, I added a bool to the mMount struct, and two extra methods to ShapeBase. Now when running Torque, I get an immediate crash with an access violation in Convex::unlink.
void Convex::unlink()
{
mPrev->mNext = mNext;
mNext->mPrev = mPrev; //<--Here
mPrev = mNext = this;
}How in the world can the two things be related?On a more general note - what is an access violation trying to tell me? I figured it was trying to access a private member, but that generates a compiler warning, doesn't it?
EDIT: I took all my changes out. Torque was fine. I added in a bool to ShapeBase::mMount (in the header file) and initialised it (in the cc file). Now I get the problem.
About the author
Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!
#2
If you still haven't nailed this, post the callstack so we can take a look. If you're in Visual Studio, it's usually down to your far left side. Looks to me like mNext is NULL or pointing to trash.
02/03/2008 (4:59 am)
Torque is not a closed API which you make calls to and hence you can break it if you make incorrect changes. Sure it's easier to blame something else when you make mistakes, but it won't help you grow as a developer.If you still haven't nailed this, post the callstack so we can take a look. If you're in Visual Studio, it's usually down to your far left side. Looks to me like mNext is NULL or pointing to trash.
#3
Thanks for the tips. I'll have a go at rebuilding. If that fails, I'll post the call stack.
EDIT: Rebuilding worked. Thanks for the help! I was seriously scratching my head over that - I made the same change to a different copy of Torque and it ran fine. Anyway, it's solved now. I'll have to remember that trick...
02/03/2008 (5:17 am)
Quote:Sure it's easier to blame something else when you make mistakes, but it won't help you grow as a developer.I know, I know. I just like to take my anger out ;P
Quote:Torque is not a closed API which you make calls to and hence you can break it if you make incorrect changes.Definately true - but I get annoyed when adding a bool to a struct is an 'incorrect change.'
Thanks for the tips. I'll have a go at rebuilding. If that fails, I'll post the call stack.
EDIT: Rebuilding worked. Thanks for the help! I was seriously scratching my head over that - I made the same change to a different copy of Torque and it ran fine. Anyway, it's solved now. I'll have to remember that trick...
Torque Owner Michael Bacon
Default Studio Name
Secondly, usually when things start going wonky like this for me a full clean and rebuild of the code base usually clears it right up. Don't ask me why but somehow the object files get out of sync and when you make changes not all of the object files get updated.
If a full clean & rebuild doesn't work I don't know what to say other than make sure that the variable you are adding is not already it a base class that you might be stomping on.