Program: 51548
Project: 51548
Buggy source:
/** 
 * This method corresponds to the menu option File -> Run. It does its work by calling runInstruction().
 */
public synchronized void menuRun(){
  threadRunning=true;
  interruptSent=false;
  noPauses=false;
  File stdoutFile=getCurrentDefaultStdoutFile();
  if (currentSettings.getStrValue(Settings.STDOUT_USE).equals("String_Node_Str")) {
    try {
      if (stdoutFile.exists()) {
        stdoutFile.delete();
      }
      stdoutFile.createNewFile();
    }
 catch (    IOException e) {
      String[] filename={stdoutFile.getName()};
      gui.showError(new Message("String_Node_Str",filename).toString());
      logger.warning(e.getMessage());
    }
  }
  RunInfo runinfo;
  int runmode=currentSettings.getIntValue(Settings.RUN_MODE);
  int base=0;
  int limit=currentSettings.getIntValue(Settings.MEMORY_SIZE);
  animator.init(control.getCpu(),base,limit);
  if ((runmode & ANIMATED) != 0) {
    gui.showAnimator();
  }
  do {
    currentState=B91_RUNNING;
    setGUICommandsForCurrentState();
    int nextLine=((Processor)control.getCpu()).getValueOf(TTK91Cpu.CU_PC_CURRENT);
    gui.selectLine(nextLine,GUI.INSTRUCTIONS_AND_DATA_TABLE);
    runmode=currentSettings.getIntValue(Settings.RUN_MODE);
    try {
      runinfo=control.runLine();
      if (runinfo == null) {
        break;
      }
    }
 catch (    TTK91NoKbdData needMoreData) {
      gui.addComment(new Message("String_Node_Str").toString());
      gui.updateStatusBar(new Message("String_Node_Str").toString());
      currentState=B91_WAIT_FOR_KBD;
      setGUICommandsForCurrentState();
      gui.enable(GUI.INPUT_FIELD);
      waitForContinueTask();
      gui.disable(GUI.INPUT_FIELD);
      continue;
    }
catch (    TTK91RuntimeException e) {
      gui.updateStatusBar(new Message("String_Node_Str").toString());
      gui.addComment(e.getMessage());
      currentState=INTERRUPTED_WITH_PAUSE;
      setGUICommandsForCurrentState();
      break;
    }
    if ((runmode & COMMENTED) != 0) {
      if (runinfo.getComments() != null) {
        gui.addComment(runinfo.getLineNumber() + "String_Node_Str" + runinfo.getComments());
      }
    }
    animator.stopAnimation();
    animator.animate(runinfo);
    gui.updateStatusBar(runinfo.getComments());
    if (runinfo.isExternalOp() && runinfo.whatOUT() != null) {
      if (runinfo.whatOUT()[0] == Processor.CRT) {
        gui.addOutputData(runinfo.whatOUT()[1]);
      }
    }
    int[] newRegisterValues=runinfo.getRegisters();
    gui.updateReg(GUI.R0,newRegisterValues[0]);
    gui.updateReg(GUI.R1,newRegisterValues[1]);
    gui.updateReg(GUI.R2,newRegisterValues[2]);
    gui.updateReg(GUI.R3,newRegisterValues[3]);
    gui.updateReg(GUI.R4,newRegisterValues[4]);
    gui.updateReg(GUI.R5,newRegisterValues[5]);
    gui.updateReg(GUI.R6,newRegisterValues[6]);
    gui.updateReg(GUI.R7,newRegisterValues[7]);
    gui.updateReg(GUI.PC,runinfo.getNewPC());
    LinkedList changedMemoryLines=runinfo.getChangedMemoryLines();
    Iterator changedMemoryLinesListIterator=changedMemoryLines.iterator();
    while (changedMemoryLinesListIterator.hasNext()) {
      Object[] listItem=(Object[])changedMemoryLinesListIterator.next();
      int line=((Integer)listItem[0]).intValue();
      MemoryLine contents=(MemoryLine)listItem[1];
      gui.updateInstructionsAndDataTableLine(line,contents.getBinary(),contents.getSymbolic());
    }
    gui.repaint();
    if ((runmode & LINE_BY_LINE) != 0 && noPauses == false) {
      currentState=B91_PAUSED;
      setGUICommandsForCurrentState();
      waitForContinueTask();
    }
 else {
      try {
        if (SLOWDOWN > 0)         wait(SLOWDOWN);
      }
 catch (      InterruptedException e) {
        System.out.println("String_Node_Str");
      }
    }
  }
 while (interruptSent == false);
  if (currentState == INTERRUPTED_WITH_PAUSE) {
    setGUICommandsForCurrentState();
    waitForContinueTask();
  }
  load();
  currentState=B91_NOT_RUNNING;
  setGUICommandsForCurrentState();
  gui.unselectAll();
  gui.addComment("String_Node_Str");
  gui.addComment(new Message("String_Node_Str").toString());
  gui.addComment("String_Node_Str");
  continueTask();
  threadRunning=false;
  continueTask();
}

