Program: 76101
Project: 76101
Buggy source:
private Actor _dequeueEvents(){
  Actor actorToFire=null;
  DEEvent currentEvent=null, nextEvent=null;
  int currentDepth=0;
  while (true) {
    if (_stopWhenQueueIsEmpty) {
      try {
        nextEvent=(DEEvent)_eventQueue.get();
      }
 catch (      IllegalActionException ex) {
        break;
      }
    }
 else {
      _stopRequested=false;
      while (_eventQueue.isEmpty() && !_stopRequested) {
        if (_debugging) {
          _debug("String_Node_Str");
        }
synchronized (_eventQueue) {
          try {
            _eventQueue.wait();
          }
 catch (          InterruptedException e) {
            break;
          }
        }
      }
      try {
        nextEvent=(DEEvent)_eventQueue.get();
      }
 catch (      IllegalActionException ex) {
        break;
      }
    }
    if (actorToFire == null) {
      try {
        _eventQueue.take();
      }
 catch (      IllegalActionException ex) {
        throw new InternalErrorException(ex.toString());
      }
      currentEvent=nextEvent;
      actorToFire=currentEvent.actor();
      if (_deadActors != null && _deadActors.contains(actorToFire)) {
        if (_debugging)         _debug("String_Node_Str",((Entity)actorToFire).getFullName());
        actorToFire=null;
        continue;
      }
      double currentTime=currentEvent.timeStamp();
      if (_debugging)       _debug("String_Node_Str",Double.toString(currentTime));
      try {
        setCurrentTime(currentTime);
      }
 catch (      IllegalActionException ex) {
        throw new InternalErrorException(ex.toString());
      }
      if (currentTime < _startTime) {
        _startTime=currentTime;
      }
      currentDepth=currentEvent.depth();
      _microstep=currentEvent.microstep();
      if (currentTime > getStopTime()) {
        if (_debugging) {
          _debug("String_Node_Str");
        }
        return null;
      }
      DEReceiver rec=currentEvent.receiver();
      if (rec != null) {
        if (_debugging)         _debug(getName(),"String_Node_Str",rec.getContainer().getName());
        rec._triggerEvent(currentEvent.token());
      }
    }
 else {
      if (nextEvent.isSimultaneousWith(currentEvent) && nextEvent.actor() == currentEvent.actor()) {
        try {
          _eventQueue.take();
        }
 catch (        IllegalActionException ex) {
          throw new InternalErrorException(ex.toString());
        }
        DEReceiver rec=nextEvent.receiver();
        if (rec != null) {
          rec._triggerEvent(nextEvent.token());
        }
      }
 else {
        break;
      }
    }
  }
  return actorToFire;
}

Fixed version (ground truth):
private Actor _dequeueEvents(){
  Actor actorToFire=null;
  DEEvent currentEvent=null, nextEvent=null;
  int currentDepth=0;
  while (true) {
    if (_stopWhenQueueIsEmpty) {
      try {
        nextEvent=(DEEvent)_eventQueue.get();
      }
 catch (      IllegalActionException ex) {
        break;
      }
    }
 else {
      if (actorToFire != null && _eventQueue.isEmpty())       break;
      _stopRequested=false;
      while (_eventQueue.isEmpty() && !_stopRequested) {
        if (_debugging) {
          _debug("String_Node_Str");
        }
synchronized (_eventQueue) {
          try {
            _eventQueue.wait();
          }
 catch (          InterruptedException e) {
            break;
          }
        }
      }
      try {
        nextEvent=(DEEvent)_eventQueue.get();
      }
 catch (      IllegalActionException ex) {
        break;
      }
    }
    if (actorToFire == null) {
      try {
        _eventQueue.take();
      }
 catch (      IllegalActionException ex) {
        throw new InternalErrorException(ex.toString());
      }
      currentEvent=nextEvent;
      actorToFire=currentEvent.actor();
      if (_deadActors != null && _deadActors.contains(actorToFire)) {
        if (_debugging)         _debug("String_Node_Str",((Entity)actorToFire).getFullName());
        actorToFire=null;
        continue;
      }
      double currentTime=currentEvent.timeStamp();
      if (_synchronizeToRealTime) {
        long elapsedTime=System.currentTimeMillis() - _realStartTime;
        double elapsedTimeInSeconds=((double)elapsedTime) / 1000.0;
        if (currentTime > elapsedTimeInSeconds) {
          long timeToWait=(long)((currentTime - elapsedTimeInSeconds) * 1000.0);
          if (timeToWait > 0) {
            if (_debugging) {
              _debug("String_Node_Str" + timeToWait);
            }
synchronized (_eventQueue) {
              try {
                _eventQueue.wait(timeToWait);
              }
 catch (              InterruptedException ex) {
              }
            }
          }
        }
      }
      if (_debugging)       _debug("String_Node_Str",Double.toString(currentTime));
      try {
        setCurrentTime(currentTime);
      }
 catch (      IllegalActionException ex) {
        throw new InternalErrorException(ex.toString());
      }
      if (currentTime < _startTime) {
        _startTime=currentTime;
      }
      currentDepth=currentEvent.depth();
      _microstep=currentEvent.microstep();
      if (currentTime > getStopTime()) {
        if (_debugging) {
          _debug("String_Node_Str");
        }
        return null;
      }
      DEReceiver rec=currentEvent.receiver();
      if (rec != null) {
        if (_debugging)         _debug(getName(),"String_Node_Str",rec.getContainer().getName());
        rec._triggerEvent(currentEvent.token());
      }
    }
 else {
      if (nextEvent.isSimultaneousWith(currentEvent) && nextEvent.actor() == currentEvent.actor()) {
        try {
          _eventQueue.take();
        }
 catch (        IllegalActionException ex) {
          throw new InternalErrorException(ex.toString());
        }
        DEReceiver rec=nextEvent.receiver();
        if (rec != null) {
          rec._triggerEvent(nextEvent.token());
        }
      }
 else {
        break;
      }
    }
  }
  return actorToFire;
}