Program: 72790
Project: 72790
Buggy source:
/** 
 * Advance the current model tag to that of the earliest event in the event queue, and fire all actors that have requested or are triggered to be fired at the current tag. If <i>synchronizeToRealTime</i> is true, then before firing, wait until real time matches or exceeds the timestamp of the event. Note that the default unit for time is seconds. <p> Each actor is fired repeatedly (prefire(), fire()), until either it has no more input tokens, or its prefire() method returns false. Note that if the actor fails to consume its inputs, then this can result in an infinite loop. Each actor that is fired is then postfired once at the conclusion of the iteration. </p><p> If there are no events in the event queue, then the behavior depends on the <i>stopWhenQueueIsEmpty</i> parameter. If it is false, then this thread will stall until events become available in the event queue. Otherwise, time will advance to the stop time and the execution will halt.</p>
 * @return 0 if firing was successful, and the next event in eventqueue should be checked for processing; -1 if there's no actor to fire, and we should not keep firing; 1 if there's no actor to fire, but the next event should be checked for processing.
 * @exception IllegalActionException If the firing actor throws it, orevent queue is not ready, or an event is missed, or time is set backwards.
 */
protected int _fire() throws IllegalActionException {
  Actor actorToFire=_getNextActorToFire();
  if (actorToFire == null) {
    if (_isTopLevel()) {
      if (_debugging) {
        _debug("String_Node_Str");
      }
      if (!_stopFireRequested) {
        _noMoreActorsToFire=true;
      }
    }
 else {
      if (_debugging) {
        _debug("String_Node_Str" + "String_Node_Str");
      }
    }
    _stopFireRequested=false;
    return -1;
  }
  if (actorToFire == getContainer()) {
    return 1;
  }
  if (_debugging) {
    _debug("String_Node_Str" + actorToFire.getFullName());
  }
  boolean refire;
  do {
    refire=false;
    if (_debugging) {
      if (!((CompositeEntity)getContainer()).deepContains((NamedObj)actorToFire)) {
        _debug("String_Node_Str");
        _disableActor(actorToFire);
        break;
      }
      _debug(new FiringEvent(this,actorToFire,FiringEvent.BEFORE_PREFIRE));
      if (!actorToFire.prefire()) {
        _debug("String_Node_Str");
        break;
      }
      _debug(new FiringEvent(this,actorToFire,FiringEvent.AFTER_PREFIRE));
      _debug(new FiringEvent(this,actorToFire,FiringEvent.BEFORE_FIRE));
      actorToFire.fire();
      _debug(new FiringEvent(this,actorToFire,FiringEvent.AFTER_FIRE));
      _debug(new FiringEvent(this,actorToFire,FiringEvent.BEFORE_POSTFIRE));
      if (!actorToFire.postfire()) {
        _debug("String_Node_Str",((Nameable)actorToFire).getName());
        _disableActor(actorToFire);
        break;
      }
      _debug(new FiringEvent(this,actorToFire,FiringEvent.AFTER_POSTFIRE));
    }
 else {
      if (!((CompositeEntity)getContainer()).deepContains((NamedObj)actorToFire)) {
        _disableActor(actorToFire);
        break;
      }
      if (!actorToFire.prefire()) {
        break;
      }
      actorToFire.fire();
      if (!actorToFire.postfire()) {
        _disableActor(actorToFire);
        break;
      }
    }
    Iterator<?> inputPorts=actorToFire.inputPortList().iterator();
    while (inputPorts.hasNext() && !refire) {
      IOPort port=(IOPort)inputPorts.next();
      for (int i=0; i < port.getWidth(); i++) {
        if (port.hasToken(i)) {
          if (_debugging) {
            _debug("String_Node_Str" + port.getName() + "String_Node_Str"+ i+ "String_Node_Str");
          }
          if (!_aspectsPresent || _schedule(actorToFire,getModelTime())) {
            refire=true;
            break;
          }
 else           if (_aspectsPresent) {
            if (_actorsInExecution == null) {
              _actorsInExecution=new HashMap();
            }
            List<DEEvent> events=_actorsInExecution.get(actorToFire);
            if (events == null) {
              events=new ArrayList<DEEvent>();
            }
            events.add(new DEEvent(actorToFire,getModelTime(),1,_getDepthOfActor(actorToFire)));
            _actorsInExecution.put(actorToFire,events);
          }
        }
      }
    }
  }
 while (refire);
  return 0;
}

