Program: 132839
Project: 132839
Buggy source:
private void piggybackDecrementsOnInstructions(Logger logger,Function fn,Block block,final RCTracker tracker,final RefCountType rcType){
  final Counters<Var> candidates=tracker.getVarCandidates(block,rcType,RCDir.DECR);
  UseFinder subblockWalker=new UseFinder(tracker,rcType,candidates.keySet(),null);
  ListIterator<Continuation> cit=block.continuationEndIterator();
  while (cit.hasPrevious()) {
    Continuation cont=cit.previous();
    if (RCUtil.isAsyncForeachLoop(cont)) {
      AbstractForeachLoop loop=(AbstractForeachLoop)cont;
      List<Var> piggybacked=loop.tryPiggyBack(candidates,rcType,true);
      for (      Var pv : piggybacked) {
        logger.trace("String_Node_Str" + pv + "String_Node_Str"+ rcType+ "String_Node_Str"+ candidates.getCount(pv));
      }
      candidates.resetAll(piggybacked);
      tracker.resetAll(rcType,piggybacked,RCDir.DECR);
    }
    subblockWalker.reset();
    TreeWalk.walkSyncChildren(logger,fn,cont,subblockWalker);
    removeCandidates(subblockWalker.getUsedVars(),tracker,candidates.keySet());
  }
  List<Var> successful=new ArrayList<Var>();
  ListIterator<Statement> it=block.statementEndIterator();
  while (it.hasPrevious()) {
    Statement stmt=it.previous();
switch (stmt.type()) {
case INSTRUCTION:
{
        Instruction inst=stmt.instruction();
        List<Var> piggybacked=inst.tryPiggyback(candidates,rcType);
        candidates.resetAll(piggybacked);
        successful.addAll(piggybacked);
        List<Var> used=findUses(inst,rcType,candidates.keySet());
        removeCandidates(used,tracker,candidates.keySet());
        break;
      }
case CONDITIONAL:
    subblockWalker.reset();
  TreeWalk.walkSyncChildren(logger,fn,stmt.conditional(),subblockWalker);
removeCandidates(subblockWalker.getUsedVars(),tracker,candidates.keySet());
break;
default :
throw new STCRuntimeError("String_Node_Str" + stmt.type());
}
}
for (Var v : successful) {
assert(v != null);
tracker.reset(rcType,v);
}
}

Fixed version (ground truth):
private void piggybackDecrementsOnInstructions(Logger logger,Function fn,Block block,final RCTracker tracker,final RefCountType rcType){
  final Counters<Var> candidates=tracker.getVarCandidates(block,rcType,RCDir.DECR);
  UseFinder subblockWalker=new UseFinder(tracker,rcType,candidates.keySet(),null);
  ListIterator<Continuation> cit=block.continuationEndIterator();
  while (cit.hasPrevious()) {
    Continuation cont=cit.previous();
    if (RCUtil.isAsyncForeachLoop(cont)) {
      AbstractForeachLoop loop=(AbstractForeachLoop)cont;
      List<Var> piggybacked=loop.tryPiggyBack(candidates,rcType,RCDir.DECR);
      for (      Var pv : piggybacked) {
        logger.trace("String_Node_Str" + pv + "String_Node_Str"+ rcType+ "String_Node_Str"+ candidates.getCount(pv));
      }
      candidates.resetAll(piggybacked);
      tracker.resetAll(rcType,piggybacked,RCDir.DECR);
    }
    subblockWalker.reset();
    TreeWalk.walkSyncChildren(logger,fn,cont,subblockWalker);
    removeCandidates(subblockWalker.getUsedVars(),tracker,candidates.keySet());
  }
  List<Var> successful=new ArrayList<Var>();
  ListIterator<Statement> it=block.statementEndIterator();
  while (it.hasPrevious()) {
    Statement stmt=it.previous();
switch (stmt.type()) {
case INSTRUCTION:
{
        Instruction inst=stmt.instruction();
        List<Var> piggybacked=inst.tryPiggyback(candidates,rcType);
        if (piggybacked.size() > 0 && logger.isTraceEnabled()) {
          logger.trace("String_Node_Str" + piggybacked + "String_Node_Str"+ inst);
        }
        candidates.resetAll(piggybacked);
        successful.addAll(piggybacked);
        List<Var> used=findUses(inst,rcType,candidates.keySet());
        removeCandidates(used,tracker,candidates.keySet());
        break;
      }
case CONDITIONAL:
    subblockWalker.reset();
  TreeWalk.walkSyncChildren(logger,fn,stmt.conditional(),subblockWalker);
removeCandidates(subblockWalker.getUsedVars(),tracker,candidates.keySet());
break;
default :
throw new STCRuntimeError("String_Node_Str" + stmt.type());
}
}
for (Var v : successful) {
assert(v != null);
tracker.reset(rcType,v);
}
}