Program: 85303
Project: 85303
Buggy source:
/** 
 * Read in the program facts generated by SPARK. We also construct our own call graph and pointer variables.
 */
private void preprocess(){
  int id;
  int s, t;
  n_func=Scene.v().getReachableMethods().size() + 1;
  call_graph=new CgEdge[n_func];
  n_calls=0;
  n_reach_spark_user_methods=0;
  id=1;
  QueueReader<MethodOrMethodContext> smList=Scene.v().getReachableMethods().listener();
  CallGraph soot_callgraph=Scene.v().getCallGraph();
  while (smList.hasNext()) {
    final SootMethod func=(SootMethod)smList.next();
    func2int.put(func,id);
    int2func.put(id,func);
    if (soot_callgraph.isEntryMethod(func) || func.isEntryMethod()) {
      CgEdge p=new CgEdge(Constants.SUPER_MAIN,id,null,call_graph[Constants.SUPER_MAIN]);
      call_graph[Constants.SUPER_MAIN]=p;
      n_calls++;
    }
    if (!func.isJavaLibraryMethod())     ++n_reach_spark_user_methods;
    id++;
  }
  QueueReader<Edge> edgeList=Scene.v().getCallGraph().listener();
  while (edgeList.hasNext()) {
    Edge edge=edgeList.next();
    if (edge.isClinit()) {
      continue;
    }
    SootMethod src_func=edge.src();
    SootMethod tgt_func=edge.tgt();
    s=func2int.get(src_func);
    t=func2int.get(tgt_func);
    CgEdge p=new CgEdge(s,t,edge,call_graph[s]);
    call_graph[s]=p;
    edgeMapping.put(edge,p);
    Stmt callsite=edge.srcStmt();
    if (edge.isThreadRunCall() || edge.kind().isExecutor() || edge.kind().isAsyncTask()) {
      thread_run_callsites.add(callsite);
    }
 else     if (edge.isInstance() && !edge.isSpecial()) {
      InstanceInvokeExpr expr=(InstanceInvokeExpr)callsite.getInvokeExpr();
      p.base_var=findLocalVarNode(expr.getBase());
      if (SootInfo.countCallEdgesForCallsite(callsite,true) > 1 && p.base_var != null) {
        multiCallsites.add(callsite);
      }
    }
    ++n_calls;
  }
  for (Iterator<VarNode> it=getVarNodeNumberer().iterator(); it.hasNext(); ) {
    VarNode vn=it.next();
    IVarAbstraction pn=makeInternalNode(vn);
    pointers.add(pn);
  }
  for (Iterator<AllocDotField> it=getAllocDotFieldNodeNumberer().iterator(); it.hasNext(); ) {
    AllocDotField adf=it.next();
    SparkField field=adf.getField();
    if (field instanceof SootField) {
      Type decType=((SootField)field).getDeclaringClass().getType();
      Type baseType=adf.getBase().getType();
      if (!castNeverFails(baseType,decType))       continue;
    }
    IVarAbstraction pn=makeInternalNode(adf);
    pointers.add(pn);
  }
  for (Iterator<AllocNode> it=getAllocNodeNumberer().iterator(); it.hasNext(); ) {
    AllocNode obj=it.next();
    IVarAbstraction pn=makeInternalNode(obj);
    allocations.add(pn);
  }
  for (  Object object : allocSources()) {
    IVarAbstraction obj=makeInternalNode((AllocNode)object);
    Node[] succs=allocLookup((AllocNode)object);
    for (    Node element0 : succs) {
      PlainConstraint cons=new PlainConstraint();
      IVarAbstraction p=makeInternalNode(element0);
      cons.expr.setPair(obj,p);
      cons.type=Constants.NEW_CONS;
      constraints.add(cons);
    }
  }
  Pair<Node,Node> intercall=new Pair<Node,Node>();
  for (  Object object : simpleSources()) {
    IVarAbstraction p=makeInternalNode((VarNode)object);
    Node[] succs=simpleLookup((VarNode)object);
    for (    Node element0 : succs) {
      PlainConstraint cons=new PlainConstraint();
      IVarAbstraction q=makeInternalNode(element0);
      cons.expr.setPair(p,q);
      cons.type=Constants.ASSIGN_CONS;
      intercall.setPair((VarNode)object,element0);
      cons.interCallEdges=lookupEdgesForAssignment(intercall);
      constraints.add(cons);
    }
  }
  intercall=null;
  assign2edges.clear();
  for (  Object object : loadSources()) {
    FieldRefNode frn=(FieldRefNode)object;
    IVarAbstraction p=makeInternalNode(frn.getBase());
    Node[] succs=loadLookup(frn);
    for (    Node element0 : succs) {
      PlainConstraint cons=new PlainConstraint();
      IVarAbstraction q=makeInternalNode(element0);
      cons.f=frn.getField();
      cons.expr.setPair(p,q);
      cons.type=Constants.LOAD_CONS;
      constraints.add(cons);
    }
  }
  for (  Object object : storeSources()) {
    IVarAbstraction p=makeInternalNode((VarNode)object);
    Node[] succs=storeLookup((VarNode)object);
    for (    Node element0 : succs) {
      PlainConstraint cons=new PlainConstraint();
      FieldRefNode frn=(FieldRefNode)element0;
      IVarAbstraction q=makeInternalNode(frn.getBase());
      cons.f=frn.getField();
      cons.expr.setPair(p,q);
      cons.type=Constants.STORE_CONS;
      constraints.add(cons);
    }
  }
  n_init_constraints=constraints.size();
  low_cg=new int[n_func];
  vis_cg=new int[n_func];
  rep_cg=new int[n_func];
  indeg_cg=new int[n_func];
  scc_size=new int[n_func];
  block_num=new int[n_func];
  context_size=new long[n_func];
  max_context_size_block=new long[n_func];
}