Fixed version (ground truth):
/** 
 * Advance the current model tag to that of the earliest event in the event queue, and fire all actors that have requested or are triggered to be fired at the current tag. If <i>synchronizeToRealTime</i> is true, then before firing, wait until real time matches or exceeds the timestamp of the event. Note that the default unit for time is seconds. <p> Each actor is fired repeatedly (prefire(), fire()), until either it has no more input tokens, or its prefire() method returns false. Note that if the actor fails to consume its inputs, then this can result in an infinite loop. Each actor that is fired is then postfired once at the conclusion of the iteration. </p><p> If there are no events in the event queue, then the behavior depends on the <i>stopWhenQueueIsEmpty</i> parameter. If it is false, then this thread will stall until events become available in the event queue. Otherwise, time will advance to the stop time and the execution will halt.</p>
 * @return 0 if firing was successful, and the next event in eventqueue should be checked for processing; -1 if there's no actor to fire, and we should not keep firing; 1 if there's no actor to fire, but the next event should be checked for processing.
 * @exception IllegalActionException If the firing actor throws it, orevent queue is not ready, or an event is missed, or time is set backwards.
 */
protected int _fire() throws IllegalActionException {
  Actor actorToFire=_getNextActorToFire();
  if (actorToFire == null) {
    if (_isTopLevel()) {
      if (_debugging) {
        _debug("String_Node_Str");
      }
      if (!_stopFireRequested) {
        _noMoreActorsToFire=true;
      }
    }
 else {
      if (_debugging) {
        _debug("String_Node_Str" + "String_Node_Str");
      }
    }
    _stopFireRequested=false;
    return -1;
  }
  if (actorToFire == getContainer()) {
    return 1;
  }
  if (_debugging) {
    _debug("String_Node_Str" + actorToFire.getFullName());
  }
  boolean refire;
  do {
    refire=false;
    if (_debugging) {
      if (!((CompositeEntity)getContainer()).deepContains((NamedObj)actorToFire)) {
        _debug("String_Node_Str");
        _disableActor(actorToFire);
        break;
      }
      _debug(new FiringEvent(this,actorToFire,FiringEvent.BEFORE_PREFIRE));
      if (!actorToFire.prefire()) {
        _debug("String_Node_Str");
        break;
      }
      _debug(new FiringEvent(this,actorToFire,FiringEvent.AFTER_PREFIRE));
      _debug(new FiringEvent(this,actorToFire,FiringEvent.BEFORE_FIRE));
      actorToFire.fire();
      _debug(new FiringEvent(this,actorToFire,FiringEvent.AFTER_FIRE));
      _debug(new FiringEvent(this,actorToFire,FiringEvent.BEFORE_POSTFIRE));
      if (!actorToFire.postfire()) {
        _debug("String_Node_Str",((Nameable)actorToFire).getName());
        _disableActor(actorToFire);
        break;
      }
      _debug(new FiringEvent(this,actorToFire,FiringEvent.AFTER_POSTFIRE));
    }
 else {
      if (!((CompositeEntity)getContainer()).deepContains((NamedObj)actorToFire)) {
        _disableActor(actorToFire);
        break;
      }
      if (!actorToFire.prefire()) {
        break;
      }
      actorToFire.fire();
      if (!actorToFire.postfire()) {
        _disableActor(actorToFire);
        break;
      }
    }
    Iterator<?> inputPorts=actorToFire.inputPortList().iterator();
    while (inputPorts.hasNext() && !refire) {
      IOPort port=(IOPort)inputPorts.next();
      for (int i=0; i < port.getWidth(); i++) {
        if (port.hasToken(i)) {
          if (_debugging) {
            _debug("String_Node_Str" + port.getName() + "String_Node_Str"+ i+ "String_Node_Str");
          }
          if (!_aspectsPresent || _schedule(actorToFire,getModelTime())) {
            refire=true;
            break;
          }
 else           if (_aspectsPresent) {
            if (_actorsInExecution == null) {
              _actorsInExecution=new HashMap();
            }
            List<DEEvent> events=_actorsInExecution.get(actorToFire);
            if (events == null) {
              events=new ArrayList<DEEvent>();
            }
            events.add(new DEEvent(port,getModelTime(),1,_getDepthOfActor(actorToFire)));
            _actorsInExecution.put(actorToFire,events);
          }
        }
      }
    }
  }
 while (refire);
  return 0;
}