Program: 174053
Project: 174053
Buggy source:
/** 
 * Completes the tracking by updating the dependencies on the derivation to match the observables that were observed during tracking.
 */
private void completeTracking(){
  if (null == _tracker) {
    return;
  }
  _tracker.invariantDependenciesUnique("String_Node_Str");
  Guards.invariant(() -> _tracker.getState() != ObserverState.NOT_TRACKING,() -> "String_Node_Str");
  ObserverState newDerivationState=ObserverState.UP_TO_DATE;
  if (null == _observables) {
    return;
  }
  final int size=_observables.size();
  int currentIndex=0;
  for (int i=0; i < size; i++) {
    final Observable observable=_observables.get(i);
    if (!observable.isInCurrentTracking()) {
      observable.putInCurrentTracking();
      if (i != currentIndex) {
        _observables.set(currentIndex,observable);
      }
      currentIndex++;
      final Observer observer=observable.getObserver();
      if (null != observer) {
        final ObserverState dependenciesState=observer.getState();
        if (dependenciesState.ordinal() < newDerivationState.ordinal()) {
          newDerivationState=dependenciesState;
        }
      }
    }
  }
  final ArrayList<Observable> dependencies=_tracker.getDependencies();
  for (int i=dependencies.size() - 1; i >= 0; i--) {
    final Observable observable=dependencies.get(i);
    if (!observable.isInCurrentTracking()) {
      observable.removeObserver(_tracker);
    }
  }
  for (int i=currentIndex - 1; i >= 0; i--) {
    final Observable observable=_observables.get(i);
    if (observable.isInCurrentTracking()) {
      observable.removeFromCurrentTracking();
      observable.addObserver(_tracker);
    }
  }
  if (ObserverState.UP_TO_DATE != newDerivationState) {
    _tracker.setState(newDerivationState);
  }
  for (int i=_observables.size() - 1; i > currentIndex; i--) {
    _observables.remove(i);
  }
  _tracker.replaceDependencies(_observables);
}

Fixed version (ground truth):
/** 
 * Completes the tracking by updating the dependencies on the derivation to match the observables that were observed during tracking.
 */
private void completeTracking(){
  if (null == _tracker) {
    return;
  }
  _tracker.invariantDependenciesUnique("String_Node_Str");
  Guards.invariant(() -> _tracker.getState() != ObserverState.NOT_TRACKING,() -> "String_Node_Str");
  ObserverState newDerivationState=ObserverState.UP_TO_DATE;
  if (null == _observables) {
    return;
  }
  final int size=_observables.size();
  int currentIndex=0;
  for (int i=0; i < size; i++) {
    final Observable observable=_observables.get(i);
    if (!observable.isInCurrentTracking()) {
      observable.putInCurrentTracking();
      if (i != currentIndex) {
        _observables.set(currentIndex,observable);
      }
      currentIndex++;
      final Observer observer=observable.getObserver();
      if (null != observer) {
        final ObserverState dependenciesState=observer.getState();
        if (dependenciesState.ordinal() < newDerivationState.ordinal()) {
          newDerivationState=dependenciesState;
        }
      }
    }
  }
  final ArrayList<Observable> dependencies=_tracker.getDependencies();
  for (int i=dependencies.size() - 1; i >= 0; i--) {
    final Observable observable=dependencies.get(i);
    if (!observable.isInCurrentTracking()) {
      observable.removeObserver(_tracker);
    }
  }
  for (int i=currentIndex - 1; i >= 0; i--) {
    final Observable observable=_observables.get(i);
    if (observable.isInCurrentTracking()) {
      observable.removeFromCurrentTracking();
      observable.addObserver(_tracker);
    }
  }
  if (ObserverState.UP_TO_DATE != newDerivationState) {
    _tracker.setState(newDerivationState);
  }
  for (int i=_observables.size() - 1; i >= currentIndex; i--) {
    _observables.remove(i);
  }
  _tracker.replaceDependencies(_observables);
}