Fixed version (ground truth):
/** 
 * This method corresponds to the menu option File -> Run. It does its work by calling runInstruction().
 */
public void menuRun(){
synchronized (lock) {
    threadRunning=true;
    interruptSent=false;
    noPauses=false;
    File stdoutFile=getCurrentDefaultStdoutFile();
    if (currentSettings.getStrValue(Settings.STDOUT_USE).equals("String_Node_Str")) {
      try {
        if (stdoutFile.exists()) {
          stdoutFile.delete();
        }
        stdoutFile.createNewFile();
      }
 catch (      IOException e) {
        String[] filename={stdoutFile.getName()};
        gui.showError(new Message("String_Node_Str",filename).toString());
        logger.warning(e.getMessage());
      }
    }
    RunInfo runinfo;
    int runmode=currentSettings.getIntValue(Settings.RUN_MODE);
    int base=0;
    int limit=currentSettings.getIntValue(Settings.MEMORY_SIZE);
    animator.init(control.getCpu(),base,limit);
    if ((runmode & ANIMATED) != 0) {
      gui.showAnimator();
    }
    do {
      currentState=B91_RUNNING;
      setGUICommandsForCurrentState();
      int nextLine=((Processor)control.getCpu()).getValueOf(TTK91Cpu.CU_PC_CURRENT);
      gui.selectLine(nextLine,GUI.INSTRUCTIONS_AND_DATA_TABLE);
      runmode=currentSettings.getIntValue(Settings.RUN_MODE);
      try {
        runinfo=control.runLine();
        if (runinfo == null) {
          break;
        }
      }
 catch (      TTK91NoKbdData needMoreData) {
        gui.addComment(new Message("String_Node_Str").toString());
        gui.updateStatusBar(new Message("String_Node_Str").toString());
        currentState=B91_WAIT_FOR_KBD;
        setGUICommandsForCurrentState();
        gui.enable(GUI.INPUT_FIELD);
        waitForContinueTask();
        gui.disable(GUI.INPUT_FIELD);
        continue;
      }
catch (      TTK91RuntimeException e) {
        gui.updateStatusBar(new Message("String_Node_Str").toString());
        gui.addComment(e.getMessage());
        currentState=INTERRUPTED_WITH_PAUSE;
        setGUICommandsForCurrentState();
        break;
      }
      if ((runmode & COMMENTED) != 0) {
        if (runinfo.getComments() != null) {
          gui.addComment(runinfo.getLineNumber() + "String_Node_Str" + runinfo.getComments());
        }
      }
      animator.stopAnimation();
      animator.animate(runinfo);
      gui.updateStatusBar(runinfo.getComments());
      if (runinfo.isExternalOp() && runinfo.whatOUT() != null) {
        if (runinfo.whatOUT()[0] == Processor.CRT) {
          gui.addOutputData(runinfo.whatOUT()[1]);
        }
      }
      int[] newRegisterValues=runinfo.getRegisters();
      gui.updateReg(GUI.R0,newRegisterValues[0]);
      gui.updateReg(GUI.R1,newRegisterValues[1]);
      gui.updateReg(GUI.R2,newRegisterValues[2]);
      gui.updateReg(GUI.R3,newRegisterValues[3]);
      gui.updateReg(GUI.R4,newRegisterValues[4]);
      gui.updateReg(GUI.R5,newRegisterValues[5]);
      gui.updateReg(GUI.R6,newRegisterValues[6]);
      gui.updateReg(GUI.R7,newRegisterValues[7]);
      gui.updateReg(GUI.PC,runinfo.getNewPC());
      LinkedList changedMemoryLines=runinfo.getChangedMemoryLines();
      Iterator changedMemoryLinesListIterator=changedMemoryLines.iterator();
      while (changedMemoryLinesListIterator.hasNext()) {
        Object[] listItem=(Object[])changedMemoryLinesListIterator.next();
        int line=((Integer)listItem[0]).intValue();
        MemoryLine contents=(MemoryLine)listItem[1];
        gui.updateInstructionsAndDataTableLine(line,contents.getBinary(),contents.getSymbolic());
      }
      gui.repaint();
      if ((runmode & LINE_BY_LINE) != 0 && noPauses == false) {
        currentState=B91_PAUSED;
        setGUICommandsForCurrentState();
        waitForContinueTask();
      }
 else {
        try {
          if (SLOWDOWN > 0)           lock.wait(SLOWDOWN);
        }
 catch (        InterruptedException e) {
          System.out.println("String_Node_Str");
        }
      }
    }
 while (interruptSent == false);
    if (currentState == INTERRUPTED_WITH_PAUSE) {
      setGUICommandsForCurrentState();
      waitForContinueTask();
    }
    load();
    currentState=B91_NOT_RUNNING;
    setGUICommandsForCurrentState();
    gui.unselectAll();
    gui.addComment("String_Node_Str");
    gui.addComment(new Message("String_Node_Str").toString());
    gui.addComment("String_Node_Str");
    continueTask();
    threadRunning=false;
    continueTask();
  }
}