Program: 136011
Project: 136011
Buggy source:
public void simulate() throws Exception {
  StateVec theInitStates=null;
  TLCState curState=null;
  if (isCancelled) {
    return;
  }
  try {
    theInitStates=this.tool.getInitStates();
    this.numOfGenStates=theInitStates.size();
    for (int i=0; i < theInitStates.size(); i++) {
      curState=theInitStates.elementAt(i);
      if (this.tool.isGoodState(curState)) {
        for (int j=0; j < this.invariants.length; j++) {
          if (!this.tool.isValid(this.invariants[j],curState)) {
            MP.printError(EC.TLC_INVARIANT_VIOLATED_INITIAL,new String[]{this.tool.getInvNames()[j],curState.toString()});
            return;
          }
        }
      }
 else {
        MP.printError(EC.TLC_STATE_NOT_COMPLETELY_SPECIFIED_INITIAL,curState.toString());
        return;
      }
    }
  }
 catch (  Exception e) {
    if (curState != null) {
      MP.printError(EC.TLC_INITIAL_STATE,new String[]{e.getMessage(),curState.toString()});
    }
 else {
      MP.printError(EC.GENERAL,e.getMessage());
    }
    this.printSummary();
    return;
  }
  if (this.numOfGenStates == 0) {
    MP.printError(EC.TLC_NO_STATES_SATISFYING_INIT);
    return;
  }
  theInitStates.deepNormalize();
  ProgressReport report=new ProgressReport();
  report.start();
  int traceIdx=0;
  int idx=0;
  try {
    for (int traceCnt=1; traceCnt <= this.traceNum; traceCnt++) {
      traceIdx=0;
      this.aril=rng.getAril();
      curState=this.randomState(theInitStates);
      boolean inConstraints=this.tool.isInModel(curState);
      while (traceIdx < this.traceDepth) {
        if (traceIdx < this.stateTrace.length) {
          this.stateTrace[traceIdx]=curState;
          traceIdx++;
        }
        if (!inConstraints)         break;
        StateVec nextStates=this.randomNextStates(curState);
        if (nextStates == null) {
          if (this.checkDeadlock) {
            this.printBehavior(EC.TLC_DEADLOCK_REACHED,null,curState,traceIdx);
            if (!TLCGlobals.continuation) {
              return;
            }
          }
          break;
        }
        for (int i=0; i < nextStates.size(); i++) {
          this.numOfGenStates++;
          TLCState state=nextStates.elementAt(i);
          if (TLCGlobals.coverageInterval >= 0) {
            ((TLCStateMutSource)state).addCounts(this.astCounts);
          }
          if (!this.tool.isGoodState(state)) {
            this.printBehavior(EC.TLC_STATE_NOT_COMPLETELY_SPECIFIED_NEXT,null,state,traceIdx);
            return;
          }
 else {
            try {
              for (idx=0; idx < this.invariants.length; idx++) {
                if (!this.tool.isValid(this.invariants[idx],state)) {
                  this.printBehavior(EC.TLC_INVARIANT_VIOLATED_BEHAVIOR,new String[]{this.tool.getInvNames()[idx]},state,traceIdx);
                  if (!TLCGlobals.continuation) {
                    return;
                  }
                }
              }
            }
 catch (            Exception e) {
              this.printBehavior(EC.TLC_INVARIANT_EVALUATION_FAILED,new String[]{this.tool.getInvNames()[idx],e.getMessage()},state,traceIdx);
              return;
            }
            try {
              for (idx=0; idx < this.impliedActions.length; idx++) {
                if (!this.tool.isValid(this.impliedActions[idx],curState,state)) {
                  this.printBehavior(EC.TLC_ACTION_PROPERTY_VIOLATED_BEHAVIOR,new String[]{this.tool.getImpliedActNames()[idx]},state,traceIdx);
                  if (!TLCGlobals.continuation) {
                    return;
                  }
                }
              }
            }
 catch (            Exception e) {
              this.printBehavior(EC.TLC_ACTION_PROPERTY_EVALUATION_FAILED,new String[]{this.tool.getImpliedActNames()[idx],e.getMessage()},state,traceIdx);
              return;
            }
          }
        }
        TLCState s1=this.randomState(nextStates);
        inConstraints=(this.tool.isInModel(s1) && this.tool.isInActions(curState,s1));
        curState=s1;
      }
      if (this.checkLiveness) {
        LiveCheck1.checkTrace(stateTrace,traceIdx);
      }
      if (this.traceFile != null) {
        String fileName=this.traceFile + traceCnt;
        PrintWriter pw=new PrintWriter(FileUtil.newBFOS(fileName));
        pw.println("String_Node_Str" + fileName + "String_Node_Str");
        for (idx=0; idx < traceIdx; idx++) {
          pw.println("String_Node_Str" + (idx + 1) + "String_Node_Str");
          pw.println(this.stateTrace[idx] + "String_Node_Str");
        }
        pw.println("String_Node_Str");
        pw.close();
      }
    }
  }
 catch (  Throwable e) {
    if (e instanceof LiveException) {
      this.printSummary();
    }
 else {
      this.printBehavior(EC.GENERAL,new String[]{e.getMessage()},curState,traceIdx);
    }
  }
}

