Physics Crash on Exit (Possible Cause??) Due to PhysicsObject.h - FIXED (THREED-1757)
by John "Mythic" Henry · in Torque 3D Professional · 04/26/2011 (1:12 pm) · 5 replies
Okay, been playing around with T3D now and never liked Exit Crashes.
Makes it hard to track down real bugs :)
So I dug into it and this is what I found:
in ../T3D/Physics/PhysicsObject.h
This Class is Based off of [WeakRefBase]
Now I haven't dug into the WeakRefPtr/StrongRefPtr before
but spotted very quickly that is was crashing during the Destruction
of the Ref to mPhysicsRep that is in anything that gets dealt with
by the Physics Engines..
Now other Objects/Classes that are based off the *RefBase's are not
Accessed usually by a simple [Class] *newVar but by [Weak/Strong]RefPtr<(class)> newVar
So I spent a little time mucking around and changed ALL references that
accessed the Class * to WeakRefPtr's (found an issue in the GMK 1.2.8) that
had a Class set as a (class) : public WeakRefBase but was using StrongRefPtr<(class)> newVar
That (converting to T3D GMK 1.2.8) got me on this track..
So far it's working...
All the mPhysicsRep Vars were changed from:
(example terrDat.h)
(example terrData.cpp)
So far so good, It stopped crashing and returns to the Menu
It completely exits without crashing.
Cant do any real proper testing for memory leaks or other issues yet
as I im still waiting for GMK 1.2.9, so at the moment my project is
a mess while I finish the port of 1.2.8. The SAFE_DELETE( mPhysicsRep )
was where the crash comes back to (Debugging), this seems to be part of the problem...
Cheers
Mythic
Makes it hard to track down real bugs :)
So I dug into it and this is what I found:
in ../T3D/Physics/PhysicsObject.h
///
class PhysicsObject : public WeakRefBase
{
public:
virtual ~PhysicsObject();This Class is Based off of [WeakRefBase]
Now I haven't dug into the WeakRefPtr/StrongRefPtr before
but spotted very quickly that is was crashing during the Destruction
of the Ref to mPhysicsRep that is in anything that gets dealt with
by the Physics Engines..
Now other Objects/Classes that are based off the *RefBase's are not
Accessed usually by a simple [Class] *newVar but by [Weak/Strong]RefPtr<(class)> newVar
So I spent a little time mucking around and changed ALL references that
accessed the Class * to WeakRefPtr's (found an issue in the GMK 1.2.8) that
had a Class set as a (class) : public WeakRefBase but was using StrongRefPtr<(class)> newVar
That (converting to T3D GMK 1.2.8) got me on this track..
So far it's working...
All the mPhysicsRep Vars were changed from:
(example terrDat.h)
//Mythic DEBUG //Crash fix on exit?? WeakRefPtr<PhysicsBody> mPhysicsRep; // PhysicsBody *mPhysicsRep;
(example terrData.cpp)
void TerrainBlock::onRemove()
{
removeFromScene();
//Mythic DEBUG START -- CrashOnExit
//SAFE_DELETE( mPhysicsRep );
if (mPhysicsRep) mPhysicsRep = NULL;
//Mythic DEBUG END -- CrashOnExitSo far so good, It stopped crashing and returns to the Menu
It completely exits without crashing.
Cant do any real proper testing for memory leaks or other issues yet
as I im still waiting for GMK 1.2.9, so at the moment my project is
a mess while I finish the port of 1.2.8. The SAFE_DELETE( mPhysicsRep )
was where the crash comes back to (Debugging), this seems to be part of the problem...
Cheers
Mythic
About the author
Recent Threads
#2
- Which version of T3D did you run across this? (B3, 1.1 Preview, etc)
- Repo steps to get the crash: I've been playing with the physics demo for about half an hour now and haven't been able to see the crash you're describing. The more info you can give us, the quicker we can address it.
- What platform/OS are you on?
04/28/2011 (6:02 pm)
@Mythic - I see that you're reporting this as a crash on exit, but would you mind providing us a bit more information?- Which version of T3D did you run across this? (B3, 1.1 Preview, etc)
- Repo steps to get the crash: I've been playing with the physics demo for about half an hour now and haven't been able to see the crash you're describing. The more info you can give us, the quicker we can address it.
- What platform/OS are you on?
#3
Hopefully Tom has that fixed in the version you're using.
//This caused the exit mission crash;
ESC KEY-> GUI:YES-> *CRASH*
ESC KEY-> Close window-> *CRASH*
//---------------------------------------------
If you're using the Physics demo..here's some more issues;
1. Projectiles disappear when firing at (ammunition) items.
2. The scene stalls some frames while (it appears that) physics objects are being loaded. Load the mission and simply turn around.
[there has to be a way to adjust this and smooth this out, it's terrible in it's current form.]
3. Stand at coordinate 0,0,0 and shoot any mountain top with your rocket launcher...watch how it hurts the player.
4. Exit the mission : crash
That is what I found in 30 seconds a few weeks ago.
I plan to thoroughly test soon and I will report these issues I stated here.
// Quad 3Ghz
// GTX460, latest and greatest X and drivers.
// Win7 64
04/28/2011 (6:11 pm)
Ray, 1.1 Preview1 is known to have exit crash issues(physics demo). Scott posted that in his 1.1 Preview1 announcement. Hopefully Tom has that fixed in the version you're using.
//This caused the exit mission crash;
ESC KEY-> GUI:YES-> *CRASH*
ESC KEY-> Close window-> *CRASH*
//---------------------------------------------
If you're using the Physics demo..here's some more issues;
1. Projectiles disappear when firing at (ammunition) items.
2. The scene stalls some frames while (it appears that) physics objects are being loaded. Load the mission and simply turn around.
[there has to be a way to adjust this and smooth this out, it's terrible in it's current form.]
3. Stand at coordinate 0,0,0 and shoot any mountain top with your rocket launcher...watch how it hurts the player.
4. Exit the mission : crash
That is what I found in 30 seconds a few weeks ago.
I plan to thoroughly test soon and I will report these issues I stated here.
// Quad 3Ghz
// GTX460, latest and greatest X and drivers.
// Win7 64
#4
should have given info... :)
T3D Preview (Latest)
UnModified Except to turn on PhysX in the Basic Physics demo
from the pro download not the demo download.
WinXP pro
4G ram, 4cpu(internal), 2.8Ghz Amd
Nvidia GeForce 9800GT
MSVC IDE 2008
That was with the Default Demo exe for Physics
Then tried a compile as well with same results.
Merged in GMK 1.2.8 then a few tweaks from 1.2.9/1.2.10
During the merge/convert and debug of 1.2.8 I
finally spotted where it was a crash when it was
deleting the last Player data during the
Safe_Delete(mPhysicsRep) and then it moved to a
Physics shape when I added those in from a GMK mission.
I started debuging further in when I spotted the
above I posted about the (Strong/Weak)RefPtr's.
At this time I no longer crash on exit, its now
currently during a call to _createShape() whenever
I've modified a DAE shape lol. Crashes on the trigger
call to load the (shape).cs file it created in the shape
editor :(
Mind you, at this point I've merged in both the
Mack/Fack and GMK kits and have the Mack working, but a few
problems with Physics still.
I have been strictly working with Bullet, but I think it's
time to try PhysX and see if some if this is coming from
there...
04/29/2011 (4:55 pm)
Sorry about that, I'd posted it in the Preview forum, but stillshould have given info... :)
T3D Preview (Latest)
UnModified Except to turn on PhysX in the Basic Physics demo
from the pro download not the demo download.
WinXP pro
4G ram, 4cpu(internal), 2.8Ghz Amd
Nvidia GeForce 9800GT
MSVC IDE 2008
That was with the Default Demo exe for Physics
Then tried a compile as well with same results.
Merged in GMK 1.2.8 then a few tweaks from 1.2.9/1.2.10
During the merge/convert and debug of 1.2.8 I
finally spotted where it was a crash when it was
deleting the last Player data during the
Safe_Delete(mPhysicsRep) and then it moved to a
Physics shape when I added those in from a GMK mission.
I started debuging further in when I spotted the
above I posted about the (Strong/Weak)RefPtr's.
At this time I no longer crash on exit, its now
currently during a call to _createShape() whenever
I've modified a DAE shape lol. Crashes on the trigger
call to load the (shape).cs file it created in the shape
editor :(
Mind you, at this point I've merged in both the
Mack/Fack and GMK kits and have the Mack working, but a few
problems with Physics still.
I have been strictly working with Bullet, but I think it's
time to try PhysX and see if some if this is coming from
there...
#5
It looks like an issue with PhysX. I've been using only Bullet
at first and had not even compiled in the PhysX. I resetup
to allow both Physics Engines and its crashing again with
PhysX active, but not with Bullet active.
Bullet Physics is working pretty well, found I have a bit of
trouble climbing a Ramp and a set of stairs I created for a
DTS building lol... I have to run and jump up the ramp or I
slide back down *chuckle*, and have similar problems with
the Stairs. The ramp has a simple one box collision.
The stairs have complex multiple collision boxes.
Do remember this is no longer a stock Preview with both
Mack/GMK and my own changes :)
04/30/2011 (1:45 pm)
Did some more work on this again...It looks like an issue with PhysX. I've been using only Bullet
at first and had not even compiled in the PhysX. I resetup
to allow both Physics Engines and its crashing again with
PhysX active, but not with Bullet active.
Bullet Physics is working pretty well, found I have a bit of
trouble climbing a Ramp and a set of stairs I created for a
DTS building lol... I have to run and jump up the ramp or I
slide back down *chuckle*, and have similar problems with
the Stairs. The ramp has a simple one box collision.
The stairs have complex multiple collision boxes.
Do remember this is no longer a stock Preview with both
Mack/GMK and my own changes :)
Associate David Montgomery-Blake
David MontgomeryBlake