Program: 133199
Project: 133199
Buggy source:
private void callFunction(Context context,String function,FunctionType concrete,List<Var> oList,List<Var> iList,Var priorityVal) throws UndefinedTypeException, UserException {
  ArrayList<Var> realIList=new ArrayList<Var>(iList.size());
  ArrayList<Var> derefVars=new ArrayList<Var>();
  ArrayList<Var> waitVars=new ArrayList<Var>();
  Context waitContext=null;
  assert(concrete.getInputs().size() == iList.size());
  for (int i=0; i < iList.size(); i++) {
    Var input=iList.get(i);
    Type inputType=input.type();
    Type expType=concrete.getInputs().get(i);
    if (inputType.getImplType().equals(expType)) {
      realIList.add(input);
    }
 else     if (Types.isRefTo(inputType,expType)) {
      if (waitContext == null) {
        waitContext=new LocalContext(context);
      }
      Var derefed;
      derefed=waitContext.createAliasVariable(expType);
      waitVars.add(input);
      derefVars.add(derefed);
      realIList.add(derefed);
    }
 else     if (Types.isUpdateableEquiv(inputType,expType)) {
      realIList.add(snapshotUpdateable(context,input));
    }
 else {
      throw new STCRuntimeError(context.getFileLine() + "String_Node_Str" + "String_Node_Str"+ inputType.toString()+ "String_Node_Str"+ expType.toString());
    }
  }
  ArrayList<Var> usedVars=null;
  if (waitContext != null) {
    FunctionContext fc=context.getFunctionContext();
    usedVars=new ArrayList<Var>();
    usedVars.addAll(iList);
    usedVars.addAll(oList);
    backend.startWaitStatement(fc.constructName("String_Node_Str" + function),waitVars,usedVars,new ArrayList<Var>(),WaitMode.DATA_ONLY,false,TaskMode.LOCAL);
    assert(waitVars.size() == derefVars.size());
    for (int i=0; i < waitVars.size(); i++) {
      Var derefVar=derefVars.get(i);
      varCreator.declare(derefVar);
      if (Types.isArrayRef(waitVars.get(i).type())) {
        backend.retrieveRef(derefVar,waitVars.get(i));
      }
 else {
        throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + derefVar);
      }
    }
  }
  backendFunctionCall(context,function,oList,realIList,priorityVal);
  if (waitContext != null) {
    backend.endWaitStatement(usedVars,new ArrayList<Var>());
  }
}

Fixed version (ground truth):
private void callFunction(Context context,String function,FunctionType concrete,List<Var> oList,List<Var> iList,Var priorityVal) throws UndefinedTypeException, UserException {
  ArrayList<Var> realIList=new ArrayList<Var>(iList.size());
  ArrayList<Var> derefVars=new ArrayList<Var>();
  ArrayList<Var> waitVars=new ArrayList<Var>();
  Context waitContext=null;
  assert(concrete.getInputs().size() == iList.size());
  for (int i=0; i < iList.size(); i++) {
    Var input=iList.get(i);
    Type inputType=input.type();
    Type expType=concrete.getInputs().get(i);
    if (inputType.getImplType().equals(expType.getImplType())) {
      realIList.add(input);
    }
 else     if (Types.isRefTo(inputType,expType)) {
      if (waitContext == null) {
        waitContext=new LocalContext(context);
      }
      Var derefed;
      derefed=waitContext.createAliasVariable(expType);
      waitVars.add(input);
      derefVars.add(derefed);
      realIList.add(derefed);
    }
 else     if (Types.isUpdateableEquiv(inputType,expType)) {
      realIList.add(snapshotUpdateable(context,input));
    }
 else {
      throw new STCRuntimeError(context.getFileLine() + "String_Node_Str" + "String_Node_Str"+ inputType.toString()+ "String_Node_Str"+ expType.toString());
    }
  }
  ArrayList<Var> usedVars=null;
  if (waitContext != null) {
    FunctionContext fc=context.getFunctionContext();
    usedVars=new ArrayList<Var>();
    usedVars.addAll(iList);
    usedVars.addAll(oList);
    backend.startWaitStatement(fc.constructName("String_Node_Str" + function),waitVars,usedVars,new ArrayList<Var>(),WaitMode.DATA_ONLY,false,TaskMode.LOCAL);
    assert(waitVars.size() == derefVars.size());
    for (int i=0; i < waitVars.size(); i++) {
      Var derefVar=derefVars.get(i);
      varCreator.declare(derefVar);
      if (Types.isArrayRef(waitVars.get(i).type())) {
        backend.retrieveRef(derefVar,waitVars.get(i));
      }
 else {
        throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + derefVar);
      }
    }
  }
  backendFunctionCall(context,function,oList,realIList,priorityVal);
  if (waitContext != null) {
    backend.endWaitStatement(usedVars,new ArrayList<Var>());
  }
}