Program: 100160
Project: 100160
Buggy source:
/** 
 * handle flow from return value to callers, or from actual to formals
 * @param curPkAndState
 * @param handler
 */
private void handleBackInterproc(final PointerKeyAndState curPkAndState,final CopyHandler handler,final boolean addGraphs){
  final PointerKey curPk=curPkAndState.getPointerKey();
  final State curState=curPkAndState.getState();
  if (curPk instanceof ReturnValueKey) {
    final ReturnValueKey returnKey=(ReturnValueKey)curPk;
    if (DEBUG) {
      Trace.println("String_Node_Str");
    }
    final CGNode callee=returnKey.getNode();
    if (DEBUG) {
      Trace.println("String_Node_Str" + callee);
    }
    final boolean isExceptional=returnKey instanceof ExceptionReturnValueKey;
    for (    final CallSiteAndCGNode callSiteAndCGNode : g.getPotentialCallers(returnKey)) {
      final CGNode caller=callSiteAndCGNode.getCGNode();
      final IR ir=getIR(caller);
      if (ir == null)       continue;
      final CallSiteReference call=callSiteAndCGNode.getCallSiteReference();
      if (!addGraphs) {
        if (!g.hasSubgraphForNode(caller)) {
          continue;
        }
      }
      final ReturnBarLabel returnBarLabel=ReturnBarLabel.make(callSiteAndCGNode);
      doTransition(curState,returnBarLabel,new Function<State,Object>(){
        private void propagateToCaller(){
          g.addSubgraphForNode(caller);
          SSAAbstractInvokeInstruction[] callInstrs=ir.getCalls(call);
          for (int i=0; i < callInstrs.length; i++) {
            SSAAbstractInvokeInstruction callInstr=callInstrs[i];
            PointerKey returnAtCallerKey=heapModel.getPointerKeyForLocal(caller,isExceptional ? callInstr.getException() : callInstr.getDef());
            if (Assertions.verifyAssertions) {
              Assertions._assert(g.containsNode(returnAtCallerKey));
              Assertions._assert(g.containsNode(returnKey));
            }
            handler.handle(curPkAndState,returnAtCallerKey,returnBarLabel);
          }
        }
        public Object apply(        State callerState){
          Set<CGNode> possibleTargets=g.getPossibleTargets(caller,call);
          if (noOnTheFlyNeeded(callSiteAndCGNode,possibleTargets)) {
            propagateToCaller();
          }
 else {
            if (callToOTFTargets.get(callSiteAndCGNode).contains(callee.getMethod())) {
              propagateToCaller();
            }
 else {
              queryCallTargets(callSiteAndCGNode,ir,callerState);
            }
          }
          return null;
        }
      }
);
    }
  }
  if (curPk instanceof LocalPointerKey) {
    LocalPointerKey localPk=(LocalPointerKey)curPk;
    CGNode caller=localPk.getNode();
    for (Iterator<SSAInvokeInstruction> iter=g.getInstrsPassingParam(localPk); iter.hasNext(); ) {
      SSAInvokeInstruction callInstr=iter.next();
      for (int i=0; i < callInstr.getNumberOfUses(); i++) {
        if (localPk.getValueNumber() != callInstr.getUse(i))         continue;
        CallSiteReference callSiteRef=callInstr.getCallSite();
        CallSiteAndCGNode callSiteAndCGNode=new CallSiteAndCGNode(callSiteRef,caller);
        Set<CGNode> possibleCallees=g.getPossibleTargets(caller,callSiteRef);
        if (noOnTheFlyNeeded(callSiteAndCGNode,possibleCallees)) {
          for (          CGNode callee : possibleCallees) {
            if (!addGraphs) {
              if (!g.hasSubgraphForNode(callee)) {
                continue;
              }
            }
            if (callee.getIR() == null) {
              continue;
            }
            g.addSubgraphForNode(callee);
            PointerKey paramVal=heapModel.getPointerKeyForLocal(callee,i + 1);
            if (Assertions.verifyAssertions) {
              Assertions._assert(g.containsNode(paramVal));
            }
            handler.handle(curPkAndState,paramVal,ParamBarLabel.make(callSiteAndCGNode));
          }
        }
 else {
          if (callToOTFTargets.containsKey(callSiteAndCGNode)) {
            Set<IMethod> targetMethods=callToOTFTargets.get(callSiteAndCGNode);
            for (            CGNode callee : possibleCallees) {
              if (targetMethods.contains(callee.getMethod())) {
                if (caller.getIR() == null) {
                  continue;
                }
                g.addSubgraphForNode(callee);
                PointerKey paramVal=heapModel.getPointerKeyForLocal(callee,i + 1);
                if (Assertions.verifyAssertions) {
                  Assertions._assert(g.containsNode(paramVal));
                }
                handler.handle(curPkAndState,paramVal,ParamBarLabel.make(callSiteAndCGNode));
              }
            }
          }
 else {
            queryCallTargets(callSiteAndCGNode,getIR(caller),curState);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * handle flow from return value to callers, or from actual to formals
 * @param curPkAndState
 * @param handler
 */
private void handleBackInterproc(final PointerKeyAndState curPkAndState,final CopyHandler handler,final boolean addGraphs){
  final PointerKey curPk=curPkAndState.getPointerKey();
  final State curState=curPkAndState.getState();
  if (curPk instanceof ReturnValueKey) {
    final ReturnValueKey returnKey=(ReturnValueKey)curPk;
    if (DEBUG) {
      Trace.println("String_Node_Str");
    }
    final CGNode callee=returnKey.getNode();
    if (DEBUG) {
      Trace.println("String_Node_Str" + callee);
    }
    final boolean isExceptional=returnKey instanceof ExceptionReturnValueKey;
    for (    final CallSiteAndCGNode callSiteAndCGNode : g.getPotentialCallers(returnKey)) {
      final CGNode caller=callSiteAndCGNode.getCGNode();
      final IR ir=getIR(caller);
      if (ir == null)       continue;
      final CallSiteReference call=callSiteAndCGNode.getCallSiteReference();
      if (!addGraphs) {
        if (!g.hasSubgraphForNode(caller)) {
          continue;
        }
      }
      final ReturnBarLabel returnBarLabel=ReturnBarLabel.make(callSiteAndCGNode);
      doTransition(curState,returnBarLabel,new Function<State,Object>(){
        private void propagateToCaller(){
          g.addSubgraphForNode(caller);
          SSAAbstractInvokeInstruction[] callInstrs=ir.getCalls(call);
          for (int i=0; i < callInstrs.length; i++) {
            SSAAbstractInvokeInstruction callInstr=callInstrs[i];
            PointerKey returnAtCallerKey=heapModel.getPointerKeyForLocal(caller,isExceptional ? callInstr.getException() : callInstr.getDef());
            if (Assertions.verifyAssertions) {
              Assertions._assert(g.containsNode(returnAtCallerKey));
              Assertions._assert(g.containsNode(returnKey));
            }
            handler.handle(curPkAndState,returnAtCallerKey,returnBarLabel);
          }
        }
        public Object apply(        State callerState){
          SSAAbstractInvokeInstruction callInstr=ir.getCalls(call)[0];
          PointerKey returnAtCallerKey=heapModel.getPointerKeyForLocal(caller,isExceptional ? callInstr.getException() : callInstr.getDef());
          Set<CGNode> possibleTargets=g.getPossibleTargets(caller,call,(LocalPointerKey)returnAtCallerKey);
          if (noOnTheFlyNeeded(callSiteAndCGNode,possibleTargets)) {
            propagateToCaller();
          }
 else {
            if (callToOTFTargets.get(callSiteAndCGNode).contains(callee.getMethod())) {
              propagateToCaller();
            }
 else {
              queryCallTargets(callSiteAndCGNode,ir,callerState);
            }
          }
          return null;
        }
      }
);
    }
  }
  if (curPk instanceof LocalPointerKey) {
    LocalPointerKey localPk=(LocalPointerKey)curPk;
    CGNode caller=localPk.getNode();
    for (Iterator<SSAInvokeInstruction> iter=g.getInstrsPassingParam(localPk); iter.hasNext(); ) {
      SSAInvokeInstruction callInstr=iter.next();
      for (int i=0; i < callInstr.getNumberOfUses(); i++) {
        if (localPk.getValueNumber() != callInstr.getUse(i))         continue;
        CallSiteReference callSiteRef=callInstr.getCallSite();
        CallSiteAndCGNode callSiteAndCGNode=new CallSiteAndCGNode(callSiteRef,caller);
        Set<CGNode> possibleCallees=g.getPossibleTargets(caller,callSiteRef,localPk);
        if (noOnTheFlyNeeded(callSiteAndCGNode,possibleCallees)) {
          for (          CGNode callee : possibleCallees) {
            if (!addGraphs) {
              if (!g.hasSubgraphForNode(callee)) {
                continue;
              }
            }
            if (callee.getIR() == null) {
              continue;
            }
            g.addSubgraphForNode(callee);
            PointerKey paramVal=heapModel.getPointerKeyForLocal(callee,i + 1);
            if (Assertions.verifyAssertions) {
              Assertions._assert(g.containsNode(paramVal));
            }
            handler.handle(curPkAndState,paramVal,ParamBarLabel.make(callSiteAndCGNode));
          }
        }
 else {
          if (callToOTFTargets.containsKey(callSiteAndCGNode)) {
            Set<IMethod> targetMethods=callToOTFTargets.get(callSiteAndCGNode);
            for (            CGNode callee : possibleCallees) {
              if (targetMethods.contains(callee.getMethod())) {
                if (caller.getIR() == null) {
                  continue;
                }
                g.addSubgraphForNode(callee);
                PointerKey paramVal=heapModel.getPointerKeyForLocal(callee,i + 1);
                if (Assertions.verifyAssertions) {
                  Assertions._assert(g.containsNode(paramVal));
                }
                handler.handle(curPkAndState,paramVal,ParamBarLabel.make(callSiteAndCGNode));
              }
            }
          }
 else {
            queryCallTargets(callSiteAndCGNode,getIR(caller),curState);
          }
        }
      }
    }
  }
}