Program: 70677
Project: 70677
Buggy source:
@Override public void drawTriangles(RenderObject robj,int gidx,RenderInstances rinst){
  boolean selecting=isSelecting();
  boolean hasColors=((robj.hasColors() || rinst.hasColors()) && hasVertexColoring());
  boolean useColors=hasColors && !selecting && (myActiveColor == ActiveColor.DEFAULT);
  boolean useHSV=isHSVColorInterpolationEnabled();
  maybeUpdateState(gl);
  int savedShading=0;
  if (useColors) {
    savedShading=enableVertexColoring(useHSV);
  }
  boolean useDisplayList=(!selecting || !hasColors) && (!robj.isTransient());
  GL2VersionedObject gvo=null;
  boolean compile=true;
  if (useDisplayList) {
    RenderInstancesKey key=new RenderInstancesKey(rinst.getIdentifier(),robj.getIdentifier(),DrawType.TRIANGLES,gidx);
    RenderInstancesFingerprint fingerprint=new RenderInstancesFingerprint(rinst.getVersionInfo(),robj.getVersionInfo());
    gvo=myGLResources.getVersionedObject(key);
    if (gvo == null || gvo.disposeInvalid(gl)) {
      gvo=myGLResources.allocateVersionedObject(gl,key,fingerprint);
      compile=true;
    }
 else {
      compile=!(gvo.compareExchangeFingerPrint(fingerprint));
    }
  }
  if (compile) {
    if (gvo != null) {
      gvo.beginCompile(gl);
    }
    robj.readLock();
    rinst.readLock();
    int ninstances=rinst.numInstances();
    int[] instances=rinst.getInstances();
    int ipos=rinst.getInstanceTypeOffset();
    int tpos=rinst.getInstanceTransformOffset();
    int cpos=rinst.getInstanceColorOffset();
    int spos=rinst.getInstanceScaleOffset();
    int stride=rinst.getInstanceStride();
    InstanceTransformType[] type=RenderInstances.getTransformTypes();
    boolean hasInstanceScales=rinst.hasScales();
    boolean hasInstanceColors=useColors && rinst.hasColors();
    gl.glPushMatrix();
    for (int i=0; i < ninstances; ++i) {
      int iidx=instances[ipos];
      int tidx=instances[tpos];
      int cidx=instances[cpos];
      int sidx=instances[spos];
switch (type[iidx]) {
case AFFINE:
{
          AffineTransform3d aff=rinst.getAffine(tidx);
          mulTransform(gl,aff);
          break;
        }
case FRAME:
{
        RigidTransform3d frame=rinst.getFrame(tidx);
        mulTransform(gl,frame);
        break;
      }
case POINT:
{
      float[] trans=rinst.getPoint(tidx);
      gl.glTranslatef(trans[0],trans[1],trans[2]);
      break;
    }
}
if (hasInstanceScales && (sidx >= 0)) {
  Double s=rinst.getScale(sidx);
  gl.glScaled(s,s,s);
}
if (hasInstanceColors && (cidx >= 0)) {
  byte[] c=rinst.getColor(cidx);
  gl.glColor4ub(c[0],c[1],c[2],c[3]);
}
drawRawTriangles(gl,robj,gidx,0,robj.numTriangles(gidx),robj.hasNormals(),!hasInstanceColors && useColors,!selecting & robj.hasTextureCoords(),useHSV);
ipos+=stride;
tpos+=stride;
cpos+=stride;
spos+=stride;
}
gl.glPopMatrix();
robj.readUnlock();
rinst.readUnlock();
if (gvo != null) {
gvo.endCompile(gl);
gvo.draw(gl);
}
}
 else {
gvo.draw(gl);
}
if (useColors) {
disableVertexColoring(useHSV,savedShading);
}
}

Fixed version (ground truth):
@Override public void drawTriangles(RenderObject robj,int gidx,RenderInstances rinst){
  boolean selecting=isSelecting();
  boolean hasColors=((robj.hasColors() || rinst.hasColors()) && hasVertexColoring());
  boolean useColors=hasColors && !selecting && (myActiveColor == ActiveColor.DEFAULT);
  boolean useHSV=isHSVColorInterpolationEnabled();
  maybeUpdateState(gl);
  int savedShading=0;
  if (useColors) {
    savedShading=enableVertexColoring(useHSV);
  }
  boolean useDisplayList=(!selecting || !hasColors) && (!robj.isTransient());
  GL2VersionedObject gvo=null;
  boolean compile=true;
  if (useDisplayList) {
    RenderInstancesKey key=new RenderInstancesKey(rinst.getIdentifier(),robj.getIdentifier(),DrawType.TRIANGLES,gidx);
    RenderInstancesFingerprint fingerprint=new RenderInstancesFingerprint(rinst.getVersionInfo(),robj.getVersionInfo());
    gvo=myGLResources.getVersionedObject(key);
    if (gvo == null || gvo.disposeInvalid(gl)) {
      gvo=myGLResources.allocateVersionedObject(gl,key,fingerprint);
      compile=true;
    }
 else {
      compile=!(gvo.compareExchangeFingerPrint(fingerprint));
    }
  }
  if (compile) {
    if (gvo != null) {
      gvo.beginCompile(gl);
    }
    robj.readLock();
    rinst.readLock();
    int ninstances=rinst.numInstances();
    int[] instances=rinst.getInstances();
    int ipos=rinst.getInstanceTypeOffset();
    int tpos=rinst.getInstanceTransformOffset();
    int cpos=rinst.getInstanceColorOffset();
    int spos=rinst.getInstanceScaleOffset();
    int stride=rinst.getInstanceStride();
    InstanceTransformType[] type=RenderInstances.getTransformTypes();
    boolean hasInstanceScales=rinst.hasScales();
    boolean hasInstanceColors=useColors && rinst.hasColors();
    for (int i=0; i < ninstances; ++i) {
      int iidx=instances[ipos];
      int tidx=instances[tpos];
      int cidx=instances[cpos];
      int sidx=instances[spos];
      gl.glPushMatrix();
switch (type[iidx]) {
case AFFINE:
{
          AffineTransform3d aff=rinst.getAffine(tidx);
          mulTransform(gl,aff);
          break;
        }
case FRAME:
{
        RigidTransform3d frame=rinst.getFrame(tidx);
        mulTransform(gl,frame);
        break;
      }
case POINT:
{
      float[] trans=rinst.getPoint(tidx);
      gl.glTranslatef(trans[0],trans[1],trans[2]);
      break;
    }
}
if (hasInstanceScales && (sidx >= 0)) {
  Double s=rinst.getScale(sidx);
  gl.glScaled(s,s,s);
}
if (hasInstanceColors && (cidx >= 0)) {
  byte[] c=rinst.getColor(cidx);
  gl.glColor4ub(c[0],c[1],c[2],c[3]);
}
drawRawTriangles(gl,robj,gidx,0,robj.numTriangles(gidx),robj.hasNormals(),!hasInstanceColors && useColors,!selecting & robj.hasTextureCoords(),useHSV);
gl.glPopMatrix();
ipos+=stride;
tpos+=stride;
cpos+=stride;
spos+=stride;
}
robj.readUnlock();
rinst.readUnlock();
if (gvo != null) {
gvo.endCompile(gl);
gvo.draw(gl);
}
}
 else {
gvo.draw(gl);
}
if (useColors) {
disableVertexColoring(useHSV,savedShading);
}
}