Program: 132858
Project: 132858
Buggy source:
/** 
 * Internal helper to implement constructs that need to wait for a number of variables, and then run some code
 * @param procName
 * @param waitVars
 * @param passIn
 * @param keepOpenVars
 * @param priority 
 * @param recursive
 */
private void startAsync(String procName,List<Var> waitVars,List<Var> passIn,boolean recursive,TaskMode mode,TaskProps props){
  props.assertInternalTypesValid();
  mode.checkSpawn(execContextStack.peek());
  for (  Var v : passIn) {
    if (Types.isBlobVal(v)) {
      throw new STCRuntimeError("String_Node_Str");
    }
  }
  List<String> args=new ArrayList<String>();
  args.add(Turbine.LOCAL_STACK_NAME);
  for (  Var v : passIn) {
    args.add(prefixVar(v));
  }
  Sequence constructProc=new Sequence();
  String uniqueName=uniqueTCLFunctionName(procName);
  Proc proc=new Proc(uniqueName,usedTclFunctionNames,args,constructProc);
  tree.add(proc);
  boolean useDeepWait=false;
  List<Expression> waitFor=new ArrayList<Expression>();
  for (  Var w : waitVars) {
    if (recursive) {
      Type baseType=w.type();
      if (Types.isArray(w.type()) || Types.isBag(w.type())) {
        baseType=new NestedContainerInfo(w.type()).baseType;
        useDeepWait=true;
      }
      if (Types.isPrimFuture(baseType)) {
      }
 else       if (Types.isRef(baseType)) {
      }
 else {
        throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + w.type().typeName());
      }
    }
    Expression waitExpr=getTurbineWaitId(w);
    waitFor.add(waitExpr);
  }
  List<Expression> action=buildActionFromVars(uniqueName,passIn);
  RuleProps ruleProps=buildRuleProps(props);
  if (useDeepWait) {
    int depths[]=new int[waitVars.size()];
    boolean isFile[]=new boolean[waitVars.size()];
    for (int i=0; i < waitVars.size(); i++) {
      Type waitVarType=waitVars.get(i).type();
      Type baseType;
      if (Types.isArray(waitVarType)) {
        NestedContainerInfo ai=new NestedContainerInfo(waitVarType);
        depths[i]=ai.nesting;
        baseType=ai.baseType;
      }
 else {
        depths[i]=0;
        baseType=waitVarType;
      }
      isFile[i]=Types.isFile(baseType);
    }
    Sequence rule=Turbine.deepRule(uniqueName,waitFor,depths,isFile,action,mode,execContextStack.peek(),ruleProps);
    point().append(rule);
  }
 else {
    point().append(Turbine.rule(uniqueName,waitFor,action,mode,execContextStack.peek(),ruleProps));
  }
  pointStack.push(constructProc);
  ExecContext newExecContext;
  if (mode == TaskMode.WORKER) {
    newExecContext=ExecContext.WORKER;
  }
 else   if (mode == TaskMode.CONTROL) {
    newExecContext=ExecContext.CONTROL;
  }
 else {
    newExecContext=execContextStack.peek();
  }
  execContextStack.push(newExecContext);
}

Fixed version (ground truth):
/** 
 * Internal helper to implement constructs that need to wait for a number of variables, and then run some code
 * @param procName
 * @param waitVars
 * @param passIn
 * @param keepOpenVars
 * @param priority 
 * @param recursive
 */
private void startAsync(String procName,List<Var> waitVars,List<Var> passIn,boolean recursive,TaskMode mode,TaskProps props){
  props.assertInternalTypesValid();
  mode.checkSpawn(execContextStack.peek());
  for (  Var v : passIn) {
    if (Types.isBlobVal(v)) {
      throw new STCRuntimeError("String_Node_Str");
    }
  }
  List<String> args=new ArrayList<String>();
  args.add(Turbine.LOCAL_STACK_NAME);
  for (  Var v : passIn) {
    args.add(prefixVar(v));
  }
  Sequence constructProc=new Sequence();
  String uniqueName=uniqueTCLFunctionName(procName);
  Proc proc=new Proc(uniqueName,usedTclFunctionNames,args,constructProc);
  tree.add(proc);
  boolean useDeepWait=false;
  List<Expression> waitFor=new ArrayList<Expression>();
  for (  Var w : waitVars) {
    if (recursive) {
      Type baseType=w.type();
      if (Types.isArray(w.type()) || Types.isBag(w.type())) {
        baseType=new NestedContainerInfo(w.type()).baseType;
        useDeepWait=true;
      }
      if (Types.isPrimFuture(baseType)) {
      }
 else       if (Types.isRef(baseType)) {
      }
 else {
        throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + w.type().typeName());
      }
    }
    Expression waitExpr=getTurbineWaitId(w);
    waitFor.add(waitExpr);
  }
  List<Expression> action=buildActionFromVars(uniqueName,passIn);
  RuleProps ruleProps=buildRuleProps(props);
  if (useDeepWait) {
    int depths[]=new int[waitVars.size()];
    boolean isFile[]=new boolean[waitVars.size()];
    for (int i=0; i < waitVars.size(); i++) {
      Type waitVarType=waitVars.get(i).type();
      Type baseType;
      if (Types.isContainer(waitVarType)) {
        NestedContainerInfo ai=new NestedContainerInfo(waitVarType);
        depths[i]=ai.nesting;
        baseType=ai.baseType;
      }
 else {
        depths[i]=0;
        baseType=waitVarType;
      }
      isFile[i]=Types.isFile(baseType);
    }
    Sequence rule=Turbine.deepRule(uniqueName,waitFor,depths,isFile,action,mode,execContextStack.peek(),ruleProps);
    point().append(rule);
  }
 else {
    point().append(Turbine.rule(uniqueName,waitFor,action,mode,execContextStack.peek(),ruleProps));
  }
  pointStack.push(constructProc);
  ExecContext newExecContext;
  if (mode == TaskMode.WORKER) {
    newExecContext=ExecContext.WORKER;
  }
 else   if (mode == TaskMode.CONTROL) {
    newExecContext=ExecContext.CONTROL;
  }
 else {
    newExecContext=execContextStack.peek();
  }
  execContextStack.push(newExecContext);
}