Program: 70740
Project: 70740
Buggy source:
public void processSelection(GLAutoDrawable drawable){
  GL2 gl=myGl;
  gl.glEnable(GL2.GL_LIGHTING);
  if (savedBlend) {
    gl.glEnable(GL.GL_BLEND);
  }
  if (savedMulti) {
    gl.glEnable(GL.GL_MULTISAMPLE);
  }
  if (!myMaxQStack.isEmpty()) {
    throw new IllegalStateException("String_Node_Str");
  }
  int w=myViewW;
  int h=myViewH;
  ByteBuffer pixels=ByteBuffer.allocate(4 * w * h);
  gl.glReadPixels(0,0,w,h,GL2.GL_RGBA,GL2.GL_UNSIGNED_BYTE,pixels);
  HitRecord[] hits=null;
  boolean badIdWarningIssued=false;
  for (int i=0; i < w; i++) {
    for (int j=0; j < h; j++) {
      int r=0xff & pixels.get();
      int g=0xff & pixels.get();
      int b=0xff & pixels.get();
      int a=0xff & pixels.get();
      int colorId=r;
      colorId<<=8;
      colorId+=g;
      colorId<<=8;
      colorId+=b;
      if (colorId != 0) {
        int id=colorId - 1;
        if (id < 0 || id >= myTotalMaxQ) {
          if (!badIdWarningIssued) {
            System.out.printf("String_Node_Str" + "String_Node_Str",id);
            badIdWarningIssued=true;
          }
        }
 else {
          if (hits == null) {
            hits=new HitRecord[myTotalMaxQ];
          }
          HitRecord rec=hits[id];
          if (rec == null) {
            rec=new HitRecord(0);
            hits[id]=rec;
          }
          rec.size++;
        }
      }
    }
  }
  gl.glBindFramebuffer(GL2.GL_FRAMEBUFFER,0);
  gl.glDeleteFramebuffers(1,frameBufferId,0);
  gl.glDeleteRenderbuffers(1,renderBufferId,0);
  gl.glDeleteRenderbuffers(1,depthBufferId,0);
  gl.glViewport(mySavedViewport[0],mySavedViewport[1],mySavedViewport[2],mySavedViewport[3]);
  gl.glMatrixMode(GL2.GL_PROJECTION);
  gl.glPopMatrix();
  gl.glMatrixMode(GL2.GL_MODELVIEW);
  myViewer.selectionEvent.mySelectedObjects=new LinkedList[0];
  if (hits == null) {
    myViewer.selectionEvent.mySelectedObjects=new LinkedList[0];
  }
 else {
    int qid=0;
    LinkedList<HitRecord> records=new LinkedList<HitRecord>();
    int[] result=new int[1];
    Iterator<GLRenderable> it=myViewer.renderIterator();
    while (it.hasNext()) {
      GLRenderable r=it.next();
      if (r instanceof GLSelectable) {
        GLSelectable s=(GLSelectable)r;
        int numq=s.numSelectionQueriesNeeded();
        int nums=(numq >= 0 ? numq : 1);
        if (s.isSelectable()) {
          for (int i=0; i < nums; i++) {
            HitRecord rec;
            if ((rec=hits[qid + i]) != null) {
              if (numq < 0) {
                rec.objs.add(s);
              }
 else {
                s.getSelection(rec.objs,i);
              }
              if (rec.objs.size() > 0) {
                records.add(rec);
              }
            }
          }
        }
        qid+=nums;
      }
    }
    Collections.sort(records);
    LinkedList<Object>[] selObjs=new LinkedList[records.size()];
    for (int i=0; i < records.size(); i++) {
      selObjs[i]=records.get(i).objs;
    }
    myViewer.selectionEvent.mySelectedObjects=selObjs;
  }
  GLSelectionListener[] listeners=myViewer.getSelectionListeners();
  for (int i=0; i < listeners.length; i++) {
    listeners[i].itemsSelected(myViewer.selectionEvent);
  }
  myViewer.getCanvas().repaint();
}