Fixed version (ground truth):
/** 
 * Read in the program facts generated by SPARK. We also construct our own call graph and pointer variables.
 */
private void preprocess(){
  int id;
  int s, t;
  n_func=Scene.v().getReachableMethods().size() + 1;
  call_graph=new CgEdge[n_func];
  n_calls=0;
  n_reach_spark_user_methods=0;
  id=1;
  QueueReader<MethodOrMethodContext> smList=Scene.v().getReachableMethods().listener();
  CallGraph soot_callgraph=Scene.v().getCallGraph();
  while (smList.hasNext()) {
    final SootMethod func=(SootMethod)smList.next();
    func2int.put(func,id);
    int2func.put(id,func);
    if (soot_callgraph.isEntryMethod(func) || func.isEntryMethod()) {
      CgEdge p=new CgEdge(Constants.SUPER_MAIN,id,null,call_graph[Constants.SUPER_MAIN]);
      call_graph[Constants.SUPER_MAIN]=p;
      n_calls++;
    }
    if (!func.isJavaLibraryMethod())     ++n_reach_spark_user_methods;
    id++;
  }
  QueueReader<Edge> edgeList=Scene.v().getCallGraph().listener();
  while (edgeList.hasNext()) {
    Edge edge=edgeList.next();
    if (edge.isClinit()) {
      continue;
    }
    SootMethod src_func=edge.src();
    SootMethod tgt_func=edge.tgt();
    s=func2int.get(src_func);
    t=func2int.get(tgt_func);
    CgEdge p=new CgEdge(s,t,edge,call_graph[s]);
    call_graph[s]=p;
    edgeMapping.put(edge,p);
    Stmt callsite=edge.srcStmt();
    if (edge.isThreadRunCall() || edge.kind().isExecutor() || edge.kind().isAsyncTask()) {
      thread_run_callsites.add(callsite);
    }
 else     if (edge.isInstance() && !edge.isSpecial()) {
      InstanceInvokeExpr expr=(InstanceInvokeExpr)callsite.getInvokeExpr();
      if (expr.getMethodRef().getSignature().contains("String_Node_Str")) {
        thread_run_callsites.add(callsite);
      }
 else {
        p.base_var=findLocalVarNode(expr.getBase());
        if (SootInfo.countCallEdgesForCallsite(callsite,true) > 1 && p.base_var != null) {
          multiCallsites.add(callsite);
        }
      }
    }
    ++n_calls;
  }
  for (Iterator<VarNode> it=getVarNodeNumberer().iterator(); it.hasNext(); ) {
    VarNode vn=it.next();
    IVarAbstraction pn=makeInternalNode(vn);
    pointers.add(pn);
  }
  for (Iterator<AllocDotField> it=getAllocDotFieldNodeNumberer().iterator(); it.hasNext(); ) {
    AllocDotField adf=it.next();
    SparkField field=adf.getField();
    if (field instanceof SootField) {
      Type decType=((SootField)field).getDeclaringClass().getType();
      Type baseType=adf.getBase().getType();
      if (!castNeverFails(baseType,decType))       continue;
    }
    IVarAbstraction pn=makeInternalNode(adf);
    pointers.add(pn);
  }
  for (Iterator<AllocNode> it=getAllocNodeNumberer().iterator(); it.hasNext(); ) {
    AllocNode obj=it.next();
    IVarAbstraction pn=makeInternalNode(obj);
    allocations.add(pn);
  }
  for (  Object object : allocSources()) {
    IVarAbstraction obj=makeInternalNode((AllocNode)object);
    Node[] succs=allocLookup((AllocNode)object);
    for (    Node element0 : succs) {
      PlainConstraint cons=new PlainConstraint();
      IVarAbstraction p=makeInternalNode(element0);
      cons.expr.setPair(obj,p);
      cons.type=Constants.NEW_CONS;
      constraints.add(cons);
    }
  }
  Pair<Node,Node> intercall=new Pair<Node,Node>();
  for (  Object object : simpleSources()) {
    IVarAbstraction p=makeInternalNode((VarNode)object);
    Node[] succs=simpleLookup((VarNode)object);
    for (    Node element0 : succs) {
      PlainConstraint cons=new PlainConstraint();
      IVarAbstraction q=makeInternalNode(element0);
      cons.expr.setPair(p,q);
      cons.type=Constants.ASSIGN_CONS;
      intercall.setPair((VarNode)object,element0);
      cons.interCallEdges=lookupEdgesForAssignment(intercall);
      constraints.add(cons);
    }
  }
  intercall=null;
  assign2edges.clear();
  for (  Object object : loadSources()) {
    FieldRefNode frn=(FieldRefNode)object;
    IVarAbstraction p=makeInternalNode(frn.getBase());
    Node[] succs=loadLookup(frn);
    for (    Node element0 : succs) {
      PlainConstraint cons=new PlainConstraint();
      IVarAbstraction q=makeInternalNode(element0);
      cons.f=frn.getField();
      cons.expr.setPair(p,q);
      cons.type=Constants.LOAD_CONS;
      constraints.add(cons);
    }
  }
  for (  Object object : storeSources()) {
    IVarAbstraction p=makeInternalNode((VarNode)object);
    Node[] succs=storeLookup((VarNode)object);
    for (    Node element0 : succs) {
      PlainConstraint cons=new PlainConstraint();
      FieldRefNode frn=(FieldRefNode)element0;
      IVarAbstraction q=makeInternalNode(frn.getBase());
      cons.f=frn.getField();
      cons.expr.setPair(p,q);
      cons.type=Constants.STORE_CONS;
      constraints.add(cons);
    }
  }
  n_init_constraints=constraints.size();
  low_cg=new int[n_func];
  vis_cg=new int[n_func];
  rep_cg=new int[n_func];
  indeg_cg=new int[n_func];
  scc_size=new int[n_func];
  block_num=new int[n_func];
  context_size=new long[n_func];
  max_context_size_block=new long[n_func];
}