Program: 136098
Project: 136098
Buggy source:
/** 
 * Compute the set of the next states.  For each next state, check if it is a valid state, if the invariants are satisfied, and if it satisfies the constraints. It also adds the states that have not been done in nextStates.  Return true if it finds a leaf successor of curState.
 */
public final boolean doNext(TLCState curState,long cfp,boolean isLeaf,ObjLongTable counts,StateVec states,LongVec fps) throws Throwable {
  boolean deadLocked=true;
  TLCState succState=null;
  StateVec liveNextStates=null;
  LongVec liveNextFPs=null;
  if (this.checkLiveness && isLeaf) {
    liveNextStates=new StateVec(2);
    liveNextFPs=new LongVec(2);
  }
  try {
    int k=0;
    boolean allSuccDone=true;
    boolean allSuccNonLeaf=true;
    for (int i=0; i < this.actions.length; i++) {
      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)) {
            this.printTrace(EC.TLC_STATE_NOT_COMPLETELY_SPECIFIED_NEXT,null,curState,succState);
synchronized (this) {
              this.notify();
            }
          }
          return allSuccNonLeaf;
        }
        if (TLCGlobals.coverageInterval >= 0) {
          ((TLCStateMutSource)succState).addCounts(counts);
        }
        boolean inModel=(this.tool.isInModel(succState) && this.tool.isInActions(curState,succState));
        int status=FPIntSet.NEW;
        if (inModel) {
          long fp=succState.fingerPrint();
          status=this.theFPSet.setStatus(fp,FPIntSet.NEW);
          allSuccDone=allSuccDone && FPIntSet.isDone(status);
          allSuccNonLeaf=allSuccNonLeaf && !FPIntSet.isLeaf(status);
          if (status == FPIntSet.NEW && this.allStateWriter != null) {
            this.allStateWriter.writeState(succState);
          }
          if (!FPIntSet.isCompleted(status)) {
            states.addElement(succState);
            fps.addElement(fp);
          }
          if (this.checkLiveness && isLeaf) {
            liveNextStates.addElement(succState);
            liveNextFPs.addElement(fp);
          }
        }
        if (status == FPIntSet.NEW) {
          try {
            int len=this.invariants.length;
            for (k=0; k < len; k++) {
              if (!tool.isValid(this.invariants[k],succState)) {
synchronized (this) {
                  if (TLCGlobals.continuation) {
                    this.printTrace(EC.TLC_INVARIANT_VIOLATED_BEHAVIOR,new String[]{this.tool.getInvNames()[k]},curState,succState);
                    break;
                  }
 else {
                    if (this.setErrState(curState,succState,false)) {
                      this.printTrace(EC.TLC_INVARIANT_VIOLATED_BEHAVIOR,new String[]{this.tool.getInvNames()[k]},curState,succState);
                      this.notify();
                    }
                    return allSuccNonLeaf;
                  }
                }
              }
            }
            if (k < len)             continue;
          }
 catch (          Exception e) {
            if (this.setErrState(curState,succState,true)) {
              this.printTrace(EC.TLC_INVARIANT_EVALUATION_FAILED,new String[]{this.tool.getInvNames()[k]},curState,succState);
              this.notify();
            }
            return allSuccNonLeaf;
          }
        }
        try {
          int len=this.impliedActions.length;
          for (k=0; k < len; k++) {
            if (!tool.isValid(this.impliedActions[k],curState,succState)) {
synchronized (this) {
                if (TLCGlobals.continuation) {
                  this.printTrace(EC.TLC_ACTION_PROPERTY_VIOLATED_BEHAVIOR,new String[]{this.tool.getImpliedActNames()[k]},curState,succState);
                  break;
                }
 else {
                  if (this.setErrState(curState,succState,false)) {
                    this.printTrace(EC.TLC_ACTION_PROPERTY_VIOLATED_BEHAVIOR,new String[]{this.tool.getImpliedActNames()[k]},curState,succState);
                    this.notify();
                  }
                  return allSuccNonLeaf;
                }
              }
            }
          }
          if (k < len)           continue;
        }
 catch (        Exception e) {
          if (this.setErrState(curState,succState,true)) {
            this.printTrace(EC.TLC_ACTION_PROPERTY_EVALUATION_FAILED,new String[]{this.tool.getImpliedActNames()[k]},curState,succState);
            this.notify();
          }
          return allSuccNonLeaf;
        }
      }
      succState=null;
    }
    if (deadLocked && this.checkDeadlock) {
synchronized (this) {
        if (this.setErrState(curState,null,false)) {
          this.printTrace(EC.TLC_DEADLOCK_REACHED,null,curState,null);
          this.notify();
        }
      }
      return allSuccNonLeaf;
    }
    if (this.checkLiveness && isLeaf) {
      long curStateFP=curState.fingerPrint();
      liveNextStates.addElement(curState);
      liveNextFPs.addElement(curStateFP);
      LiveCheck.addNextState(curState,curStateFP,liveNextStates,liveNextFPs);
    }
    if (allSuccDone || (isLeaf && allSuccNonLeaf)) {
      this.theFPSet.setStatus(cfp,FPIntSet.DONE);
    }
    return allSuccNonLeaf;
  }
 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.printTrace(EC.TLC_BEHAVIOR_UP_TO_THIS_POINT,null,curState,succState);
        this.notifyAll();
      }
    }
    throw e;
  }
}

Fixed version (ground truth):
/** 
 * Compute the set of the next states.  For each next state, check if it is a valid state, if the invariants are satisfied, and if it satisfies the constraints. It also adds the states that have not been done in nextStates.  Return true if it finds a leaf successor of curState.
 */
