Re: Possible causes for this error?
Posted: Sat Dec 08, 2012 10:06 pm
Oof. I'll have to take a look at this tomorrow or maybe Monday. Looks like there is a lot to digest.
Support forum for the Chipmunk Physics engine
https://chipmunk-physics.net/forum/
To be even more clear, it's on the cpBody->arbiterList but not in the cpSpace.cachedArbiters set or the cpSpace.arbiters array? Even after all the shapes have been removed for that body? The only way I can figure that is happening is if the bodies aren't getting woken up when removing the shapes. I don't see how that could happen unless there was something else wrong with the contact graph, but I don't see how that could happen without other terrible issues coming up constantly.To be crystal clear, the dangling pointer is in the arbiter and the arbiter is on the body's linked list but not in the space's arbiter hash set or arbiter list
Code: Select all
void cpArbiterValidate(cpArbiter *arb)
{
CP_VALIDATE_MAGIC_NUMBER(arb, 0xdeaddead);
cpBodyValidate(arb->body_a);
cpBodyValidate(arb->body_b);
}
void cpBodyValidate(cpBody *body)
{
CP_VALIDATE_MAGIC_NUMBER(body, 0xdeadbeef);
}
void cpSpaceValidate( cpSpace *space )
{
#ifdef CP_DETAILED_VALIDATION
if(space == NULL)
return;
cpArray *bodies = space->bodies;
cpArray *constraints = space->constraints;
cpArray *arbiters = space->arbiters;
cpHashSet *cachedArbiters = space->cachedArbiters;
for(int i=0; i<arbiters->num; i++){
cpArbiter *arb = (cpArbiter *)arbiters->arr[i];
cpArbiterValidate(arb);
}
for(int i=0; i<space->bodies->num; i++)
{
cpBody *TheBody = (cpBody*)space->bodies->arr[i];
cpBodyValidate(TheBody);
CP_BODY_FOREACH_ARBITER(TheBody, arb)
{
cpArbiterValidate(arb);
cpHashValue arbHashID = CP_HASH_PAIR((cpHashValue)arb->a, (cpHashValue)arb->b);
cpAssertSoft(cpArrayContains(arbiters, arb) || cpHashSetFind(space->cachedArbiters, arbHashID, arb) == arb, "Arbiter is on body but not in space?");
}
}
#endif
}
Code: Select all
void AnimatedPhysicsObject::OnRemoveFromPhysicsLayer()
{
assert(_Layer != NULL);
cpBody *TheBody = _Body;
cpSpace *TheSpace = _Layer->GetSpace();
cpSpaceValidate(TheSpace);
for(ShapeList::iterator it=_Shapes.begin(); it!=_Shapes.end(); ++it)
{
cpShape *TheShape = *it;
cpSpaceRemoveShape(TheSpace, TheShape);
}
cpSpaceValidate(TheSpace);
PhysicsObject::OnRemoveFromPhysicsLayer();
cpSpaceValidate(TheSpace);
}
Code: Select all
CP_BODY_FOREACH_ARBITER(body, arb){
cpBody *bodyA = arb->body_a;
if(body == bodyA || cpBodyIsStatic(bodyA)){
int numContacts = arb->numContacts;
cpContact *contacts = arb->contacts;
Code: Select all
cpArrayPush(space->sleepingComponents, body);
CP_BODY_FOREACH_COMPONENT(body, other) cpSpaceDeactivateBody(space, other);