Report any bugs here and we'll post fixes
Moderators: Sascha Willems, Thomas
by SFCBias » Tue Jun 22, 2010 12:53 am
I'm using Ogre for rendering and decided to move away from OgreNewt since the support and updates are dieing on the Ogre Forums (besides me and kallaspriit). So I followed the tutorials on the wiki with a few changes to fit my code but when i call my own setWorldSize function it crashes during the Newton call to setWorldSize saying "Pure virtual function called" which usually has something to do with trying to access freed memory. Here is the code of my function
- Code: Select all
void PhysX::setWorldSize(const AxisAlignedBox& box)
{
Vector3 maxBox = box.getMaximum();
Vector3 minBox = box.getMinimum();
// add some extra padding
minBox.x -= 50.0f;
minBox.y -= 500.0f;
minBox.z -= 50.0f;
maxBox.x += 50.0f;
maxBox.y += 500.0f;
maxBox.z += 50.0f;
// set the new world size
NewtonSetWorldSize (mWorld, &minBox[0], &maxBox[0]);
}
Not sure what the problem is there.
Also when i comment out the call to my SetWorldSize function, it makes it to the renderLoop where it crashes at NewtonUpdate I've copied the backtrace but thats about all the information i have about it.
- Code: Select all
Elite,Inc [C/C++ Application]
gdb Debugger (6/22/10 12:49 AM) (Suspended)
Thread [1] (Suspended: Signal 'SIGSEGV' received. Description: Segmentation fault.)
14 dgWorld::CalculateContacts() 0x00007ffff64fe163
13 dgBroadPhaseCalculateContactsWorkerThread::ThreadExecute() 0x00007ffff6500a0e
12 dgBroadPhaseCollision::UpdateContacts() 0x00007ffff65065d9
11 dgWorld::Update() 0x00007ffff64c9ff4
10 Newton::UpdatePhysics() 0x00007ffff65dbf80
9 NewtonUpdate() 0x00007ffff65db079
8 Elite::PhysX::frameStarted() /home/sfcbias/workspace/Elite,Inc/source/PhysX.cpp:791 0x00000000004476b1
7 Ogre::Root::_fireFrameStarted() /home/sfcbias/ogre_src_v1-7-1/OgreMain/src/OgreRoot.cpp:804 0x00007ffff797b574
6 Ogre::Root::_fireFrameStarted() /home/sfcbias/ogre_src_v1-7-1/OgreMain/src/OgreRoot.cpp:876 0x00007ffff797c2c9
5 Ogre::Root::renderOneFrame() /home/sfcbias/ogre_src_v1-7-1/OgreMain/src/OgreRoot.cpp:963 0x00007ffff797c329
4 Ogre::Root::startRendering() /home/sfcbias/ogre_src_v1-7-1/OgreMain/src/OgreRoot.cpp:956 0x00007ffff797c39d
3 Elite::Application::startRenderLoop() /home/sfcbias/workspace/Elite,Inc/source/Main.cpp:144 0x000000000043da8a
2 Elite::Application::go() /home/sfcbias/workspace/Elite,Inc/source/Main.cpp:32 0x000000000043cdc1
1 main() /home/sfcbias/workspace/Elite,Inc/source/Main.cpp:164 0x000000000043daaf
Thread [2] (Suspended)
gdb (6/22/10 12:49 AM)
/home/sfcbias/workspace/Elite,Inc/Debug/Elite,Inc (6/22/10 12:49 AM)
-
SFCBias
-
- Posts: 54
- Joined: Tue Jun 22, 2010 12:40 am
- Location: Hephzibah,GA
by Stucuk » Tue Jun 22, 2010 1:10 am
Does Box and its getMaximum exist? You can get The virtual error message if you have a class which has virtual procedures which are not overridden by another class's version, I.E:
- Code: Select all
TWhatever = Class(TObject)
procedure Bla; Virtual; Abstract;
end;
TMyWhatever = Class(TWhatever)
procedure Bla; override;
end;
var
Wrong : TWhatever;
Right : TMyWhatever;
begin
Wrong.Bla; // Virtual Error Message
Right.Bla; // Works
end;
-
Stucuk
-
- Posts: 801
- Joined: Sat Mar 12, 2005 3:54 pm
- Location: Scotland
-
by SFCBias » Tue Jun 22, 2010 2:45 am
In the function , im passing by reference. So yes this does exist because box is the object im working with.
-
SFCBias
-
- Posts: 54
- Joined: Tue Jun 22, 2010 12:40 am
- Location: Hephzibah,GA
by Stucuk » Tue Jun 22, 2010 4:49 am
SFCBias wrote:In the function , im passing by reference.
Passing a pointer doesn't mean it exists. You still may get a Virtual error on a class which uses Virtual Procedures but was free'd or never setup(Thus the virtual procedure is invalid). Hence why i asked.
And have you used any virtual procedures in the Box's class or any class?
-
Stucuk
-
- Posts: 801
- Joined: Sat Mar 12, 2005 3:54 pm
- Location: Scotland
-
by SFCBias » Tue Jun 22, 2010 8:03 am
http://www.cplusplus.com/doc/tutorial/pointers/ A reference takes the address of another variable. And also i stepped through the function, and its fine.
*EDIT*: I ran the code again with SetWorldSize before i create any bodies and collisions and it works just fine, however i'd still like an answer to this problem.
-
SFCBias
-
- Posts: 54
- Joined: Tue Jun 22, 2010 12:40 am
- Location: Hephzibah,GA
by Stucuk » Tue Jun 22, 2010 9:45 am
SFCBias wrote:A reference takes the address of another variable.
Thats the definition of a pointer. A variable that holds the address of another memory location. That doesn't always mean it will be a memory location to a valid variable.
SFCBias wrote:*EDIT*: I ran the code again with SetWorldSize before i create any bodies and collisions and it works just fine, however i'd still like an answer to this problem.
Assuming its a bug in Newton it would be good if you could provide a demo exe that could reproduce the problem so that Julio could track it down easier.
-
Stucuk
-
- Posts: 801
- Joined: Sat Mar 12, 2005 3:54 pm
- Location: Scotland
-
by Julio Jerez » Tue Jun 22, 2010 10:33 am
are you saying that this?
- Code: Select all
void PhysX::setWorldSize(const AxisAlignedBox& box)
{
Vector3 maxBox = box.getMaximum();
Vector3 minBox = box.getMinimum();
// add some extra padding
minBox.x -= 50.0f;
minBox.y -= 500.0f;
minBox.z -= 50.0f;
maxBox.x += 50.0f;
maxBox.y += 500.0f;
maxBox.z += 50.0f;
// set the new world size
NewtonSetWorldSize (mWorld, &minBox[0], &maxBox[0]);
}
is craching in newton update
That function does not call newton update. I assume you are in linux 64, is are you sure you are not using a double dll?
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by SFCBias » Tue Jun 22, 2010 11:48 am
Julio Jerez wrote:are you saying that this?
- Code: Select all
void PhysX::setWorldSize(const AxisAlignedBox& box)
{
Vector3 maxBox = box.getMaximum();
Vector3 minBox = box.getMinimum();
// add some extra padding
minBox.x -= 50.0f;
minBox.y -= 500.0f;
minBox.z -= 50.0f;
maxBox.x += 50.0f;
maxBox.y += 500.0f;
maxBox.z += 50.0f;
// set the new world size
NewtonSetWorldSize (mWorld, &minBox[0], &maxBox[0]);
}
is craching in newton update
That function does not call newton update. I assume you are in linux 64, is are you sure you are not using a double dll?
No these are two separate problems. If i comment out the call to NewtonSetWorldSize in this function then when i get the the render loop it crashes at NewtonUpdate, I dont think that these are related problems. I just put them into one post to save making a second post.
-
SFCBias
-
- Posts: 54
- Joined: Tue Jun 22, 2010 12:40 am
- Location: Hephzibah,GA
by Julio Jerez » Tue Jun 22, 2010 1:25 pm
My guess is that something is wrong, you must be using a wrong library.
if you are in linux see how it is set up in the make file. they use the same functions and I beleiev it works.
are the SDK sample running?
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by SFCBias » Tue Jun 22, 2010 5:17 pm
Yes the samples are running just fine, i even recompiled them to be sure, so im almost certain its an error of mine but i can't quite catch it.
Last edited by
SFCBias on Tue Jun 22, 2010 5:34 pm, edited 2 times in total.
-
SFCBias
-
- Posts: 54
- Joined: Tue Jun 22, 2010 12:40 am
- Location: Hephzibah,GA
by Julio Jerez » Tue Jun 22, 2010 5:22 pm
is teh scene you are trying too complex, or does it happens with just one object.
also can you test in a different machine? if it crash then it means it is consistent and I might be able to find it.
I do not know what could be without a test,
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by SFCBias » Tue Jun 22, 2010 5:34 pm
I fixed the problem with NewtonSetWorldSize by calling it before I created any bodies or collisions. Now i still have to problem with NewonUpdate. This one i think has to do with memory as well since i get a segfault.
-
SFCBias
-
- Posts: 54
- Joined: Tue Jun 22, 2010 12:40 am
- Location: Hephzibah,GA
by Stucuk » Tue Jun 22, 2010 5:38 pm
Id bet its just one problem rather then two. Id check your code which sets up the bodies.
-
Stucuk
-
- Posts: 801
- Joined: Sat Mar 12, 2005 3:54 pm
- Location: Scotland
-
by SFCBias » Tue Jun 22, 2010 5:53 pm
Stucuk wrote:Id bet its just one problem rather then two. Id check your code which sets up the bodies.
check for what exactly , heres the code if it'll help
- Code: Select all
void PhysX::createRigidBody(NewtonWorld* world, SceneNode* sourceNode,
NewtonCollision* m_col, dFloat mass)
{
NewtonBody* body = NewtonCreateBody(mWorld, m_col);
float matrix[16];
if (sourceNode != NULL)
{
PhysXTools::QuatPosToMatrix(sourceNode->getOrientation(),
sourceNode->getPosition(), &matrix[0]);
}
else
{
SceneNode* sn = SceneHandler::getSingleton().getSceneManager(
"Octree1")->getRootSceneNode();
PhysXTools::QuatPosToMatrix(sn->getOrientation(),
sn->getPosition(), &matrix[0]);
}
NewtonBodySetMatrix(body, &matrix[0]);
Ogre::Vector3 inertia, offset;
NewtonConvexCollisionCalculateInertialMatrix(m_col, &inertia[0],
&offset[0]);
NewtonBodySetCentreOfMass(body, &offset[0]);
NewtonBodySetMassMatrix(body, mass, mass * inertia.x, mass * inertia.y,
mass * inertia.z);
NewtonBodySetForceAndTorqueCallback(body, globalForceCallback);
NewtonBodySetTransformCallback(body, globalTransformCallback);
NewtonBodySetUserData(body, sourceNode);
_matManager->assignMaterial(body, "WoodMaterial");
NewtonReleaseCollision(PhysX::getSingleton().getWorld(), m_col);
}
And the backtrace is in the first post
-
SFCBias
-
- Posts: 54
- Joined: Tue Jun 22, 2010 12:40 am
- Location: Hephzibah,GA
by Stucuk » Tue Jun 22, 2010 6:07 pm
For example seeing if globalForceCallback/globalTransformCallback are properly setup. If your using
Virtual's and your not overriding them you will get an error message about virtual stuff.
Basically id check everything that your sending to newton, no matter if its unlikely to be the culprit.
-
Stucuk
-
- Posts: 801
- Joined: Sat Mar 12, 2005 3:54 pm
- Location: Scotland
-
Return to Bugs and Fixes
Who is online
Users browsing this forum: No registered users and 7 guests