Program: 136010
Project: 136010
Buggy source:
/** 
 * Compute the set of the next states.  For each next state, check that it is a valid state, check that the invariants are satisfied, check that it satisfies the constraints, and enqueue it in the state queue. Return true if the model checking should stop. This method is called from the workers on every step
 */
public final boolean doNext(TLCState curState,ObjLongTable counts) throws Throwable {
  if (this.cancellationFlag) {
    return false;
  }
  boolean deadLocked=true;
  TLCState succState=null;
  StateVec liveNextStates=null;
  LongVec liveNextFPs=null;
  if (this.checkLiveness) {
    liveNextStates=new StateVec(2);
    liveNextFPs=new LongVec(2);
  }
  try {
    int k=0;
    for (int i=0; i < this.actions.length; i++) {
      if (this.cancellationFlag) {
        return false;
      }
      StateVec nextStates=this.tool.getNextStates(this.actions[i],curState);
      int sz=nextStates.size();
      this.incNumOfGenStates(sz);
      deadLocked=deadLocked && (sz == 0);
      for (int j=0; j < sz; j++) {
        succState=nextStates.elementAt(j);
        if (!this.tool.isGoodState(succState)) {
          if (this.setErrState(curState,succState,false)) {
            MP.printError(EC.TLC_STATE_NOT_COMPLETELY_SPECIFIED_NEXT);
            this.trace.printTrace(curState.uid,curState,succState);
            this.theStateQueue.finishAll();
synchronized (this) {
              this.notify();
            }
          }
          return true;
        }
        if (TLCGlobals.coverageInterval >= 0) {
          ((TLCStateMutSource)succState).addCounts(counts);
        }
        boolean inModel=(this.tool.isInModel(succState) && this.tool.isInActions(curState,succState));
        boolean seen=false;
        if (inModel) {
          long fp=succState.fingerPrint();
          seen=this.theFPSet.put(fp);
          if (!seen) {
            if (this.allStateWriter != null) {
              this.allStateWriter.writeState(succState);
            }
            long loc=this.trace.writeState(curState.uid,fp);
            succState.uid=loc;
            this.theStateQueue.sEnqueue(succState);
          }
          if (this.checkLiveness) {
            liveNextStates.addElement(succState);
            liveNextFPs.addElement(fp);
          }
        }
        if (!seen) {
          try {
            int len=this.invariants.length;
            for (k=0; k < len; k++) {
              if (this.cancellationFlag) {
                return false;
              }
              if (!tool.isValid(this.invariants[k],succState)) {
synchronized (this) {
                  if (TLCGlobals.continuation) {
                    MP.printError(EC.TLC_INVARIANT_VIOLATED_BEHAVIOR,this.tool.getInvNames()[k]);
                    this.trace.printTrace(curState.uid,curState,succState);
                    break;
                  }
 else {
                    if (this.setErrState(curState,succState,false)) {
                      MP.printError(EC.TLC_INVARIANT_VIOLATED_BEHAVIOR,this.tool.getInvNames()[k]);
                      this.trace.printTrace(curState.uid,curState,succState);
                      this.theStateQueue.finishAll();
                      this.notify();
                    }
                    return true;
                  }
                }
              }
            }
            if (k < len)             continue;
          }
 catch (          Exception e) {
            if (this.setErrState(curState,succState,true)) {
              MP.printError(EC.TLC_INVARIANT_EVALUATION_FAILED,new String[]{this.tool.getInvNames()[k],e.getMessage()});
              this.trace.printTrace(curState.uid,curState,succState);
              this.theStateQueue.finishAll();
              this.notify();
            }
            throw e;
          }
        }
        try {
          int len=this.impliedActions.length;
          for (k=0; k < len; k++) {
            if (this.cancellationFlag) {
              return false;
            }
            if (!tool.isValid(this.impliedActions[k],curState,succState)) {
synchronized (this) {
                if (TLCGlobals.continuation) {
                  MP.printError(EC.TLC_ACTION_PROPERTY_VIOLATED_BEHAVIOR,this.tool.getImpliedActNames()[k]);
                  this.trace.printTrace(curState.uid,curState,succState);
                  break;
                }
 else {
                  if (this.setErrState(curState,succState,false)) {
                    MP.printError(EC.TLC_ACTION_PROPERTY_VIOLATED_BEHAVIOR,this.tool.getImpliedActNames()[k]);
                    this.trace.printTrace(curState.uid,curState,succState);
                    this.theStateQueue.finishAll();
                    this.notify();
                  }
                  return true;
                }
              }
            }
          }
          if (k < len)           continue;
        }
 catch (        Exception e) {
          if (this.setErrState(curState,succState,true)) {
            MP.printError(EC.TLC_ACTION_PROPERTY_EVALUATION_FAILED,new String[]{this.tool.getImpliedActNames()[k],e.getMessage()});
            this.trace.printTrace(curState.uid,curState,succState);
            this.theStateQueue.finishAll();
            this.notify();
          }
          throw e;
        }
      }
      succState=null;
    }
    if (deadLocked && this.checkDeadlock) {
synchronized (this) {
        if (this.setErrState(curState,null,false)) {
          MP.printError(EC.TLC_DEADLOCK_REACHED);
          this.trace.printTrace(curState.uid,curState,null);
          this.theStateQueue.finishAll();
          this.notify();
        }
      }
      return true;
    }
    if (this.checkLiveness) {
      long curStateFP=curState.fingerPrint();
      liveNextStates.addElement(curState);
      liveNextFPs.addElement(curStateFP);
      LiveCheck.addNextState(curState,curStateFP,liveNextStates,liveNextFPs);
    }
    return false;
  }
 catch (  Throwable e) {
    boolean keep=((e instanceof StackOverflowError) || (e instanceof OutOfMemoryError));
synchronized (this) {
      if (this.setErrState(curState,succState,!keep)) {
        if (e instanceof StackOverflowError) {
          MP.printError(EC.SYSTEM_STACK_OVERFLOW);
        }
 else         if (e instanceof OutOfMemoryError) {
          MP.printError(EC.SYSTEM_OUT_OF_MEMORY);
        }
 else {
          MP.printError(EC.GENERAL,e.getMessage());
        }
        this.trace.printTrace(curState.uid,curState,succState);
        this.theStateQueue.finishAll();
        this.notify();
      }
    }
    throw e;
  }
}

