Program: 110359
Project: 110359
Buggy source:
@Override public void selectTracks(TrackSelection[] selections,boolean[] mayRetainStreamFlags,SampleStream[] streams,boolean[] streamResetFlags,long positionUs){
  int[] streamChildIndices=new int[selections.length];
  int[] selectionChildIndices=new int[selections.length];
  for (int i=0; i < selections.length; i++) {
    streamChildIndices[i]=streams[i] == null ? -1 : streamPeriodIndices.get(streams[i]);
    selectionChildIndices[i]=-1;
    if (selections[i] != null) {
      TrackGroup trackGroup=selections[i].getTrackGroup();
      for (int j=0; j < periods.length; j++) {
        if (periods[j].getTrackGroups().indexOf(trackGroup) != -1) {
          selectionChildIndices[i]=j;
          break;
        }
      }
    }
  }
  streamPeriodIndices.clear();
  SampleStream[] childStreams=new SampleStream[selections.length];
  TrackSelection[] childSelections=new TrackSelection[selections.length];
  ArrayList<MediaPeriod> enabledPeriodsList=new ArrayList<>(periods.length);
  for (int i=0; i < periods.length; i++) {
    for (int j=0; j < selections.length; j++) {
      childStreams[j]=streamChildIndices[j] == i ? streams[j] : null;
      childSelections[j]=selectionChildIndices[j] == i ? selections[j] : null;
    }
    periods[i].selectTracks(childSelections,mayRetainStreamFlags,childStreams,streamResetFlags,positionUs);
    boolean periodEnabled=false;
    for (int j=0; j < selections.length; j++) {
      if (selectionChildIndices[j] == i) {
        streams[j]=childStreams[j];
        if (childStreams[j] != null) {
          periodEnabled=true;
          streamPeriodIndices.put(childStreams[j],i);
        }
      }
    }
    if (periodEnabled) {
      enabledPeriodsList.add(periods[i]);
    }
  }
  enabledPeriods=new MediaPeriod[enabledPeriodsList.size()];
  enabledPeriodsList.toArray(enabledPeriods);
  sequenceableLoader=new CompositeSequenceableLoader(enabledPeriods);
}

Fixed version (ground truth):
@Override public long selectTracks(TrackSelection[] selections,boolean[] mayRetainStreamFlags,SampleStream[] streams,boolean[] streamResetFlags,long positionUs){
  int[] streamChildIndices=new int[selections.length];
  int[] selectionChildIndices=new int[selections.length];
  for (int i=0; i < selections.length; i++) {
    streamChildIndices[i]=streams[i] == null ? -1 : streamPeriodIndices.get(streams[i]);
    selectionChildIndices[i]=-1;
    if (selections[i] != null) {
      TrackGroup trackGroup=selections[i].getTrackGroup();
      for (int j=0; j < periods.length; j++) {
        if (periods[j].getTrackGroups().indexOf(trackGroup) != -1) {
          selectionChildIndices[i]=j;
          break;
        }
      }
    }
  }
  streamPeriodIndices.clear();
  SampleStream[] childStreams=new SampleStream[selections.length];
  TrackSelection[] childSelections=new TrackSelection[selections.length];
  ArrayList<MediaPeriod> enabledPeriodsList=new ArrayList<>(periods.length);
  for (int i=0; i < periods.length; i++) {
    for (int j=0; j < selections.length; j++) {
      childStreams[j]=streamChildIndices[j] == i ? streams[j] : null;
      childSelections[j]=selectionChildIndices[j] == i ? selections[j] : null;
    }
    long selectPositionUs=periods[i].selectTracks(childSelections,mayRetainStreamFlags,childStreams,streamResetFlags,positionUs);
    if (i == 0) {
      positionUs=selectPositionUs;
    }
 else     if (selectPositionUs != positionUs) {
      throw new IllegalStateException("String_Node_Str");
    }
    boolean periodEnabled=false;
    for (int j=0; j < selections.length; j++) {
      if (selectionChildIndices[j] == i) {
        streams[j]=childStreams[j];
        if (childStreams[j] != null) {
          periodEnabled=true;
          streamPeriodIndices.put(childStreams[j],i);
        }
      }
    }
    if (periodEnabled) {
      enabledPeriodsList.add(periods[i]);
    }
  }
  enabledPeriods=new MediaPeriod[enabledPeriodsList.size()];
  enabledPeriodsList.toArray(enabledPeriods);
  sequenceableLoader=new CompositeSequenceableLoader(enabledPeriods);
  return positionUs;
}