Program: 74321
Project: 74321
Buggy source:
/** 
 * Get the list of events that are safe to fire. Those events contain pure events and triggered events.
 * @return List of events that can be fired next.
 */
private List<TimedEvent> _getNextEventsToFire() throws IllegalActionException {
  List<TimedEvent> events=new LinkedList<TimedEvent>();
  for (  Actor actor : _eventQueues.keySet()) {
    TreeSet<Time> set=_eventQueues.get(actor);
    if (!set.isEmpty()) {
      Time time=set.first();
      events.add(new TimedEvent(time,actor));
    }
    if (!_eventsInExecution.contains(actor)) {
      List<IOPort> inputPorts=actor.inputPortList();
      for (      IOPort port : inputPorts) {
        if (PtidesActorProperties.portIsTriggerPort(port)) {
          Receiver[][] receivers=port.getReceivers();
          for (int i=0; i < receivers.length; i++) {
            Receiver[] recv=receivers[i];
            for (int j=0; j < recv.length; j++) {
              PtidesActorReceiver receiver=(PtidesActorReceiver)recv[j];
              Time time=receiver.getNextTime();
              if (time != null && (isSafeToProcessStatically(time,port) || _isSafeToProcess(port,new ArrayList(),new Time(this,0.0),time))) {
                List<TimedEvent> toRemove=new ArrayList<TimedEvent>();
                for (int k=0; k < events.size(); k++) {
                  TimedEvent event=events.get(k);
                  if (event.contents == actor && event.timeStamp.equals(time))                   toRemove.add(event);
                }
                for (int k=0; k < toRemove.size(); k++)                 events.remove(toRemove.get(k));
                events.add(new TimedEvent(time,port));
              }
            }
          }
        }
      }
    }
  }
  return events;
}

Fixed version (ground truth):
/** 
 * Get the list of events that are safe to fire. Those events contain pure events and triggered events.
 * @return List of events that can be fired next.
 */
private List<TimedEvent> _getNextEventsToFire() throws IllegalActionException {
  List<TimedEvent> events=new LinkedList<TimedEvent>();
  for (  Actor actor : _eventQueues.keySet()) {
    TreeSet<Time> set=_eventQueues.get(actor);
    for (    TimedEvent event : _eventsInExecution) {
      if (event.contents == actor)       continue;
    }
    if (!set.isEmpty()) {
      Time time=set.first();
      _currentModelTime=time;
      if (actor.prefire())       events.add(new TimedEvent(time,actor));
      _currentModelTime=null;
    }
    List<IOPort> inputPorts=actor.inputPortList();
    for (    IOPort port : inputPorts) {
      if (PtidesActorProperties.portIsTriggerPort(port)) {
        Receiver[][] receivers=port.getReceivers();
        for (int i=0; i < receivers.length; i++) {
          Receiver[] recv=receivers[i];
          for (int j=0; j < recv.length; j++) {
            PtidesActorReceiver receiver=(PtidesActorReceiver)recv[j];
            Time time=receiver.getNextTime();
            if (time != null && (isSafeToProcessStatically(time,port) || _isSafeToProcess(port,new ArrayList(),new Time(this,0.0),time))) {
              List<TimedEvent> toRemove=new ArrayList<TimedEvent>();
              for (int k=0; k < events.size(); k++) {
                TimedEvent event=events.get(k);
                if (event.contents == actor && event.timeStamp.equals(time))                 toRemove.add(event);
              }
              for (int k=0; k < toRemove.size(); k++)               events.remove(toRemove.get(k));
              events.add(new TimedEvent(time,port));
            }
          }
        }
      }
    }
  }
  return events;
}