Fixed version (ground truth):
/** 
 * Compute the set of the next states.  For each next state, check that it is a valid state, check that the invariants are satisfied, check that it satisfies the constraints, and enqueue it in the state queue. Return true if the model checking should stop. This method is called from the workers on every step
 */
public final boolean doNext(TLCState curState,ObjLongTable counts) throws Throwable {
  if (this.cancellationFlag) {
    return false;
  }
  boolean deadLocked=true;
  TLCState succState=null;
  StateVec liveNextStates=null;
  LongVec liveNextFPs=null;
  if (this.checkLiveness) {
    liveNextStates=new StateVec(2);
    liveNextFPs=new LongVec(2);
  }
  try {
    int k=0;
    for (int i=0; i < this.actions.length; i++) {
      if (this.cancellationFlag) {
        return false;
      }
      StateVec nextStates=this.tool.getNextStates(this.actions[i],curState);
      int sz=nextStates.size();
      this.incNumOfGenStates(sz);
      deadLocked=deadLocked && (sz == 0);
      for (int j=0; j < sz; j++) {
        succState=nextStates.elementAt(j);
        if (!this.tool.isGoodState(succState)) {
          if (this.setErrState(curState,succState,false)) {
            MP.printError(EC.TLC_STATE_NOT_COMPLETELY_SPECIFIED_NEXT);
            this.trace.printTrace(curState.uid,curState,succState);
            this.theStateQueue.finishAll();
synchronized (this) {
              this.notify();
            }
          }
          return true;
        }
        if (TLCGlobals.coverageInterval >= 0) {
          ((TLCStateMutSource)succState).addCounts(counts);
        }
        boolean inModel=(this.tool.isInModel(succState) && this.tool.isInActions(curState,succState));
        boolean seen=false;
        if (inModel) {
          long fp=succState.fingerPrint();
          seen=this.theFPSet.put(fp);
          if (!seen) {
            if (this.allStateWriter != null) {
              this.allStateWriter.writeState(succState);
            }
            long loc=this.trace.writeState(curState.uid,fp);
            succState.uid=loc;
            this.theStateQueue.sEnqueue(succState);
          }
          if (this.checkLiveness) {
            liveNextStates.addElement(succState);
            liveNextFPs.addElement(fp);
          }
        }
        if (!seen) {
          try {
            int len=this.invariants.length;
            for (k=0; k < len; k++) {
              if (this.cancellationFlag) {
                return false;
              }
              if (!tool.isValid(this.invariants[k],succState)) {
synchronized (this) {
                  if (TLCGlobals.continuation) {
                    MP.printError(EC.TLC_INVARIANT_VIOLATED_BEHAVIOR,this.tool.getInvNames()[k]);
                    this.trace.printTrace(curState.uid,curState,succState);
                    break;
                  }
 else {
                    if (this.setErrState(curState,succState,false)) {
                      MP.printError(EC.TLC_INVARIANT_VIOLATED_BEHAVIOR,this.tool.getInvNames()[k]);
                      this.trace.printTrace(curState.uid,curState,succState);
                      this.theStateQueue.finishAll();
                      this.notify();
                    }
                    return true;
                  }
                }
              }
            }
            if (k < len)             continue;
          }
 catch (          Exception e) {
            if (this.setErrState(curState,succState,true)) {
              MP.printError(EC.TLC_INVARIANT_EVALUATION_FAILED,new String[]{this.tool.getInvNames()[k],(e.getMessage() == null) ? e.toString() : e.getMessage()});
              this.trace.printTrace(curState.uid,curState,succState);
              this.theStateQueue.finishAll();
              this.notify();
            }
            throw e;
          }
        }
        try {
          int len=this.impliedActions.length;
          for (k=0; k < len; k++) {
            if (this.cancellationFlag) {
              return false;
            }
            if (!tool.isValid(this.impliedActions[k],curState,succState)) {
synchronized (this) {
                if (TLCGlobals.continuation) {
                  MP.printError(EC.TLC_ACTION_PROPERTY_VIOLATED_BEHAVIOR,this.tool.getImpliedActNames()[k]);
                  this.trace.printTrace(curState.uid,curState,succState);
                  break;
                }
 else {
                  if (this.setErrState(curState,succState,false)) {
                    MP.printError(EC.TLC_ACTION_PROPERTY_VIOLATED_BEHAVIOR,this.tool.getImpliedActNames()[k]);
                    this.trace.printTrace(curState.uid,curState,succState);
                    this.theStateQueue.finishAll();
                    this.notify();
                  }
                  return true;
                }
              }
            }
          }
          if (k < len)           continue;
        }
 catch (        Exception e) {
          if (this.setErrState(curState,succState,true)) {
            MP.printError(EC.TLC_ACTION_PROPERTY_EVALUATION_FAILED,new String[]{this.tool.getImpliedActNames()[k],(e.getMessage() == null) ? e.toString() : e.getMessage()});
            this.trace.printTrace(curState.uid,curState,succState);
            this.theStateQueue.finishAll();
            this.notify();
          }
          throw e;
        }
      }
      succState=null;
    }
    if (deadLocked && this.checkDeadlock) {
synchronized (this) {
        if (this.setErrState(curState,null,false)) {
          MP.printError(EC.TLC_DEADLOCK_REACHED);
          this.trace.printTrace(curState.uid,curState,null);
          this.theStateQueue.finishAll();
          this.notify();
        }
      }
      return true;
    }
    if (this.checkLiveness) {
      long curStateFP=curState.fingerPrint();
      liveNextStates.addElement(curState);
      liveNextFPs.addElement(curStateFP);
      LiveCheck.addNextState(curState,curStateFP,liveNextStates,liveNextFPs);
    }
    return false;
  }
 catch (  Throwable e) {
    boolean keep=((e instanceof StackOverflowError) || (e instanceof OutOfMemoryError));
synchronized (this) {
      if (this.setErrState(curState,succState,!keep)) {
        if (e instanceof StackOverflowError) {
          MP.printError(EC.SYSTEM_STACK_OVERFLOW);
        }
 else         if (e instanceof OutOfMemoryError) {
          MP.printError(EC.SYSTEM_OUT_OF_MEMORY);
        }
 else         if (e.getMessage() != null) {
          MP.printError(EC.GENERAL,e.getMessage());
        }
 else {
          MP.printError(EC.GENERAL,e.toString());
        }
        this.trace.printTrace(curState.uid,curState,succState);
        this.theStateQueue.finishAll();
        this.notify();
      }
    }
    throw e;
  }
}