Program: 173173
Project: 173173
Buggy source:
/** 
 * Initialize the data structure
 * @param cfg
 * @param plan
 * @param roots
 * @param dests
 */
public KeyedInvertedBinaryTreeRouter(Config cfg,TaskPlan plan,Set<Integer> roots,Set<Integer> dests){
  int interNodeDegree=MPIContext.interNodeDegree(cfg,2);
  int intraNodeDegree=MPIContext.intraNodeDegree(cfg,2);
  mainTaskLast=false;
  this.taskPlan=plan;
  this.destinationIdentifiers=new HashMap<>();
  this.pathToTask=new HashMap<>();
  this.receiveTasks=new HashMap<Integer,Map<Integer,List<Integer>>>();
  sendExternalTasksPartial=new HashMap<>();
  sendInternalTasks=new HashMap<>();
  sendExternalTasks=new HashMap<>();
  receiveExecutors=new HashSet<>();
  List<Integer> rootsSorted=new ArrayList<Integer>(roots);
  Collections.sort(rootsSorted);
  mainTask=new HashMap<>();
  Set<Integer> destinationsInThisExecutor=TaskPlanUtils.getTasksOfThisExecutor(plan,dests);
  for (  int t : destinationsInThisExecutor) {
    int path=rootsSorted.indexOf(t);
    pathToTask.put(path,t);
  }
  for (int path=0; path < roots.size(); path++) {
    int root=rootsSorted.get(path);
    BinaryTree tree=new BinaryTree(interNodeDegree,intraNodeDegree,plan,root,dests);
    Node treeRoot=tree.buildInterGroupTree(path);
    Set<Integer> thisExecutorTasks=plan.getChannelsOfExecutor(plan.getThisExecutor());
    Set<Integer> thisExecutorTasksOfOperation=new HashSet<>();
    for (    int t : thisExecutorTasks) {
      if (dests.contains(t) || root == t) {
        thisExecutorTasksOfOperation.add(t);
      }
    }
    LOG.info(String.format("String_Node_Str",plan.getThisExecutor(),thisExecutorTasksOfOperation.toString()));
    for (    int t : thisExecutorTasksOfOperation) {
      List<Integer> recv=new ArrayList<>();
      Node search=BinaryTree.search(treeRoot,t);
      if (search != null) {
        mainTask.put(path,search.getTaskId());
        LOG.info(String.format("String_Node_Str",plan.getThisExecutor(),mainTask));
        for (        int k : search.getRemoteChildrenIds()) {
          receiveExecutors.add(plan.getExecutorForChannel(k));
        }
        recv.addAll(search.getAllChildrenIds());
        Map<Integer,List<Integer>> receivePathMap;
        if (receiveTasks.containsKey(t)) {
          receivePathMap=receiveTasks.get(t);
        }
 else {
          receivePathMap=new HashMap<>();
        }
        receivePathMap.put(path,new ArrayList<>(recv));
        receiveTasks.put(t,receivePathMap);
        List<Integer> directChildren=search.getDirectChildren();
        if (t == path) {
          LOG.log(Level.INFO,String.format("String_Node_Str",plan.getThisExecutor(),directChildren));
        }
        for (        int child : directChildren) {
          Map<Integer,Set<Integer>> sendMap;
          if (sendInternalTasks.containsKey(child)) {
            sendMap=sendInternalTasks.get(child);
          }
 else {
            sendMap=new HashMap<>();
          }
          Set<Integer> sendTasks=new HashSet<>();
          sendTasks.add(t);
          sendMap.put(path,sendTasks);
          sendInternalTasks.put(child,sendMap);
          Map<Integer,Integer> destinationMap=new HashMap<>();
          if (destinationIdentifiers.containsKey(path)) {
            destinationMap=destinationIdentifiers.get(path);
          }
          destinationMap.put(child,t);
          destinationIdentifiers.put(path,destinationMap);
        }
        Node parent=search.getParent();
        if (parent != null) {
          Map<Integer,Set<Integer>> mainSendMap;
          if (sendExternalTasksPartial.containsKey(t)) {
            mainSendMap=sendExternalTasksPartial.get(t);
          }
 else {
            mainSendMap=new HashMap<>();
          }
          Set<Integer> sendTasks=new HashSet<>();
          sendTasks.add(parent.getTaskId());
          mainSendMap.put(path,sendTasks);
          sendExternalTasksPartial.put(t,mainSendMap);
          Map<Integer,Integer> destinationMap=new HashMap<>();
          if (destinationIdentifiers.containsKey(path)) {
            destinationMap=destinationIdentifiers.get(path);
          }
          destinationMap.put(t,parent.getTaskId());
          destinationIdentifiers.put(path,destinationMap);
        }
 else {
          mainTaskLast=true;
        }
      }
 else {
        LOG.info(String.format("String_Node_Str",plan.getThisExecutor(),t));
      }
    }
  }
  LOG.info(String.format("String_Node_Str",plan.getThisExecutor(),sendInternalTasks));
  LOG.info(String.format("String_Node_Str",plan.getThisExecutor(),sendExternalTasks));
  LOG.info(String.format("String_Node_Str",plan.getThisExecutor(),sendExternalTasksPartial));
  LOG.info(String.format("String_Node_Str",plan.getThisExecutor(),receiveExecutors));
  LOG.info(String.format("String_Node_Str",plan.getThisExecutor(),receiveTasks));
  LOG.info(String.format("String_Node_Str",plan.getThisExecutor(),mainTask));
}