public final boolean doNext(TLCState curState,long cfp,boolean isLeaf,ObjLongTable counts,StateVec states,LongVec fps) throws Throwable {
  boolean deadLocked=true;
  TLCState succState=null;
  StateVec liveNextStates=null;
  LongVec liveNextFPs=null;
  if (this.checkLiveness && isLeaf) {
    liveNextStates=new StateVec(2);
    liveNextFPs=new LongVec(2);
  }
  try {
    int k=0;
    boolean allSuccDone=true;
    boolean allSuccNonLeaf=true;
    for (int i=0; i < this.actions.length; i++) {
      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)) {
            this.printTrace(EC.TLC_STATE_NOT_COMPLETELY_SPECIFIED_NEXT,null,curState,succState);
synchronized (this) {
              this.notify();
            }
          }
          return allSuccNonLeaf;
        }
        if (TLCGlobals.coverageInterval >= 0) {
          ((TLCStateMutSource)succState).addCounts(counts);
        }
        boolean inModel=(this.tool.isInModel(succState) && this.tool.isInActions(curState,succState));
        int status=FPIntSet.NEW;
        if (inModel) {
          long fp=succState.fingerPrint();
          status=this.theFPSet.setStatus(fp,FPIntSet.NEW);
          allSuccDone=allSuccDone && FPIntSet.isDone(status);
          allSuccNonLeaf=allSuccNonLeaf && !FPIntSet.isLeaf(status);
          if (status == FPIntSet.NEW && this.allStateWriter != null) {
            this.allStateWriter.writeState(succState);
          }
          if (!FPIntSet.isCompleted(status)) {
            states.addElement(succState);
            fps.addElement(fp);
          }
          if (this.checkLiveness && isLeaf) {
            liveNextStates.addElement(succState);
            liveNextFPs.addElement(fp);
          }
        }
        if (status == FPIntSet.NEW) {
          try {
            int len=this.invariants.length;
            for (k=0; k < len; k++) {
              if (!tool.isValid(this.invariants[k],succState)) {
synchronized (this) {
                  if (TLCGlobals.continuation) {
                    this.printTrace(EC.TLC_INVARIANT_VIOLATED_BEHAVIOR,new String[]{this.tool.getInvNames()[k]},curState,succState);
                    break;
                  }
 else {
                    if (this.setErrState(curState,succState,false)) {
                      this.printTrace(EC.TLC_INVARIANT_VIOLATED_BEHAVIOR,new String[]{this.tool.getInvNames()[k]},curState,succState);
                      this.notify();
                    }
                    return allSuccNonLeaf;
                  }
                }
              }
            }
            if (k < len)             continue;
          }
 catch (          Exception e) {
            if (this.setErrState(curState,succState,true)) {
              this.printTrace(EC.TLC_INVARIANT_EVALUATION_FAILED,new String[]{this.tool.getInvNames()[k]},curState,succState);
              this.notify();
            }
            return allSuccNonLeaf;
          }
        }
        try {
          int len=this.impliedActions.length;
          for (k=0; k < len; k++) {
            if (!tool.isValid(this.impliedActions[k],curState,succState)) {
synchronized (this) {
                if (TLCGlobals.continuation) {
                  this.printTrace(EC.TLC_ACTION_PROPERTY_VIOLATED_BEHAVIOR,new String[]{this.tool.getImpliedActNames()[k]},curState,succState);
                  break;
                }
 else {
                  if (this.setErrState(curState,succState,false)) {
                    this.printTrace(EC.TLC_ACTION_PROPERTY_VIOLATED_BEHAVIOR,new String[]{this.tool.getImpliedActNames()[k]},curState,succState);
                    this.notify();
                  }
                  return allSuccNonLeaf;
                }
              }
            }
          }
          if (k < len)           continue;
        }
 catch (        Exception e) {
          if (this.setErrState(curState,succState,true)) {
            this.printTrace(EC.TLC_ACTION_PROPERTY_EVALUATION_FAILED,new String[]{this.tool.getImpliedActNames()[k]},curState,succState);
            this.notify();
          }
          return allSuccNonLeaf;
        }
      }
      succState=null;
    }
    if (deadLocked && this.checkDeadlock) {
synchronized (this) {
        if (this.setErrState(curState,null,false)) {
          this.printTrace(EC.TLC_DEADLOCK_REACHED,null,curState,null);
          this.notify();
        }
      }
      return allSuccNonLeaf;
    }
    if (this.checkLiveness && isLeaf) {
      long curStateFP=curState.fingerPrint();
      liveNextStates.addElement(curState);
      liveNextFPs.addElement(curStateFP);
      LiveCheck.addNextState(curState,curStateFP,liveNextStates,liveNextFPs);
    }
    if (allSuccDone || (isLeaf && allSuccNonLeaf)) {
      this.theFPSet.setStatus(cfp,FPIntSet.DONE);
    }
    return allSuccNonLeaf;
  }
 catch (  Throwable e) {
    boolean keep=((e instanceof StackOverflowError) || (e instanceof OutOfMemoryError));
synchronized (this) {
      if (this.setErrState(curState,succState,!keep)) {
        String[] parameters=null;
        int errorCode;
        if (e instanceof StackOverflowError) {
          errorCode=EC.SYSTEM_STACK_OVERFLOW;
        }
 else         if (e instanceof OutOfMemoryError) {
          errorCode=EC.SYSTEM_OUT_OF_MEMORY;
        }
 else {
          errorCode=EC.GENERAL;
          parameters=new String[]{e.getMessage()};
        }
        this.printTrace(errorCode,parameters,curState,succState);
        this.notifyAll();
      }
    }
    throw e;
  }
}