hi all..
I'm using bullet 2.69 and get an intermittent crash due to garbage data in pHandleEdge and pHandlePrev at line 699 in btAxisSweep3.h within function btAxisSweep3Internal<BP_FP_INT_TYPE>::sortMinDown():
// if previous edge is a maximum check the bounds and add an overlap if necessary
if (updateOverlaps && testOverlap(axis,pHandleEdge, pHandlePrev))
{
-->> m_pairCache->addOverlappingPair(pHandleEdge,pHandlePrev);
The specific cause of the crash is garbage (0xcdcd..) in m_clientObject, but to my untrained eyes the rest of the data looks suspect, too. Does anyone have any information that might help? Not critical as it's reproducible and can be avoided - but there may be other, closely related, squirrels running around down there. Probably related to something unusual that i'm doing as i'm quite new to the framework :>(.
thanks!
VanDelayyyy
BTW i'm quite impressed by what i've been able to do so far with Bullet!
bad collision pair in btAxisSweep3.h sortMinDown() - (ln699)
-
- Posts: 16
- Joined: Thu Jun 26, 2008 6:48 pm
-
- Posts: 16
- Joined: Thu Jun 26, 2008 6:48 pm
Re: bad collision pair in btAxisSweep3.h sortMinDown() - (ln699)
Not sure if this helps, but i am using cloth, rope, and rigid bodies. I also see the following in the console:
warning btCollisionDispatcher::needsCollision: static-static collision!
warning btCollisionDispatcher::needsCollision: static-static collision!
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: bad collision pair in btAxisSweep3.h sortMinDown() - (ln699)
It sounds like uninitialized data. How do you add objects to the dynamics world?
Are pHandleEdge and pHandlePrev garbage, or only the 'm_clientObject' member variable?
Do you have a callstack of the crash?
Thanks for the feedback,
Erwin
Are pHandleEdge and pHandlePrev garbage, or only the 'm_clientObject' member variable?
Do you have a callstack of the crash?
Thanks for the feedback,
Erwin
-
- Posts: 16
- Joined: Thu Jun 26, 2008 6:48 pm
Re: bad collision pair in btAxisSweep3.h sortMinDown() - (ln699)
They appear to be garbage.
I add objects to the world as follows:
rope and cloth
world->getSoftBodyArray().push_back(body);
world->btCollisionWorld::addCollisionObject(body,
collisionFilterGroup,
collisionFilterMask);
everything else (rigid bodies)
world->addCollisionObject(body,collisionFilterGroup,collisionFilterMask);
The problem does not occur until the simulation has been running for ~15 seconds. At time of failure there are a lot of constraints.
Call stack:
> DebugAllBulletDemos.exe!btAxisSweep3Internal<unsigned short>::sortMinDown(int axis=2, unsigned short edge=65534, btDispatcher * __formal=0x01d18038, bool updateOverlaps=true) Line 704 C++
DebugAllBulletDemos.exe!btAxisSweep3Internal<unsigned short>::updateHandle(unsigned short handle=15, const btVector3 & aabbMin={...}, const btVector3 & aabbMax={...}, btDispatcher * dispatcher=0x01d18038) Line 660 C++
DebugAllBulletDemos.exe!btAxisSweep3Internal<unsigned short>::setAabb(btBroadphaseProxy * proxy=0x07140230, const btVector3 & aabbMin={...}, const btVector3 & aabbMax={...}, btDispatcher * dispatcher=0x01d18038) Line 235 C++
DebugAllBulletDemos.exe!btCollisionWorld::updateAabbs() Line 136 C++
DebugAllBulletDemos.exe!btCollisionWorld::performDiscreteCollisionDetection() Line 168 C++
DebugAllBulletDemos.exe!btDiscreteDynamicsWorld::internalSingleStepSimulation(float timeStep=0.016666668) Line 378 C++
DebugAllBulletDemos.exe!btSoftRigidDynamicsWorld::internalSingleStepSimulation(float timeStep=0.016666668) Line 52 C++
DebugAllBulletDemos.exe!btDiscreteDynamicsWorld::stepSimulation(float timeStep=0.016666668, int maxSubSteps=1, float fixedTimeStep=0.016666668) Line 345 C++
DebugAllBulletDemos.exe!SoftDemo::clientMoveAndDisplay() Line 897 + 0x28 bytes C++
DebugAllBulletDemos.exe!SimulationLoop() Line 242 C++
GLUT32.DLL!100050c2()
[Frames below may be incorrect and/or missing, no symbols loaded for GLUT32.DLL]
GLUT32.DLL!10004939()
DebugAllBulletDemos.exe!main(int argc=1, char * * argv=0x01d16008) Line 434 C++
DebugAllBulletDemos.exe!__tmainCRTStartup() Line 586 + 0x19 bytes C
DebugAllBulletDemos.exe!mainCRTStartup() Line 403 C
hope it helps..
-----------------
I drive way too fast to worry about cholesterol.
Steven Wright
I add objects to the world as follows:
rope and cloth
world->getSoftBodyArray().push_back(body);
world->btCollisionWorld::addCollisionObject(body,
collisionFilterGroup,
collisionFilterMask);
everything else (rigid bodies)
world->addCollisionObject(body,collisionFilterGroup,collisionFilterMask);
The problem does not occur until the simulation has been running for ~15 seconds. At time of failure there are a lot of constraints.
Call stack:
> DebugAllBulletDemos.exe!btAxisSweep3Internal<unsigned short>::sortMinDown(int axis=2, unsigned short edge=65534, btDispatcher * __formal=0x01d18038, bool updateOverlaps=true) Line 704 C++
DebugAllBulletDemos.exe!btAxisSweep3Internal<unsigned short>::updateHandle(unsigned short handle=15, const btVector3 & aabbMin={...}, const btVector3 & aabbMax={...}, btDispatcher * dispatcher=0x01d18038) Line 660 C++
DebugAllBulletDemos.exe!btAxisSweep3Internal<unsigned short>::setAabb(btBroadphaseProxy * proxy=0x07140230, const btVector3 & aabbMin={...}, const btVector3 & aabbMax={...}, btDispatcher * dispatcher=0x01d18038) Line 235 C++
DebugAllBulletDemos.exe!btCollisionWorld::updateAabbs() Line 136 C++
DebugAllBulletDemos.exe!btCollisionWorld::performDiscreteCollisionDetection() Line 168 C++
DebugAllBulletDemos.exe!btDiscreteDynamicsWorld::internalSingleStepSimulation(float timeStep=0.016666668) Line 378 C++
DebugAllBulletDemos.exe!btSoftRigidDynamicsWorld::internalSingleStepSimulation(float timeStep=0.016666668) Line 52 C++
DebugAllBulletDemos.exe!btDiscreteDynamicsWorld::stepSimulation(float timeStep=0.016666668, int maxSubSteps=1, float fixedTimeStep=0.016666668) Line 345 C++
DebugAllBulletDemos.exe!SoftDemo::clientMoveAndDisplay() Line 897 + 0x28 bytes C++
DebugAllBulletDemos.exe!SimulationLoop() Line 242 C++
GLUT32.DLL!100050c2()
[Frames below may be incorrect and/or missing, no symbols loaded for GLUT32.DLL]
GLUT32.DLL!10004939()
DebugAllBulletDemos.exe!main(int argc=1, char * * argv=0x01d16008) Line 434 C++
DebugAllBulletDemos.exe!__tmainCRTStartup() Line 586 + 0x19 bytes C
DebugAllBulletDemos.exe!mainCRTStartup() Line 403 C
hope it helps..
-----------------
I drive way too fast to worry about cholesterol.
Steven Wright
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: bad collision pair in btAxisSweep3.h sortMinDown() - (ln699)
Can you help with a reproducing testcase?
Thanks a lot for the feedback,
Erwin
What is 'they' ? What are the values for pHandleEdge and pHandlePrev exactly, at the time of the crash?VanDelayyyy wrote:They appear to be garbage.
Is there a reason why you don't use 'btDiscreteDynamicsWorld::addRigidBody' for rigid bodies, and 'btSoftRigidDynamicsWorld::addSoftBody' for softbodies? Can you try that, and see if it helps?I add objects to the world as follows:
rope and cloth
world->getSoftBodyArray().push_back(body);
world->btCollisionWorld::addCollisionObject(body,
collisionFilterGroup,
collisionFilterMask);
everything else (rigid bodies)
world->addCollisionObject(body,collisionFilterGroup,collisionFilterMask);
Thanks a lot for the feedback,
Erwin
-
- Posts: 16
- Joined: Thu Jun 26, 2008 6:48 pm
Re: bad collision pair in btAxisSweep3.h sortMinDown() - (ln699)
I've attached the code i'm using. It's a modified standalone version of the original SoftDemo.cpp in the latest release. Regrettably i haven't had time to isolate the code which causes the problem. If i change the mass of one of the objects slightly the error will not occur - i think because a collision scenario is avoided.Can you help with a reproducing testcase?
I moved the contents of the addSoftBody and addRigidBody functions (as called by the rope functor and localCreateRigidBody() in the original SoftDemo.cpp, respectively) into equivalents that explicitly take the collision group and mask as arguments to see if that would help to resolve the problem.. it didn't, but i've kept them to provide flexibility in configuring collisions. Just to be sure i'm not wasting your time i switched back to the original methods (which, as you know, use default groups/masks) and this time it crashed in a different place. I put a define at the top of the sample code to switch between the two methods.Is there a reason why you don't use 'btDiscreteDynamicsWorld::addRigidBody' for rigid bodies, and 'btSoftRigidDynamicsWorld::addSoftBody' for softbodies? Can you try that, and see if it helps?
The stack for the new crash:
DebugAllBulletDemos.exe!btCollisionObject::mergesSimulationIslands() Line 114 + 0x3 bytes C++
> DebugAllBulletDemos.exe!btSimulationIslandManager::findUnions(btDispatcher * __formal=0x025a8080, btCollisionWorld * colWorld=0x072f0158) Line 61 + 0xe bytes C++
DebugAllBulletDemos.exe!btSimulationIslandManager::updateActivationState(btCollisionWorld * colWorld=0x072f0158, btDispatcher * dispatcher=0x025a8080) Line 98 C++
DebugAllBulletDemos.exe!btDiscreteDynamicsWorld::calculateSimulationIslands() Line 677 C++
DebugAllBulletDemos.exe!btDiscreteDynamicsWorld::internalSingleStepSimulation(float timeStep=0.016666668) Line 381 C++
DebugAllBulletDemos.exe!btSoftRigidDynamicsWorld::internalSingleStepSimulation(float timeStep=0.016666668) Line 52 C++
DebugAllBulletDemos.exe!btDiscreteDynamicsWorld::stepSimulation(float timeStep=0.016666668, int maxSubSteps=1, float fixedTimeStep=0.016666668) Line 345 C++
DebugAllBulletDemos.exe!SoftDemo::clientMoveAndDisplay() Line 809 + 0x28 bytes C++
DebugAllBulletDemos.exe!SimulationLoop() Line 242 C++
The cause seems to be similar. If i hop up to findUnions(), line 61 in CollisionDispatch\btSimulationIslandManager.cpp, it's pulling two m_clientObject objects from a pair:
btCollisionObject* colObj0 = (btCollisionObject*)collisionPair.m_pProxy0->m_clientObject;
btCollisionObject* colObj1 = (btCollisionObject*)collisionPair.m_pProxy1->m_clientObject;
both colObj0 and colObj1 are garbage. I'm hoping you can reproduce this on your side, but can provide more info if you need it.
Memory Validator does not catch any memory scribbles.. not that i was expecting any.
"they" is pHandleEdge and pHandlePrev and here is they values at time of crash:What is 'they' ? What are the values for pHandleEdge and pHandlePrev exactly, at the time of the crash?
pHandleEdge 0x073db9f0 {m_minEdges=0x073dba00 "???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? m_m btAxisSweep3Internal<unsigned short>::Handle *
- btBroadphaseProxy {m_clientObject=0xcdcdcdcd m_collisionFilterGroup=-12851 m_collisionFilterMask=-12851 ...} btBroadphaseProxy
m_clientObject 0xcdcdcdcd void *
m_collisionFilterGroup -12851 short
m_collisionFilterMask -12851 short
m_multiSapParentProxy 0xcdcdcdcd void *
m_uniqueId -842150451 int
- m_minEdges 0x073dba00 "???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? unsigned short [3]
[0] 52685 unsigned short
[1] 52685 unsigned short
[2] 52685 unsigned short
- m_maxEdges 0x073dba06 "???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? unsigned short [3]
[0] 52685 unsigned short
[1] 52685 unsigned short
[2] 52685 unsigned short
m_pad 52685 unsigned short
pHandlePrev 0x073db9f0 {m_minEdges=0x073dba00 "???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? m_m btAxisSweep3Internal<unsigned short>::Handle *
- btBroadphaseProxy {m_clientObject=0xcdcdcdcd m_collisionFilterGroup=-12851 m_collisionFilterMask=-12851 ...} btBroadphaseProxy
m_clientObject 0xcdcdcdcd void *
m_collisionFilterGroup -12851 short
m_collisionFilterMask -12851 short
m_multiSapParentProxy 0xcdcdcdcd void *
m_uniqueId -842150451 int
- m_minEdges 0x073dba00 "???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? unsigned short [3]
[0] 52685 unsigned short
[1] 52685 unsigned short
[2] 52685 unsigned short
- m_maxEdges 0x073dba06 "???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? unsigned short [3]
[0] 52685 unsigned short
[1] 52685 unsigned short
[2] 52685 unsigned short
m_pad 52685 unsigned short
Hope it helps..
------------
I don't care to belong to a club that accepts people like me as members.
G. Marx
You do not have the required permissions to view the files attached to this post.
-
- Posts: 16
- Joined: Thu Jun 26, 2008 6:48 pm
Re: bad collision pair in btAxisSweep3.h sortMinDown() - (ln699)
I went back to the original bullet release to make sure i was doing a 1:1 replacement of the original code and found that i had made two additions:
setCameraParams() - a convenience function to shift the initial camera position. Not needed.
btSoftBody::removeAnchor(btRigidBody* body) - reverses appendAnchor().
The removeAnchor() was added to allow flexible movement of the rope by appending an anchor to a movable rigid object, moving the rigid object, then removing the anchor. There doesn't appear to be a way to remove an anchor in the original bullet SDK.
void
btSoftBody::removeAnchor(btRigidBody* body)
{
for(int i=m_anchors.size()-1;i>=0;i--)
{
if(m_anchors.m_body == body)
{
m_anchors.swap(i, m_anchors.size()-1);
m_anchors.pop_back();
}
}
}
This implementation assumes that nothing else is dependent on the order of the anchors.. which seems optimistic. If it's not breaking now it would be easy to break this assumption in future. Commenting out calls to this method remove the crash.. but it may be simply because some collisions no longer occur.
I should probably handle rope manipulation differently - can you suggest a better way?
-------------
Dusting is a good example of the futility of trying to put things right. As soon as you dust, the fact of your next dusting has already been established.
G. Carlin
setCameraParams() - a convenience function to shift the initial camera position. Not needed.
btSoftBody::removeAnchor(btRigidBody* body) - reverses appendAnchor().
The removeAnchor() was added to allow flexible movement of the rope by appending an anchor to a movable rigid object, moving the rigid object, then removing the anchor. There doesn't appear to be a way to remove an anchor in the original bullet SDK.
void
btSoftBody::removeAnchor(btRigidBody* body)
{
for(int i=m_anchors.size()-1;i>=0;i--)
{
if(m_anchors.m_body == body)
{
m_anchors.swap(i, m_anchors.size()-1);
m_anchors.pop_back();
}
}
}
This implementation assumes that nothing else is dependent on the order of the anchors.. which seems optimistic. If it's not breaking now it would be easy to break this assumption in future. Commenting out calls to this method remove the crash.. but it may be simply because some collisions no longer occur.
I should probably handle rope manipulation differently - can you suggest a better way?
-------------
Dusting is a good example of the futility of trying to put things right. As soon as you dust, the fact of your next dusting has already been established.
G. Carlin
-
- Posts: 16
- Joined: Thu Jun 26, 2008 6:48 pm
Re: bad collision pair in btAxisSweep3.h sortMinDown() - (ln699)
I just went back to see if i could winnow down the example.
The following code will reproduce the problem.. note the commented line in removeAnchor() which resolves it (!):
Pending an approved way to manipulate soft body nodes (which i've probably missed), this seems to work for now if the line mentioned above is uncommented.
hope it helps..
VanDelayyyy
--------------
"Here, you can't do any harm with that."
Oliver Hardy
The following code will reproduce the problem.. note the commented line in removeAnchor() which resolves it (!):
Code: Select all
void
btSoftBody::removeAnchor(btRigidBody* body)
{
for(int i=m_anchors.size()-1;i>=0;i--)
{
if(m_anchors[i].m_body == body)
{
// the line below resolves the problem
// m_anchors[i].m_node->m_battach = 0;
m_anchors.swap(i, m_anchors.size()-1);
m_anchors.pop_back();
}
}
}
...
static void Init_Ropes(SoftDemo* pdemo)
{
float groundHalfExtent = 0.5f;
btCollisionShape* groundShape = new btBoxShape(btVector3(200,groundHalfExtent,200));
pdemo->m_collisionShapes.push_back(groundShape);
btTransform tr;
tr.setIdentity();
tr.setOrigin(btVector3(0,0,0));
btRigidBody* ground = pdemo->localCreateRigidBody(0.f,tr,groundShape);
btSoftBody* psb=btSoftBodyHelpers::CreateRope(
pdemo->m_softBodyWorldInfo,
btVector3(-10,10,0),
btVector3(10,10,0),
16,
0);
psb->m_cfg.piterations = 4;
//psb->m_materials[0]->m_kLST = 0.1+(1/(btScalar)(n-1))*0.9;
psb->setTotalMass(20);
pdemo->getSoftDynamicsWorld()->addSoftBody(psb);
// if this loop runs, only the first and last nodes collide with the ground..
// all of the middle nodes fall through.
for(int i=1;i<psb->m_nodes.size()-1;i++)
{
psb->appendAnchor(i, ground);
psb->removeAnchor(ground); // this is the Villain.
}
}
hope it helps..
VanDelayyyy
--------------
"Here, you can't do any harm with that."
Oliver Hardy
-
- Posts: 16
- Joined: Thu Jun 26, 2008 6:48 pm
Re: bad collision pair in btAxisSweep3.h sortMinDown() - (ln699)
I still got intermittent crashes and found time to winnow the sample code down. It appears the size of the rigid bodies attached to the cloth causes a problem. They are boxes with half extent of .01 (their original purpose was to tie the cloth to ropes and provide a handle for moving the cloth around - they were made small since they weren't visually important). If i move the cloth around in the sim eventually there is a crash due to a bad collision pair or the cloth and bodies fall through the trough rigid body. If the half extent is increased to 0.1 the problem appears to be resolved. Not a definitive solution since i'm not sure what the underlying cause is. In the process of narrowing it down the crash would often occur at different times in different places without any changes to the executable.
The code below causes a crash in btAxisSweep3.h (line 814) with this stack trace on my box with the holderHalfExtent set to 0.01f after tossing the cloth around with the mouse for a few seconds in the simulation window. If i increase the holderHalfExtent to 0.1f the crash does not occur after several minutes of tossing.
Anyway.. making this change has stabilized the sim for me. Hope it helps..
VanDelayyyy
-------
I installed a skylight in my apartment... the people who live above me are furious!
S. Wright
The code below causes a crash in btAxisSweep3.h (line 814) with this stack trace on my box with the holderHalfExtent set to 0.01f after tossing the cloth around with the mouse for a few seconds in the simulation window. If i increase the holderHalfExtent to 0.1f the crash does not occur after several minutes of tossing.
Code: Select all
> DebugAllBulletDemos.exe!btAxisSweep3Internal<unsigned short>::sortMaxDown(int axis=1, unsigned short edge=15, btDispatcher * dispatcher=0x027d6820, bool updateOverlaps=true) Line 814 + 0x6 bytes C++
DebugAllBulletDemos.exe!btAxisSweep3Internal<unsigned short>::updateHandle(unsigned short handle=4, const btVector3 & aabbMin={...}, const btVector3 & aabbMax={...}, btDispatcher * dispatcher=0x027d6820) Line 673 C++
DebugAllBulletDemos.exe!btAxisSweep3Internal<unsigned short>::setAabb(btBroadphaseProxy * proxy=0x074700d0, const btVector3 & aabbMin={...}, const btVector3 & aabbMax={...}, btDispatcher * dispatcher=0x027d6820) Line 235 C++
DebugAllBulletDemos.exe!btCollisionWorld::updateAabbs() Line 136 C++
DebugAllBulletDemos.exe!btCollisionWorld::performDiscreteCollisionDetection() Line 168 C++
DebugAllBulletDemos.exe!btDiscreteDynamicsWorld::internalSingleStepSimulation(float timeStep=0.016666668) Line 378 C++
DebugAllBulletDemos.exe!btSoftRigidDynamicsWorld::internalSingleStepSimulation(float timeStep=0.016666668) Line 52 C++
DebugAllBulletDemos.exe!btDiscreteDynamicsWorld::stepSimulation(float timeStep=0.016666668, int maxSubSteps=1, float fixedTimeStep=0.016666668) Line 345 C++
DebugAllBulletDemos.exe!SoftDemo::clientMoveAndDisplay() Line 146 + 0x28 bytes C++
DebugAllBulletDemos.exe!SimulationLoop() Line 242 C++
Code: Select all
static void Init_Ropes(SoftDemo* pdemo)
{
// trough
btCollisionShape* troughShape = new btBoxShape(btVector3(200,0.5f,200));
btTransform tr;
tr.setIdentity();
tr.setOrigin(btVector3(0,0,0));
btRigidBody* trough = pdemo->localCreateRigidBody(0.f,tr,troughShape);
const float holderMass = 100.0f;
float holderHalfExtent = 0.01f; // this appears to cause the crash. Increasing to 0.1 appears to avoid crash
float ht = 20.0f;
btTransform startTransform;
startTransform.setIdentity();
startTransform.setOrigin(btVector3(0,ht,0));
btRigidBody* holder0 = pdemo->localCreateRigidBody(
holderMass,
startTransform,
new btBoxShape(btVector3(holderHalfExtent,holderHalfExtent,holderHalfExtent)));
holder0->setCollisionFlags(btCollisionObject::CF_NO_CONTACT_RESPONSE);
btRigidBody* holder1 = pdemo->localCreateRigidBody(
holderMass,
startTransform,
new btBoxShape(btVector3(holderHalfExtent,holderHalfExtent,holderHalfExtent)));
holder1->setCollisionFlags(btCollisionObject::CF_NO_CONTACT_RESPONSE);
// pouch
const btScalar s=0.5;
const btScalar h=ht;
const int r=9;
btSoftBody* pouch = btSoftBodyHelpers::CreatePatch(
pdemo->m_softBodyWorldInfo,
btVector3(-s,h,-s), // corner 00
btVector3(+s,h,-s), // corner 10
btVector3(-s,h,+s), // corner 01
btVector3(+s,h,+s), // corner 11
r, // resx
r, // resy
0, // fixeds
false); // this causes crash or pouch falls through trough
//true); // have to fling the pouch around for a bit before crashing
pouch->m_cfg.piterations = 16;
pdemo->getSoftDynamicsWorld()->addSoftBody(pouch);
pouch->appendAnchor(0,holder0);
pouch->appendAnchor(pouch->m_nodes.size()-1,holder1);
pdemo->m_cutting=true; // ??
}
VanDelayyyy
-------
I installed a skylight in my apartment... the people who live above me are furious!
S. Wright