Fixed version (ground truth):
/** 
 * Initialize the data structure
 * @param cfg
 * @param plan
 * @param roots
 * @param dests
 */
public KeyedInvertedBinaryTreeRouter(Config cfg,TaskPlan plan,Set<Integer> roots,Set<Integer> dests){
  int interNodeDegree=MPIContext.interNodeDegree(cfg,2);
  int intraNodeDegree=MPIContext.intraNodeDegree(cfg,2);
  mainTaskLast=false;
  this.taskPlan=plan;
  this.destinationIdentifiers=new HashMap<>();
  this.pathToTask=new HashMap<>();
  this.receiveTasks=new HashMap<Integer,Map<Integer,List<Integer>>>();
  sendExternalTasksPartial=new HashMap<>();
  sendInternalTasks=new HashMap<>();
  sendExternalTasks=new HashMap<>();
  receiveExecutors=new HashSet<>();
  List<Integer> rootsSorted=new ArrayList<Integer>(roots);
  Collections.sort(rootsSorted);
  mainTask=new HashMap<>();
  Set<Integer> destinationsInThisExecutor=TaskPlanUtils.getTasksOfThisExecutor(plan,dests);
  for (  int t : destinationsInThisExecutor) {
    int path=rootsSorted.indexOf(t);
    pathToTask.put(path,t);
  }
  for (int path=0; path < roots.size(); path++) {
    int root=rootsSorted.get(path);
    BinaryTree tree=new BinaryTree(interNodeDegree,intraNodeDegree,plan,root,dests);
    Node treeRoot=tree.buildInterGroupTree(path);
    Set<Integer> thisExecutorTasks=plan.getChannelsOfExecutor(plan.getThisExecutor());
    Set<Integer> thisExecutorTasksOfOperation=new HashSet<>();
    for (    int t : thisExecutorTasks) {
      if (dests.contains(t) || root == t) {
        thisExecutorTasksOfOperation.add(t);
      }
    }
    LOG.info(String.format("String_Node_Str",plan.getThisExecutor(),thisExecutorTasksOfOperation.toString()));
    for (    int t : thisExecutorTasksOfOperation) {
      List<Integer> recv=new ArrayList<>();
      Node search=BinaryTree.search(treeRoot,t);
      if (search != null) {
        mainTask.put(path,search.getTaskId());
        LOG.info(String.format("String_Node_Str",plan.getThisExecutor(),mainTask));
        for (        int k : search.getRemoteChildrenIds()) {
          receiveExecutors.add(plan.getExecutorForChannel(k));
        }
        recv.addAll(search.getAllChildrenIds());
        Map<Integer,List<Integer>> receivePathMap;
        if (receiveTasks.containsKey(t)) {
          receivePathMap=receiveTasks.get(t);
        }
 else {
          receivePathMap=new HashMap<>();
        }
        receivePathMap.put(path,new ArrayList<>(recv));
        receiveTasks.put(t,receivePathMap);
        List<Integer> directChildren=search.getDirectChildren();
        if (t == path) {
          LOG.log(Level.INFO,String.format("String_Node_Str",plan.getThisExecutor(),directChildren));
        }
        for (        int child : directChildren) {
          Map<Integer,Set<Integer>> sendMap;
          if (sendInternalTasks.containsKey(child)) {
            sendMap=sendInternalTasks.get(child);
          }
 else {
            sendMap=new HashMap<>();
          }
          Set<Integer> sendTasks=new HashSet<>();
          sendTasks.add(t);
          sendMap.put(path,sendTasks);
          sendInternalTasks.put(child,sendMap);
          Map<Integer,Integer> destinationMap=new HashMap<>();
          if (destinationIdentifiers.containsKey(path)) {
            destinationMap=destinationIdentifiers.get(path);
          }
          destinationMap.put(child,t);
          destinationIdentifiers.put(path,destinationMap);
        }
        Node parent=search.getParent();
        if (parent != null) {
          Map<Integer,Set<Integer>> mainSendMap;
          if (sendExternalTasksPartial.containsKey(t)) {
            mainSendMap=sendExternalTasksPartial.get(t);
          }
 else {
            mainSendMap=new HashMap<>();
          }
          Set<Integer> sendTasks=new HashSet<>();
          sendTasks.add(parent.getTaskId());
          mainSendMap.put(path,sendTasks);
          sendExternalTasksPartial.put(t,mainSendMap);
          Map<Integer,Integer> destinationMap=new HashMap<>();
          if (destinationIdentifiers.containsKey(path)) {
            destinationMap=destinationIdentifiers.get(path);
          }
          destinationMap.put(t,parent.getTaskId());
          destinationIdentifiers.put(path,destinationMap);
        }
 else {
          mainTaskLast=true;
        }
      }
 else {
        LOG.info(String.format("String_Node_Str",plan.getThisExecutor(),t));
      }
    }
  }
}