Fixed version (ground truth):
public void processSelection(GLAutoDrawable drawable){
  GL2 gl=myGl;
  gl.glEnable(GL2.GL_LIGHTING);
  if (savedBlend) {
    gl.glEnable(GL.GL_BLEND);
  }
  if (savedMulti) {
    gl.glEnable(GL.GL_MULTISAMPLE);
  }
  if (!myMaxQStack.isEmpty()) {
    throw new IllegalStateException("String_Node_Str");
  }
  int w=myViewW;
  int h=myViewH;
  ByteBuffer pixels=ByteBuffer.allocateDirect(4 * w * h);
  pixels.order(ByteOrder.nativeOrder());
  fbo.getPixelsRGBA(pixels);
  fbo.deactivate();
  fbo.cleanup();
  fbo=null;
  HitRecord[] hits=null;
  boolean badIdWarningIssued=false;
  for (int i=0; i < w; i++) {
    for (int j=0; j < h; j++) {
      int r=0xff & pixels.get();
      int g=0xff & pixels.get();
      int b=0xff & pixels.get();
      int a=0xff & pixels.get();
      int colorId=r;
      colorId<<=8;
      colorId+=g;
      colorId<<=8;
      colorId+=b;
      if (colorId != 0) {
        int id=colorId - 1;
        if (id < 0 || id >= myTotalMaxQ) {
          if (!badIdWarningIssued) {
            System.out.printf("String_Node_Str" + "String_Node_Str",id);
            badIdWarningIssued=true;
          }
        }
 else {
          if (hits == null) {
            hits=new HitRecord[myTotalMaxQ];
          }
          HitRecord rec=hits[id];
          if (rec == null) {
            rec=new HitRecord(0);
            hits[id]=rec;
          }
          rec.size++;
        }
      }
    }
  }
  pixels.clear();
  if (myViewer.isMultiSampleEnabled()) {
    FrameBufferObject dummy=new FrameBufferObject(0,0,myViewer.getWidth(),myViewer.getHeight(),8,null,null,gl);
    dummy.setupFBO();
    dummy.activate();
    dummy.deactivate();
    dummy.cleanup();
  }
  gl.glViewport(mySavedViewport[0],mySavedViewport[1],mySavedViewport[2],mySavedViewport[3]);
  gl.glMatrixMode(GL2.GL_PROJECTION);
  gl.glPopMatrix();
  gl.glMatrixMode(GL2.GL_MODELVIEW);
  myViewer.selectionEvent.mySelectedObjects=new LinkedList[0];
  if (hits == null) {
    myViewer.selectionEvent.mySelectedObjects=new LinkedList[0];
  }
 else {
    int qid=0;
    LinkedList<HitRecord> records=new LinkedList<HitRecord>();
    int[] result=new int[1];
    Iterator<GLRenderable> it=myViewer.renderIterator();
    while (it.hasNext()) {
      GLRenderable r=it.next();
      if (r instanceof GLSelectable) {
        GLSelectable s=(GLSelectable)r;
        int numq=s.numSelectionQueriesNeeded();
        int nums=(numq >= 0 ? numq : 1);
        if (s.isSelectable()) {
          for (int i=0; i < nums; i++) {
            HitRecord rec;
            if ((rec=hits[qid + i]) != null) {
              if (numq < 0) {
                rec.objs.add(s);
              }
 else {
                s.getSelection(rec.objs,i);
              }
              if (rec.objs.size() > 0) {
                records.add(rec);
              }
            }
          }
        }
        qid+=nums;
      }
    }
    Collections.sort(records);
    LinkedList<Object>[] selObjs=new LinkedList[records.size()];
    for (int i=0; i < records.size(); i++) {
      selObjs[i]=records.get(i).objs;
    }
    myViewer.selectionEvent.mySelectedObjects=selObjs;
  }
  GLSelectionListener[] listeners=myViewer.getSelectionListeners();
  for (int i=0; i < listeners.length; i++) {
    listeners[i].itemsSelected(myViewer.selectionEvent);
  }
  myViewer.getCanvas().repaint();
}