Program: 66257
Project: 66257
Buggy source:
/** 
 * Do grouping, and fill group indexes
 * @param stopsign
 * @throws DataException
 */
public void next(int rowId) throws DataException {
  int breakLevel;
  if (this.previous == null)   breakLevel=0;
 else   breakLevel=getBreakLevel(this.current,this.previous);
  try {
    for (int level=breakLevel; level < groupInstanceIndex.length; level++) {
      GroupInfo group=new GroupInfo();
      if (level != 0)       group.parent=groupInstanceIndex[level - 1] - 1;
      if (level == groupInstanceIndex.length - 1) {
        group.firstChild=rowId;
      }
 else {
        group.firstChild=groupInstanceIndex[level + 1];
      }
      groupInstanceIndex[level]++;
      if (this.streamManager != null) {
        IOUtil.writeInt(this.groupOutput[level],group.parent);
        IOUtil.writeInt(this.groupOutput[level],group.firstChild);
        this.groupOutput[level].flush();
        if (this.previous != null) {
          saveToAggrValuesToDocument(level,rowId);
        }
      }
    }
    this.aggrHelper.onRow(this.getStartingGroup(),this.getEndingGroup(),this.current,rowId);
    if (this.runningAggrs.size() > 0) {
      for (      String aggrName : this.runningAggrs) {
        IOUtil.writeObject(this.combinedAggrOutput,this.aggrHelper.getLatestAggrValue(aggrName));
      }
      IOUtil.writeLong(this.combinedAggrIndexOutput,this.combinedAggrRAOutput.getOffset());
    }
    if (this.next == null) {
      for (int i=0; i < this.aggrOutput.length; i++) {
        saveToAggrValuesToDocument(i,rowId);
      }
      if (this.overallAggrs.size() > 0 && this.combinedAggrIndexOutput != null) {
        this.combinedAggrIndexRAOutput.seek(0);
        IOUtil.writeLong(this.combinedAggrIndexOutput,this.combinedAggrRAOutput.getOffset());
        for (        String aggrName : overallAggrs) {
          IOUtil.writeObject(this.combinedAggrOutput,this.aggrHelper.getLatestAggrValue(aggrName));
        }
      }
    }
  }
 catch (  IOException e) {
    throw new DataException(e.getLocalizedMessage(),e);
  }
}

Fixed version (ground truth):
/** 
 * Do grouping, and fill group indexes
 * @param stopsign
 * @throws DataException
 */
public void next(int rowId) throws DataException {
  int breakLevel;
  if (this.previous == null)   breakLevel=0;
 else   breakLevel=getBreakLevel(this.current,this.previous);
  try {
    for (int level=breakLevel; level < groupInstanceIndex.length; level++) {
      GroupInfo group=new GroupInfo();
      if (level != 0)       group.parent=groupInstanceIndex[level - 1] - 1;
      if (level == groupInstanceIndex.length - 1) {
        group.firstChild=rowId;
      }
 else {
        group.firstChild=groupInstanceIndex[level + 1];
      }
      groupInstanceIndex[level]++;
      if (this.streamManager != null) {
        IOUtil.writeInt(this.groupOutput[level],group.parent);
        IOUtil.writeInt(this.groupOutput[level],group.firstChild);
        this.groupOutput[level].flush();
        if (this.previous != null) {
          saveToAggrValuesToDocument(level,rowId);
        }
      }
    }
    this.aggrHelper.onRow(this.getStartingGroup(),this.getEndingGroup(),this.current,rowId);
    if (this.runningAggrs.size() > 0 && this.combinedAggrOutput != null && this.combinedAggrRAOutput != null && this.combinedAggrIndexOutput != null) {
      for (      String aggrName : this.runningAggrs) {
        IOUtil.writeObject(this.combinedAggrOutput,this.aggrHelper.getLatestAggrValue(aggrName));
      }
      IOUtil.writeLong(this.combinedAggrIndexOutput,this.combinedAggrRAOutput.getOffset());
    }
    if (this.next == null) {
      for (int i=0; i < this.aggrOutput.length; i++) {
        saveToAggrValuesToDocument(i,rowId);
      }
      if (this.overallAggrs.size() > 0 && this.combinedAggrIndexOutput != null && this.combinedAggrIndexRAOutput != null && this.combinedAggrRAOutput != null && this.combinedAggrOutput != null) {
        this.combinedAggrIndexRAOutput.seek(0);
        IOUtil.writeLong(this.combinedAggrIndexOutput,this.combinedAggrRAOutput.getOffset());
        for (        String aggrName : overallAggrs) {
          IOUtil.writeObject(this.combinedAggrOutput,this.aggrHelper.getLatestAggrValue(aggrName));
        }
      }
    }
  }
 catch (  IOException e) {
    throw new DataException(e.getLocalizedMessage(),e);
  }
}