contactSolver.WarmStart problem

Hello,

I'm still debugging the cause, but I wanted to put a word out and see if anyone might be able to help. I have a ground body, it is static, and mass, invMass, a, invA, linearVelocity and angularVelocity are all zeroed. In b2Island::Solve:

Code:
    for(int jj = 0; jj < m_bodyCount; jj++) {
        b2Body* body = m_bodies[jj];
        if(body->GetUserData() == NULL && m_velocities[jj].v.x != 0.0) {
            int breakPoint = 0;
        }
    }

   if (step.warmStarting)
   {
      contactSolver.WarmStart();
   }
   
    for(int jj = 0; jj < m_bodyCount; jj++) {
        b2Body* body = m_bodies[jj];
        if(body->GetUserData() == NULL && m_velocities[jj].v.x != 0.0) {
            int breakPoint = 0;
        }
    }


Second breakpoint will occasionally hit, although some modification I made to the behavior of one of the game objects seems to be triggering it more frequently now. Somehow, collisions cause the ground body to move, every once in awhile. The ground body has a momentum and no drag, so it flies away from the rest of the level along with most of the map.
I've made progress. The problem occurs when a b2Island's contact's fixture's body's m_islandIndex points to the wrong body in the b2Island's m_bodies.

Code:
void b2Island::Solve(b2Profile* profile, const b2TimeStep& step, const b2Vec2& gravity, bool allowSleep)
{
    for(int jk = 0; jk < m_contactCount; jk++) {
        b2Contact *contact = m_contacts[jk];
       
        b2Body* bcA = contact->GetFixtureA()->GetBody();
        b2Body* bcB = contact->GetFixtureB()->GetBody();
       
        b2Body* biA = m_bodies[bcA->m_islandIndex];
        b2Body* biB = m_bodies[bcB->m_islandIndex];
       
        if(bcA != biA || bcB != biB) {
            int breakPoint = 0;
        }
    }


That breakpoint is hit before any other problems occur. I'll keep looking, but I'm getting closer. Erin, any thoughts?
The erroneous body in an island's contact list that points to the wrong m_bodies index is not in m_bodies at all, it was never island.Add'ed properly.
Found the root cause, not a Box2D error. I keep a set of local objects in the world's body list and update it according to what is near the player. I needed to clear each deactivating body's contacts. I can't use SetActive(false), because I use the fixure proxies to even determine the locality list. Problem is solved.
Glad you figured it out because I had no ideas. 🙂

Original thread: https://box2d.org/forum/viewtopic.php?t=8051