Program: 172892
Project: 172892
Buggy source:
/** 
 * Progress the communications that are pending
 */
public void progress(){
  while (pendingSends.size() > 0) {
    TCPSendRequests sendRequests=pendingSends.poll();
    postMessage(sendRequests);
    waitForCompletionSends.add(sendRequests);
  }
  for (int i=0; i < registeredReceives.size(); i++) {
    TCPReceiveRequests receiveRequests=registeredReceives.get(i);
    if (receiveRequests.availableBuffers.size() > 0) {
      postReceive(receiveRequests);
    }
  }
  Iterator<TCPSendRequests> sendRequestsIterator=waitForCompletionSends.iterator();
  while (sendRequestsIterator.hasNext()) {
    TCPSendRequests sendRequests=sendRequestsIterator.next();
    Iterator<Request> requestIterator=sendRequests.pendingSends.iterator();
    while (requestIterator.hasNext()) {
      Request r=requestIterator.next();
      TCPStatus status=r.request.testStatus();
      if (status != null) {
        requestIterator.remove();
      }
    }
    if (sendRequests.pendingSends.size() == 0) {
      sendRequests.callback.onSendComplete(sendRequests.rank,sendRequests.edge,sendRequests.message);
      sendRequestsIterator.remove();
    }
  }
  for (int i=0; i < registeredReceives.size(); i++) {
    TCPReceiveRequests receiveRequests=registeredReceives.get(i);
    Iterator<Request> requestIterator=receiveRequests.pendingRequests.iterator();
    while (requestIterator.hasNext()) {
      Request r=requestIterator.next();
      TCPStatus status=r.request.testStatus();
      if (status != null) {
        r.buffer.setSize(r.buffer.getByteBuffer().limit());
        receiveRequests.callback.onReceiveComplete(receiveRequests.rank,receiveRequests.edge,r.buffer);
        requestIterator.remove();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Progress the communications that are pending
 */
public void progress(){
  while (pendingSends.size() > 0) {
    TCPSendRequests sendRequests=pendingSends.poll();
    postMessage(sendRequests);
    waitForCompletionSends.add(sendRequests);
  }
  for (int i=0; i < registeredReceives.size(); i++) {
    TCPReceiveRequests receiveRequests=registeredReceives.get(i);
    if (receiveRequests.availableBuffers.size() > 0) {
      postReceive(receiveRequests);
    }
  }
  Iterator<TCPSendRequests> sendRequestsIterator=waitForCompletionSends.iterator();
  while (sendRequestsIterator.hasNext()) {
    TCPSendRequests sendRequests=sendRequestsIterator.next();
    Iterator<Request> requestIterator=sendRequests.pendingSends.iterator();
    while (requestIterator.hasNext()) {
      Request r=requestIterator.next();
      TCPStatus status=r.request.testStatus();
      if (status != null) {
        requestIterator.remove();
      }
    }
    if (sendRequests.pendingSends.size() == 0) {
      sendRequests.callback.onSendComplete(sendRequests.rank,sendRequests.edge,sendRequests.message);
      sendRequestsIterator.remove();
    }
  }
  for (int i=0; i < registeredReceives.size(); i++) {
    TCPReceiveRequests receiveRequests=registeredReceives.get(i);
    Iterator<Request> requestIterator=receiveRequests.pendingRequests.iterator();
    while (requestIterator.hasNext()) {
      Request r=requestIterator.next();
      TCPStatus status=r.request.testStatus();
      if (status != null) {
        r.buffer.setSize(r.buffer.getByteBuffer().limit());
        receiveRequests.callback.onReceiveComplete(receiveRequests.rank,receiveRequests.edge,r.buffer);
        requestIterator.remove();
      }
    }
  }
  comm.progress();
}