Program: 76356
Project: 76356
Buggy source:
private Actor _getActorToFire(){
  Actor actorToFire=null;
  DEEvent currentEvent=null;
  FIFOQueue eventsToPutBack=new FIFOQueue();
  double currentTime=getCurrentTime();
  long currentDepth=0;
  while (true) {
    if (_stopWhenQueueIsEmpty) {
      try {
        currentEvent=(DEEvent)_eventQueue.take();
      }
 catch (      IllegalActionException ex) {
        break;
      }
    }
 else {
      while (true) {
        try {
          currentEvent=(DEEvent)_eventQueue.take();
        }
 catch (        IllegalActionException ex) {
          _debug("String_Node_Str");
synchronized (_eventQueue) {
            try {
              _eventQueue.wait();
            }
 catch (            InterruptedException e) {
            }
          }
          continue;
        }
        break;
      }
    }
    if (actorToFire == null) {
      actorToFire=currentEvent.getDestinationActor();
      if (_deadActors != null && _deadActors.contains(actorToFire)) {
        _debug("String_Node_Str",((Entity)actorToFire).getName());
        continue;
      }
      currentTime=currentEvent.getEventTag().timeStamp();
      currentDepth=currentEvent.getEventTag().receiverDepth();
      try {
        setCurrentTime(currentTime);
      }
 catch (      IllegalActionException ex) {
        throw new InternalErrorException(ex.toString());
      }
      _debug("String_Node_Str" + currentTime);
      if (currentTime < _startTime) {
        _startTime=currentTime;
      }
      if (currentTime > getStopTime()) {
        _debug("String_Node_Str");
        return null;
      }
      DEReceiver rec=currentEvent.getDestinationReceiver();
      if (rec != null) {
        rec._triggerEvent(currentEvent.getTransferredToken());
      }
    }
 else {
      double eventTime=currentEvent.getEventTag().timeStamp();
      long eventDepth=currentEvent.getEventTag().receiverDepth();
      if (eventTime < currentTime) {
        throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
      }
      if (eventTime > currentTime || eventDepth > currentDepth) {
        eventsToPutBack.put(currentEvent);
        break;
      }
 else {
        if (currentEvent.getDestinationActor() == actorToFire) {
          DEReceiver rec=currentEvent.getDestinationReceiver();
          if (rec != null) {
            rec._triggerEvent(currentEvent.getTransferredToken());
          }
        }
 else {
          eventsToPutBack.put(currentEvent);
        }
      }
    }
  }
  _debug("String_Node_Str");
  while (eventsToPutBack.size() > 0) {
    DEEvent event=(DEEvent)eventsToPutBack.take();
    _eventQueue.put(event);
  }
  return actorToFire;
}

Fixed version (ground truth):
private Actor _getActorToFire(){
  Actor actorToFire=null;
  DEEvent currentEvent=null;
  double currentTime=getCurrentTime();
  long currentDepth=0;
  while (_pendingEvents.size() > 0) {
    currentEvent=(DEEvent)_pendingEvents.remove(0);
    actorToFire=currentEvent.getDestinationActor();
    if (_deadActors != null && _deadActors.contains(actorToFire)) {
      _debug("String_Node_Str",((Entity)actorToFire).getFullName());
      actorToFire=null;
      continue;
    }
    currentTime=currentEvent.getEventTag().timeStamp();
    currentDepth=currentEvent.getEventTag().receiverDepth();
    break;
  }
  while (true) {
    if (_stopWhenQueueIsEmpty) {
      try {
        currentEvent=(DEEvent)_eventQueue.take();
      }
 catch (      IllegalActionException ex) {
        break;
      }
    }
 else {
      while (_eventQueue.isEmpty()) {
        _debug("String_Node_Str");
synchronized (_eventQueue) {
          try {
            _eventQueue.wait();
          }
 catch (          InterruptedException e) {
          }
        }
      }
      try {
        currentEvent=(DEEvent)_eventQueue.take();
      }
 catch (      IllegalActionException ex) {
        throw new InternalErrorException(ex.toString());
      }
    }
    if (actorToFire == null) {
      actorToFire=currentEvent.getDestinationActor();
      if (_deadActors != null && _deadActors.contains(actorToFire)) {
        _debug("String_Node_Str",((Entity)actorToFire).getFullName());
        actorToFire=null;
        continue;
      }
      currentTime=currentEvent.getEventTag().timeStamp();
      currentDepth=currentEvent.getEventTag().receiverDepth();
      try {
        setCurrentTime(currentTime);
      }
 catch (      IllegalActionException ex) {
        throw new InternalErrorException(ex.toString());
      }
      _debug("String_Node_Str" + currentTime);
      if (currentTime < _startTime) {
        _startTime=currentTime;
      }
      if (currentTime > getStopTime()) {
        _debug("String_Node_Str");
        return null;
      }
      DEReceiver rec=currentEvent.getDestinationReceiver();
      if (rec != null) {
        rec._triggerEvent(currentEvent.getTransferredToken());
      }
    }
 else {
      double eventTime=currentEvent.getEventTag().timeStamp();
      long eventDepth=currentEvent.getEventTag().receiverDepth();
      if (eventTime < currentTime) {
        throw new InternalErrorException("String_Node_Str" + "String_Node_Str");
      }
      if (eventTime > currentTime || eventDepth > currentDepth) {
        _eventQueue.put(currentEvent);
        break;
      }
 else {
        DEReceiver rec=currentEvent.getDestinationReceiver();
        if (rec != null) {
          rec._triggerEvent(currentEvent.getTransferredToken());
        }
        if (currentEvent.getDestinationActor() != actorToFire) {
          _pendingEvents.add(currentEvent);
        }
      }
    }
  }
  return actorToFire;
}