Program: 132763
Project: 132763
Buggy source:
private static void rebuildContinuationPassedVars(Function function,Continuation continuation,ExecContext contCx,HierarchicalSet<Var> visibleVars,Set<Var> outerBlockVars,AliasTracker outerAliases,Result outer,Result inner){
  List<PassedVar> passedIn=new ArrayList<PassedVar>();
  for (  Var needed : inner.allNeeded()) {
    if (!visibleVars.contains(needed)) {
      throw new STCRuntimeError("String_Node_Str" + needed + "String_Node_Str"+ "String_Node_Str"+ function.getName());
    }
    boolean writeOnly=!inner.read.contains(needed);
    passedIn.add(new PassedVar(needed,writeOnly));
  }
  outer.addExcluding(inner,outerBlockVars);
  for (  PassedVar addtl : continuation.getMustPassVars()) {
    boolean mustAdd=true;
    ListIterator<PassedVar> it=passedIn.listIterator();
    while (it.hasNext()) {
      PassedVar existing=it.next();
      if (existing.var.equals(addtl.var)) {
        mustAdd=false;
        if (existing.writeOnly && !addtl.writeOnly) {
          it.set(addtl);
        }
      }
    }
    if (mustAdd) {
      if (addtl.var.storage() == Alloc.GLOBAL_CONST) {
        if (contCx == ExecContext.WORKER) {
          passedIn.add(addtl);
        }
 else {
          assert(contCx == ExecContext.CONTROL);
          for (          Block b : continuation.getBlocks()) {
            if (!b.getVariables().contains(addtl.var)) {
              b.addVariable(addtl.var);
            }
          }
        }
      }
 else {
        passedIn.add(addtl);
      }
    }
  }
  continuation.setPassedVars(passedIn);
}

Fixed version (ground truth):
private static void rebuildContinuationPassedVars(Function function,Continuation continuation,ExecContext contCx,HierarchicalSet<Var> visibleVars,Set<Var> outerBlockVars,AliasTracker outerAliases,Result outer,Result inner,FixupVarMode fixupMode){
  List<PassedVar> passedIn=new ArrayList<PassedVar>();
  for (  Var needed : inner.allNeeded()) {
    if (!visibleVars.contains(needed)) {
      throw new STCRuntimeError("String_Node_Str" + needed + "String_Node_Str"+ "String_Node_Str"+ function.getName());
    }
    boolean writeOnly=!inner.read.contains(needed);
    passedIn.add(new PassedVar(needed,writeOnly));
  }
  outer.addExcluding(inner,outerBlockVars);
  for (  PassedVar addtl : continuation.getMustPassVars()) {
    boolean mustAdd=true;
    ListIterator<PassedVar> it=passedIn.listIterator();
    while (it.hasNext()) {
      PassedVar existing=it.next();
      if (existing.var.equals(addtl.var)) {
        mustAdd=false;
        if (existing.writeOnly && !addtl.writeOnly) {
          it.set(addtl);
        }
      }
    }
    if (mustAdd) {
      if (addtl.var.storage() == Alloc.GLOBAL_CONST) {
        if (canImportGlobals(contCx)) {
          for (          Block b : continuation.getBlocks()) {
            if (!b.getVariables().contains(addtl.var)) {
              b.addVariable(addtl.var);
            }
          }
        }
 else {
          passedIn.add(addtl);
        }
      }
 else {
        passedIn.add(addtl);
      }
    }
  }
  if (fixupMode == FixupVarMode.REBUILD) {
    continuation.setPassedVars(passedIn);
  }
 else {
    assert(fixupMode == FixupVarMode.ADD);
    Collection<PassedVar> newPassedVars;
    Collection<PassedVar> oldPassedVars=continuation.getPassedVars();
    newPassedVars=PassedVar.mergeLists(passedIn,oldPassedVars);
    continuation.setPassedVars(newPassedVars);
  }
}