Program: 70864
Project: 70864
Buggy source:
private void doUpdateStructure(SparseBlockMatrix M,SparseBlockMatrix GT){
  int nactive=mySys.numActiveComponents();
  myNumActiveBodies=0;
  for (int ci=0; ci < nactive; ci++) {
    if (componentIsRigidBody(ci,M)) {
      myNumActiveBodies++;
    }
  }
  if (myNumActiveBodies > 0) {
    myBodyCompMap=new int[myNumActiveBodies];
    myCompBodyMap=new int[nactive];
    int bi=0;
    for (int ci=0; ci < nactive; ci++) {
      if (componentIsRigidBody(ci,M)) {
        myCompBodyMap[ci]=bi;
        myBodyCompMap[bi]=ci;
        bi++;
      }
 else {
        myCompBodyMap[ci]=-1;
      }
    }
    myMassSizes=new int[myNumActiveBodies];
    mySizeM=0;
    for (bi=0; bi < myNumActiveBodies; bi++) {
      int size=M.getBlockRowSize(myBodyCompMap[bi]);
      myMassSizes[bi]=size;
      mySizeM+=size;
    }
    myVelIdxs=new int[mySizeM];
    myMass=new SparseBlockMatrix(myMassSizes);
    int boff=0;
    for (bi=0; bi < myNumActiveBodies; bi++) {
      int ci=myBodyCompMap[bi];
      myMass.addBlock(bi,bi,M.getBlock(ci,ci).clone());
      int vidx=M.getBlockRowOffset(ci);
      int size=myMassSizes[bi];
      for (int k=0; k < size; k++) {
        myVelIdxs[boff + k]=vidx++;
      }
      boff+=size;
    }
    myVel=new VectorNd(mySizeM);
    myBf=new VectorNd(mySizeM);
    myGT=new SparseBlockMatrix(myMassSizes,new int[0]);
    myGTMap=createConstraintMatrix(myGT,GT,G_MATRIX);
    mySizeG=myGT.colSize();
    myLamIdxs=createConstraintIdxs(GT,myGTMap,mySizeG);
    myLam.setSize(mySizeG);
    myBg.setSize(mySizeG);
    myRg.setSize(mySizeG);
    mySolver.analyze(myMass,mySizeM,myGT,Matrix.SPD);
  }
}

Fixed version (ground truth):
private void doUpdateStructure(SparseBlockMatrix M,SparseBlockMatrix GT){
  int nactive=mySys.numActiveComponents();
  myNumActiveBodies=0;
  for (int ci=0; ci < nactive; ci++) {
    if (componentIsRigidBody(ci,M)) {
      myNumActiveBodies++;
    }
  }
  if (myNumActiveBodies > 0) {
    myBodyCompMap=new int[myNumActiveBodies];
    myCompBodyMap=new int[nactive];
    int bi=0;
    for (int ci=0; ci < nactive; ci++) {
      if (componentIsRigidBody(ci,M)) {
        myCompBodyMap[ci]=bi;
        myBodyCompMap[bi]=ci;
        bi++;
      }
 else {
        myCompBodyMap[ci]=-1;
      }
    }
    myMassSizes=new int[myNumActiveBodies];
    mySizeM=0;
    for (bi=0; bi < myNumActiveBodies; bi++) {
      int size=M.getBlockRowSize(myBodyCompMap[bi]);
      myMassSizes[bi]=size;
      mySizeM+=size;
    }
    myVelIdxs=new int[mySizeM];
    myMass=new SparseBlockMatrix(myMassSizes);
    int boff=0;
    for (bi=0; bi < myNumActiveBodies; bi++) {
      int ci=myBodyCompMap[bi];
      myMass.addBlock(bi,bi,M.getBlock(ci,ci).clone());
      int vidx=M.getBlockRowOffset(ci);
      int size=myMassSizes[bi];
      for (int k=0; k < size; k++) {
        myVelIdxs[boff + k]=vidx++;
      }
      boff+=size;
    }
    myVel=new VectorNd(mySizeM);
    myBf=new VectorNd(mySizeM);
    myGT=new SparseBlockMatrix(myMassSizes,new int[0]);
    myGTMap=createConstraintMatrix(myGT,GT,G_MATRIX);
    mySizeG=myGT.colSize();
    myLamIdxs=createConstraintIdxs(GT,myGTMap,mySizeG);
    myLam.setSize(mySizeG);
    myBg.setSize(mySizeG);
    myRg.setSize(mySizeG);
    mySolver.analyze(myMass,mySizeM,myGT,myRg,Matrix.SPD);
  }
}