Program: 73816
Project: 73816
Buggy source:
/** 
 * Return whether we want to preempt the currently executing actor and instead execute another event from the event queue. This method iterate through all events in the event queue, and finds the event in the queue that is both safe, and also has the smallest deadline. This event is then stored in _eventToProcess, and returned in _getNextSafeEvent(). If there are several safe events with the smallest deadline, then the event of smallest tag + depth is stored in _eventToProcess.
 * @return whether we want to preempt the executing event.
 * @exception IllegalActionException
 * @see #_getNextSafeEvent()
 */
protected boolean _preemptExecutingActor() throws IllegalActionException {
  if (!_getSmallestDeadlineSafeEventFromQueue()) {
    return false;
  }
  Time smallestStackDeadline=new Time(this,Double.POSITIVE_INFINITY);
  DoubleTimedEvent doubleTimedEvent=_currentlyExecutingStack.peek();
  List eventList=(List<PtidesEvent>)(doubleTimedEvent.contents);
  PtidesEvent executingEvent=(PtidesEvent)eventList.get(0);
  for (int i=0; i < eventList.size(); i++) {
    Time absExecutingDeadline=_getAbsoluteDeadline(((PtidesEvent)eventList.get(i)));
    if (absExecutingDeadline.compareTo(smallestStackDeadline) <= 0) {
      smallestStackDeadline=absExecutingDeadline;
    }
  }
  Time smallestQueueDeadline=_getAbsoluteDeadline(_eventToProcess);
  if (smallestQueueDeadline.compareTo(smallestStackDeadline) > 0) {
    _eventToProcess=null;
  }
 else   if (smallestQueueDeadline.compareTo(smallestStackDeadline) == 0) {
    if (_eventToProcess.compareTo(executingEvent) >= 0) {
      _eventToProcess=null;
    }
  }
  if (_eventToProcess == null) {
    if (_debugging) {
      _debug("String_Node_Str" + "String_Node_Str" + executingEvent.actor() + "String_Node_Str"+ getPhysicalTime());
    }
    return false;
  }
 else {
    if (_debugging) {
      _debug("String_Node_Str" + "String_Node_Str" + executingEvent.actor() + "String_Node_Str"+ _eventToProcess.actor()+ "String_Node_Str"+ getPhysicalTime());
    }
    return true;
  }
}

Fixed version (ground truth):
/** 
 * Return whether we want to preempt the currently executing actor and instead execute another event from the event queue. This method iterate through all events in the event queue, and finds the event in the queue that is both safe, and also has the smallest deadline. This event is then stored in _eventToProcess, and returned in _getNextSafeEvent(). If there are several safe events with the smallest deadline, then the event of smallest tag + depth is stored in _eventToProcess.
 * @return whether we want to preempt the executing event.
 * @exception IllegalActionException
 * @see #_getNextSafeEvent()
 */
protected boolean _preemptExecutingActor() throws IllegalActionException {
  if (!_getSmallestDeadlineSafeEventFromQueue()) {
    return false;
  }
  Time smallestStackDeadline=new Time(this,Double.POSITIVE_INFINITY);
  DoubleTimedEvent doubleTimedEvent=_currentlyExecutingStack.peek();
  List eventList=(List<PtidesEvent>)(doubleTimedEvent.contents);
  PtidesEvent executingEvent=(PtidesEvent)eventList.get(0);
  for (int i=0; i < eventList.size(); i++) {
    Time absExecutingDeadline=_getAbsoluteDeadline(((PtidesEvent)eventList.get(i)));
    if (absExecutingDeadline.compareTo(smallestStackDeadline) <= 0) {
      smallestStackDeadline=absExecutingDeadline;
    }
  }
  Time smallestQueueDeadline=_getAbsoluteDeadline(_eventToProcess);
  if (smallestQueueDeadline.compareTo(smallestStackDeadline) > 0) {
    _eventToProcess=null;
  }
 else   if (smallestQueueDeadline.compareTo(smallestStackDeadline) == 0) {
    if (_eventToProcess.compareTo(executingEvent) >= 0) {
      _eventToProcess=null;
    }
  }
  if (_eventToProcess == null) {
    if (_debugging) {
      _debug("String_Node_Str" + "String_Node_Str" + executingEvent.actor() + "String_Node_Str"+ getPhysicalTag().timestamp+ "String_Node_Str"+ getPhysicalTag().microstep);
    }
    return false;
  }
 else {
    if (_debugging) {
      _debug("String_Node_Str" + "String_Node_Str" + executingEvent.actor() + "String_Node_Str"+ _eventToProcess.actor()+ "String_Node_Str"+ getPhysicalTag().timestamp+ "String_Node_Str"+ getPhysicalTag().microstep);
    }
    return true;
  }
}