Program: 133239
Project: 133239
Buggy source:
/** 
 * @param logger
 * @param ancestorBlock the block the instructions are moved from
 * @param ancestors 
 * @param currBlock the block they are moved too (a descendant of the priorblock)
 * @param currBlockInstructions  all changes to instructions in curr blockare made through this iterator, and it is rewound to the previous position before the function exits
 * @param waitMap map of variable names to instructions/continuations they blockon
 * @param writtenV
 * @return list of moved continuations
 */
private static Set<Continuation> relocateDependentInstructions(Logger logger,Block ancestorBlock,Deque<AncestorContinuation> ancestors,Block currBlock,ListIterator<Instruction> currBlockInstructions,MultiMap<String,InstOrCont> waitMap,Var writtenV){
  List<InstOrCont> waits=waitMap.get(writtenV.name());
  Set<Instruction> movedI=new HashSet<Instruction>();
  Set<Continuation> movedC=new HashSet<Continuation>();
  for (  InstOrCont ic : waits) {
    logger.trace("String_Node_Str" + ic.toString());
switch (ic.type()) {
case CONTINUATION:
      Continuation c=ic.continuation();
    currBlock.addContinuation(c);
  movedC.add(c);
assert(c.isAsync());
updateAncestorKeepOpen(ancestors,c.getKeepOpenVars());
break;
case INSTRUCTION:
boolean canRelocate=true;
Instruction inst=ic.instruction();
ArrayList<Var> keepOpenVars=new ArrayList<Var>();
for (Var out : inst.getOutputs()) {
if (Types.isArray(out.type())) {
keepOpenVars.add(out);
}
 else if (Types.isArrayRef(out.type())) {
canRelocate=false;
}
}
if (canRelocate) {
currBlockInstructions.add(inst);
movedI.add(ic.instruction());
if (!keepOpenVars.isEmpty()) {
updateAncestorKeepOpen(ancestors,keepOpenVars);
}
}
break;
default :
throw new STCRuntimeError("String_Node_Str");
}
}
ancestorBlock.removeContinuations(movedC);
ancestorBlock.removeInstructions(movedI);
ICUtil.rewindIterator(currBlockInstructions,movedI.size());
updateWaiterMap(waitMap,movedC,movedI);
return movedC;
}

Fixed version (ground truth):
/** 
 * @param logger
 * @param ancestorBlock the block the instructions are moved from
 * @param ancestors 
 * @param currBlock the block they are moved too (a descendant of the priorblock)
 * @param currBlockInstructions  all changes to instructions in curr blockare made through this iterator, and it is rewound to the previous position before the function exits
 * @param waitMap map of variable names to instructions/continuations they blockon
 * @param writtenV
 * @return list of moved continuations
 */
private static Set<Continuation> relocateDependentInstructions(Logger logger,Block ancestorBlock,Deque<AncestorContinuation> ancestors,Block currBlock,ListIterator<Instruction> currBlockInstructions,MultiMap<String,InstOrCont> waitMap,Var writtenV){
  List<InstOrCont> waits=waitMap.get(writtenV.name());
  Set<Instruction> movedI=new HashSet<Instruction>();
  Set<Continuation> movedC=new HashSet<Continuation>();
  for (  InstOrCont ic : waits) {
    logger.trace("String_Node_Str" + ic.toString());
switch (ic.type()) {
case CONTINUATION:
{
        Continuation c=ic.continuation();
        boolean canRelocate=true;
        for (        AncestorContinuation ancestor : ancestors) {
          if (c == ancestor.continuation) {
            canRelocate=false;
            break;
          }
        }
        if (canRelocate) {
          currBlock.addContinuation(c);
          movedC.add(c);
          assert(c.isAsync());
          updateAncestorKeepOpen(ancestors,c.getKeepOpenVars());
        }
        break;
      }
case INSTRUCTION:
{
      boolean canRelocate=true;
      Instruction inst=ic.instruction();
      ArrayList<Var> keepOpenVars=new ArrayList<Var>();
      for (      Var out : inst.getOutputs()) {
        if (Types.isArray(out.type())) {
          keepOpenVars.add(out);
        }
 else         if (Types.isArrayRef(out.type())) {
          canRelocate=false;
        }
      }
      if (canRelocate) {
        currBlockInstructions.add(inst);
        movedI.add(ic.instruction());
        if (!keepOpenVars.isEmpty()) {
          updateAncestorKeepOpen(ancestors,keepOpenVars);
        }
      }
      break;
    }
default :
  throw new STCRuntimeError("String_Node_Str");
}
}
ancestorBlock.removeContinuations(movedC);
ancestorBlock.removeInstructions(movedI);
ICUtil.rewindIterator(currBlockInstructions,movedI.size());
updateWaiterMap(waitMap,movedC,movedI);
return movedC;
}