Program: 43048
Project: 43048
Buggy source:
/** 
 * do one iteration  return true if collapse was successfull  return false otherwise 
 */
protected boolean doIteration(){
  if (DEBUG) {
    printf("String_Node_Str");
  }
  getCandidateEdges(m_candidates);
  EdgeData bestCandidate=null;
  double minError=Double.MAX_VALUE;
  final int len=m_candidates.length;
  StructMixedData edges=m_mesh.getEdges();
  for (int i=0; i < len; i++) {
    EdgeData ed=m_candidates[i];
    if (m_edgeTester != null) {
      if (!m_edgeTester.canCollapse(ed.edge)) {
        continue;
      }
    }
    m_errorFunction.calculateError(ed);
    if (DEBUG)     printf("String_Node_Str",Edge.getUserData(edges,ed.edge),ed.errorValue);
    if (ed.errorValue < minError) {
      bestCandidate=ed;
      minError=ed.errorValue;
    }
  }
  if (bestCandidate == null || Edge.getHe(edges,bestCandidate.edge) == -1) {
    printf("String_Node_Str");
    return false;
  }
  EdgeData ed=bestCandidate;
  if (ed.errorValue > m_maxCollapseError) {
    m_ignoreCount++;
    return false;
  }
  m_errorFunction.calculateVertex(ed);
  if (DEBUG) {
    printf("String_Node_Str",Edge.getUserData(edges,bestCandidate.edge),ed.errorValue);
  }
  m_ecr.reset();
  m_ecp.maxEdgeLength2=m_maxEdgeLength2;
  if (DEBUG)   printf("String_Node_Str",m_collapseCount,m_mesh.getEdgeCount());
  if (!m_mesh.collapseEdge(ed.edge,ed.point,m_ecp,m_ecr)) {
    if (DEBUG)     printf("String_Node_Str");
switch (m_ecr.returnCode) {
case EdgeCollapseResult.FAILURE_SURFACE_PINCH:
      m_surfacePinchCount++;
    break;
case EdgeCollapseResult.FAILURE_FACE_FLIP:
  m_faceFlipCount++;
break;
case EdgeCollapseResult.FAILURE_LONG_EDGE:
m_longEdgeCount++;
break;
default :
System.out.println("String_Node_Str");
}
return false;
}
if (DEBUG) printf("String_Node_Str",m_mesh.getEdgeCount());
m_faceCount-=m_ecr.faceCount;
if (DEBUG) printf("String_Node_Str",m_ecr.insertedVertex);
int srcIdx=ed.vertexUserData;
int destIdx=Vertex.getUserData(m_mesh.getVertices(),m_ecr.insertedVertex);
Quadric.set(quadrics,srcIdx,quadrics,destIdx);
int[] edges_removed=m_ecr.removedEdges;
m_collapseCount+=edges_removed.length;
if (DEBUG) printf("String_Node_Str");
for (int i=0; i < edges_removed.length; i++) {
int index=Edge.getUserData(edges,edges_removed[i]);
if (DEBUG) printf("String_Node_Str",index);
m_edgeArray.set(index,-1);
}
if (ed.errorValue > m_maxError) {
m_maxError=ed.errorValue;
}
if (DEBUG) printf("String_Node_Str");
return true;
}

Fixed version (ground truth):
/** 
 * do one iteration  return true if collapse was successfull  return false otherwise 
 */
protected boolean doIteration(){
  if (DEBUG) {
    printf("String_Node_Str");
  }
  getCandidateEdges(m_candidates);
  EdgeData bestCandidate=null;
  double minError=Double.MAX_VALUE;
  final int len=m_candidates.length;
  StructMixedData edges=m_mesh.getEdges();
  for (int i=0; i < len; i++) {
    EdgeData ed=m_candidates[i];
    if (ed.edge == -1) {
      break;
    }
    if (m_edgeTester != null) {
      if (!m_edgeTester.canCollapse(ed.edge)) {
        continue;
      }
    }
    m_errorFunction.calculateError(ed);
    if (DEBUG)     printf("String_Node_Str",Edge.getUserData(edges,ed.edge),ed.errorValue);
    if (ed.errorValue < minError) {
      bestCandidate=ed;
      minError=ed.errorValue;
    }
  }
  if (bestCandidate == null || Edge.getHe(edges,bestCandidate.edge) == -1) {
    printf("String_Node_Str");
    return false;
  }
  EdgeData ed=bestCandidate;
  if (ed.errorValue > m_maxCollapseError) {
    m_ignoreCount++;
    return false;
  }
  m_errorFunction.calculateVertex(ed);
  if (DEBUG) {
    printf("String_Node_Str",Edge.getUserData(edges,bestCandidate.edge),ed.errorValue);
  }
  m_ecr.reset();
  m_ecp.maxEdgeLength2=m_maxEdgeLength2;
  if (DEBUG)   printf("String_Node_Str",m_collapseCount,m_mesh.getEdgeCount());
  if (!m_mesh.collapseEdge(ed.edge,ed.point,m_ecp,m_ecr)) {
    if (DEBUG)     printf("String_Node_Str");
switch (m_ecr.returnCode) {
case EdgeCollapseResult.FAILURE_SURFACE_PINCH:
      m_surfacePinchCount++;
    break;
case EdgeCollapseResult.FAILURE_FACE_FLIP:
  m_faceFlipCount++;
break;
case EdgeCollapseResult.FAILURE_LONG_EDGE:
m_longEdgeCount++;
break;
default :
System.out.println("String_Node_Str");
}
return false;
}
if (DEBUG) printf("String_Node_Str",m_mesh.getEdgeCount());
m_faceCount-=m_ecr.faceCount;
if (DEBUG) printf("String_Node_Str",m_ecr.insertedVertex);
int srcIdx=ed.vertexUserData;
int destIdx=Vertex.getUserData(m_mesh.getVertices(),m_ecr.insertedVertex);
Quadric.set(quadrics,srcIdx,quadrics,destIdx);
int[] edges_removed=m_ecr.removedEdges;
m_collapseCount+=edges_removed.length;
if (DEBUG) printf("String_Node_Str");
for (int i=0; i < edges_removed.length; i++) {
int index=Edge.getUserData(edges,edges_removed[i]);
if (DEBUG) printf("String_Node_Str",index);
m_edgeArray.set(index,-1);
}
if (ed.errorValue > m_maxError) {
m_maxError=ed.errorValue;
}
if (DEBUG) printf("String_Node_Str");
return true;
}