Fixed version (ground truth):
public void simulate() throws Exception {
  StateVec theInitStates=null;
  TLCState curState=null;
  if (isCancelled) {
    return;
  }
  try {
    theInitStates=this.tool.getInitStates();
    this.numOfGenStates=theInitStates.size();
    for (int i=0; i < theInitStates.size(); i++) {
      curState=theInitStates.elementAt(i);
      if (this.tool.isGoodState(curState)) {
        for (int j=0; j < this.invariants.length; j++) {
          if (!this.tool.isValid(this.invariants[j],curState)) {
            MP.printError(EC.TLC_INVARIANT_VIOLATED_INITIAL,new String[]{this.tool.getInvNames()[j],curState.toString()});
            return;
          }
        }
      }
 else {
        MP.printError(EC.TLC_STATE_NOT_COMPLETELY_SPECIFIED_INITIAL,curState.toString());
        return;
      }
    }
  }
 catch (  Exception e) {
    if (curState != null) {
      MP.printError(EC.TLC_INITIAL_STATE,new String[]{(e.getMessage() == null) ? e.toString() : e.getMessage(),curState.toString()});
    }
 else {
      MP.printError(EC.GENERAL,(e.getMessage() == null) ? e.toString() : e.getMessage());
    }
    this.printSummary();
    return;
  }
  if (this.numOfGenStates == 0) {
    MP.printError(EC.TLC_NO_STATES_SATISFYING_INIT);
    return;
  }
  theInitStates.deepNormalize();
  ProgressReport report=new ProgressReport();
  report.start();
  int traceIdx=0;
  int idx=0;
  try {
    for (int traceCnt=1; traceCnt <= this.traceNum; traceCnt++) {
      traceIdx=0;
      this.aril=rng.getAril();
      curState=this.randomState(theInitStates);
      boolean inConstraints=this.tool.isInModel(curState);
      while (traceIdx < this.traceDepth) {
        if (traceIdx < this.stateTrace.length) {
          this.stateTrace[traceIdx]=curState;
          traceIdx++;
        }
        if (!inConstraints)         break;
        StateVec nextStates=this.randomNextStates(curState);
        if (nextStates == null) {
          if (this.checkDeadlock) {
            this.printBehavior(EC.TLC_DEADLOCK_REACHED,null,curState,traceIdx);
            if (!TLCGlobals.continuation) {
              return;
            }
          }
          break;
        }
        for (int i=0; i < nextStates.size(); i++) {
          this.numOfGenStates++;
          TLCState state=nextStates.elementAt(i);
          if (TLCGlobals.coverageInterval >= 0) {
            ((TLCStateMutSource)state).addCounts(this.astCounts);
          }
          if (!this.tool.isGoodState(state)) {
            this.printBehavior(EC.TLC_STATE_NOT_COMPLETELY_SPECIFIED_NEXT,null,state,traceIdx);
            return;
          }
 else {
            try {
              for (idx=0; idx < this.invariants.length; idx++) {
                if (!this.tool.isValid(this.invariants[idx],state)) {
                  this.printBehavior(EC.TLC_INVARIANT_VIOLATED_BEHAVIOR,new String[]{this.tool.getInvNames()[idx]},state,traceIdx);
                  if (!TLCGlobals.continuation) {
                    return;
                  }
                }
              }
            }
 catch (            Exception e) {
              this.printBehavior(EC.TLC_INVARIANT_EVALUATION_FAILED,new String[]{this.tool.getInvNames()[idx],e.getMessage()},state,traceIdx);
              return;
            }
            try {
              for (idx=0; idx < this.impliedActions.length; idx++) {
                if (!this.tool.isValid(this.impliedActions[idx],curState,state)) {
                  this.printBehavior(EC.TLC_ACTION_PROPERTY_VIOLATED_BEHAVIOR,new String[]{this.tool.getImpliedActNames()[idx]},state,traceIdx);
                  if (!TLCGlobals.continuation) {
                    return;
                  }
                }
              }
            }
 catch (            Exception e) {
              this.printBehavior(EC.TLC_ACTION_PROPERTY_EVALUATION_FAILED,new String[]{this.tool.getImpliedActNames()[idx],e.getMessage()},state,traceIdx);
              return;
            }
          }
        }
        TLCState s1=this.randomState(nextStates);
        inConstraints=(this.tool.isInModel(s1) && this.tool.isInActions(curState,s1));
        curState=s1;
      }
      if (this.checkLiveness) {
        LiveCheck1.checkTrace(stateTrace,traceIdx);
      }
      if (this.traceFile != null) {
        String fileName=this.traceFile + traceCnt;
        PrintWriter pw=new PrintWriter(FileUtil.newBFOS(fileName));
        pw.println("String_Node_Str" + fileName + "String_Node_Str");
        for (idx=0; idx < traceIdx; idx++) {
          pw.println("String_Node_Str" + (idx + 1) + "String_Node_Str");
          pw.println(this.stateTrace[idx] + "String_Node_Str");
        }
        pw.println("String_Node_Str");
        pw.close();
      }
    }
  }
 catch (  Throwable e) {
    if (e instanceof LiveException) {
      this.printSummary();
    }
 else {
      this.printBehavior(EC.GENERAL,new String[]{(e.getMessage() == null) ? e.toString() : e.getMessage()},curState,traceIdx);
    }
  }
}