Program: 173020
Project: 173020
Buggy source:
private void sendProgress(Queue<Pair<Object,MPISendMessage>> pendingSendMessages,int sendId){
  boolean canProgress=true;
  while (pendingSendMessages.size() > 0 && canProgress) {
    Pair<Object,MPISendMessage> pair=pendingSendMessages.peek();
    MPISendMessage mpiSendMessage=pair.getValue();
    Object messageObject=pair.getKey();
    if (mpiSendMessage.serializedState() == MPISendMessage.SendState.INIT) {
      for (      Integer i : mpiSendMessage.getInternalSends()) {
        boolean receiveAccepted;
        if (isStoreBased && isLastReceiver) {
          serializeAndWriteToMemoryManager(mpiSendMessage,messageObject);
          receiveAccepted=receiver.receiveSendInternally(mpiSendMessage.getSource(),i,mpiSendMessage.getPath(),mpiSendMessage.getFlags(),operationMemoryManager);
        }
 else {
          lock.lock();
          try {
            receiveAccepted=receiver.receiveSendInternally(mpiSendMessage.getSource(),i,mpiSendMessage.getPath(),mpiSendMessage.getFlags(),messageObject);
          }
  finally {
            lock.unlock();
          }
        }
        if (!receiveAccepted) {
          canProgress=false;
          break;
        }
      }
      if (canProgress) {
        mpiSendMessage.setSendState(MPISendMessage.SendState.SENT_INTERNALLY);
      }
    }
    if (canProgress) {
      if (mpiSendMessage.getExternalSends().size() == 0) {
        pendingSendMessages.poll();
        continue;
      }
      MPISendMessage message=(MPISendMessage)messageSerializer.get(sendId).build(pair.getKey(),mpiSendMessage);
      if (message.serializedState() == MPISendMessage.SendState.SERIALIZED) {
        List<Integer> exRoutes=new ArrayList<>(mpiSendMessage.getExternalSends());
        int startOfExternalRouts=mpiSendMessage.getAcceptedExternalSends();
        int noOfExternalSends=startOfExternalRouts;
        for (int i=startOfExternalRouts; i < exRoutes.size(); i++) {
          boolean sendAccepted=sendMessageToTarget(message.getMPIMessage(),exRoutes.get(i));
          if (!sendAccepted) {
            canProgress=false;
            break;
          }
 else {
            sendCount++;
            mpiSendMessage.incrementAcceptedExternalSends();
            noOfExternalSends++;
          }
        }
        if (noOfExternalSends == exRoutes.size()) {
          mpiSendMessage.setSendState(MPISendMessage.SendState.FINISHED);
          pendingSendMessages.poll();
        }
      }
 else {
        break;
      }
    }
  }
}

Fixed version (ground truth):
private void sendProgress(Queue<Pair<Object,MPISendMessage>> pendingSendMessages,int sendId){
  boolean canProgress=true;
  while (pendingSendMessages.size() > 0 && canProgress) {
    Pair<Object,MPISendMessage> pair=pendingSendMessages.peek();
    MPISendMessage mpiSendMessage=pair.getValue();
    Object messageObject=pair.getKey();
    if (mpiSendMessage.serializedState() == MPISendMessage.SendState.INIT) {
      int startOfInternalRouts=mpiSendMessage.getAcceptedInternalSends();
      List<Integer> inRoutes=new ArrayList<>(mpiSendMessage.getInternalSends());
      for (int i=startOfInternalRouts; i < mpiSendMessage.getInternalSends().size(); i++) {
        boolean receiveAccepted;
        if (isStoreBased && isLastReceiver) {
          serializeAndWriteToMemoryManager(mpiSendMessage,messageObject);
          receiveAccepted=receiver.receiveSendInternally(mpiSendMessage.getSource(),inRoutes.get(i),mpiSendMessage.getPath(),mpiSendMessage.getFlags(),operationMemoryManager);
        }
 else {
          lock.lock();
          try {
            receiveAccepted=receiver.receiveSendInternally(mpiSendMessage.getSource(),inRoutes.get(i),mpiSendMessage.getPath(),mpiSendMessage.getFlags(),messageObject);
          }
  finally {
            lock.unlock();
          }
        }
        if (!receiveAccepted) {
          canProgress=false;
          break;
        }
        mpiSendMessage.incrementAcceptedInternalSends();
      }
      if (canProgress) {
        mpiSendMessage.setSendState(MPISendMessage.SendState.SENT_INTERNALLY);
      }
    }
    if (canProgress) {
      if (mpiSendMessage.getExternalSends().size() == 0) {
        pendingSendMessages.poll();
        continue;
      }
      MPISendMessage message=(MPISendMessage)messageSerializer.get(sendId).build(pair.getKey(),mpiSendMessage);
      if (message.serializedState() == MPISendMessage.SendState.SERIALIZED) {
        List<Integer> exRoutes=new ArrayList<>(mpiSendMessage.getExternalSends());
        int startOfExternalRouts=mpiSendMessage.getAcceptedExternalSends();
        int noOfExternalSends=startOfExternalRouts;
        for (int i=startOfExternalRouts; i < exRoutes.size(); i++) {
          boolean sendAccepted=sendMessageToTarget(message.getMPIMessage(),exRoutes.get(i));
          if (!sendAccepted) {
            canProgress=false;
            break;
          }
 else {
            sendCount++;
            mpiSendMessage.incrementAcceptedExternalSends();
            noOfExternalSends++;
          }
        }
        if (noOfExternalSends == exRoutes.size()) {
          mpiSendMessage.setSendState(MPISendMessage.SendState.FINISHED);
          pendingSendMessages.poll();
        }
      }
 else {
        break;
      }
    }
  }
}