Program: 16141
Project: 16141
Buggy source:
int addRowTry(Row row) throws SQLException {
  int rowLength=row.getByteCount(data);
  int pageSize=index.getPageStore().getPageSize();
  int last=entryCount == 0 ? pageSize : offsets[entryCount - 1];
  if (entryCount > 0 && last - rowLength < start + KEY_OFFSET_PAIR_LENGTH) {
    if (entryCount > 1) {
      return entryCount / 2;
    }
    int todoIncorrect;
    if (find(row.getPos()) != 1) {
      System.out.println("String_Node_Str" + find(row.getPos()));
    }
    return 1;
  }
  int offset=last - rowLength;
  int[] newOffsets=new int[entryCount + 1];
  int[] newKeys=new int[entryCount + 1];
  Row[] newRows=new Row[entryCount + 1];
  int x;
  if (entryCount == 0) {
    x=0;
  }
 else {
    readAllRows();
    x=find(row.getPos());
    if (SysProperties.CHECK && x < keys.length && keys[x] == row.getPos()) {
      throw Message.throwInternalError("String_Node_Str" + row.getPos());
    }
    System.arraycopy(offsets,0,newOffsets,0,x);
    System.arraycopy(keys,0,newKeys,0,x);
    System.arraycopy(rows,0,newRows,0,x);
    if (x < entryCount) {
      for (int j=x; j < entryCount; j++) {
        newOffsets[j + 1]=offsets[j] - rowLength;
      }
      System.arraycopy(keys,x,newKeys,x + 1,entryCount - x);
      System.arraycopy(rows,x,newRows,x + 1,entryCount - x);
    }
  }
  written=false;
  last=x == 0 ? pageSize : offsets[x - 1];
  offset=last - rowLength;
  entryCount++;
  start+=KEY_OFFSET_PAIR_LENGTH;
  newOffsets[x]=offset;
  newKeys[x]=row.getPos();
  newRows[x]=row;
  offsets=newOffsets;
  keys=newKeys;
  rows=newRows;
  index.getPageStore().updateRecord(this,true,data);
  if (offset < start) {
    if (entryCount > 1) {
      Message.throwInternalError();
    }
    start+=4;
    int remaining=rowLength - (pageSize - start);
    offset=start;
    offsets[x]=offset;
    int previous=getPos();
    int dataOffset=pageSize;
    int page=index.getPageStore().allocatePage();
    firstOverflowPageId=page;
    this.overflowRowSize=pageSize + rowLength;
    write();
    rowRef=new SoftReference<Row>(rows[0]);
    rows[0]=null;
    do {
      int type, size, next;
      if (remaining <= pageSize - PageDataOverflow.START_LAST) {
        type=Page.TYPE_DATA_OVERFLOW | Page.FLAG_LAST;
        size=remaining;
        next=0;
      }
 else {
        type=Page.TYPE_DATA_OVERFLOW;
        size=pageSize - PageDataOverflow.START_MORE;
        next=index.getPageStore().allocatePage();
      }
      PageDataOverflow overflow=new PageDataOverflow(this,page,type,previous,next,data,dataOffset,size);
      index.getPageStore().updateRecord(overflow,true,null);
      dataOffset+=size;
      remaining-=size;
      previous=page;
      page=next;
    }
 while (remaining > 0);
    data.truncate(index.getPageStore().getPageSize());
  }
  return -1;
}

Fixed version (ground truth):
int addRowTry(Row row) throws SQLException {
  int rowLength=row.getByteCount(data);
  int pageSize=index.getPageStore().getPageSize();
  int last=entryCount == 0 ? pageSize : offsets[entryCount - 1];
  if (entryCount > 0 && last - rowLength < start + KEY_OFFSET_PAIR_LENGTH) {
    if (entryCount > 1) {
      return entryCount / 2;
    }
    return find(row.getPos());
  }
  int offset=last - rowLength;
  int[] newOffsets=new int[entryCount + 1];
  int[] newKeys=new int[entryCount + 1];
  Row[] newRows=new Row[entryCount + 1];
  int x;
  if (entryCount == 0) {
    x=0;
  }
 else {
    readAllRows();
    x=find(row.getPos());
    if (SysProperties.CHECK && x < keys.length && keys[x] == row.getPos()) {
      throw Message.throwInternalError("String_Node_Str" + row.getPos());
    }
    System.arraycopy(offsets,0,newOffsets,0,x);
    System.arraycopy(keys,0,newKeys,0,x);
    System.arraycopy(rows,0,newRows,0,x);
    if (x < entryCount) {
      for (int j=x; j < entryCount; j++) {
        newOffsets[j + 1]=offsets[j] - rowLength;
      }
      System.arraycopy(keys,x,newKeys,x + 1,entryCount - x);
      System.arraycopy(rows,x,newRows,x + 1,entryCount - x);
    }
  }
  written=false;
  last=x == 0 ? pageSize : offsets[x - 1];
  offset=last - rowLength;
  entryCount++;
  start+=KEY_OFFSET_PAIR_LENGTH;
  newOffsets[x]=offset;
  newKeys[x]=row.getPos();
  newRows[x]=row;
  offsets=newOffsets;
  keys=newKeys;
  rows=newRows;
  index.getPageStore().updateRecord(this,true,data);
  if (offset < start) {
    if (entryCount > 1) {
      Message.throwInternalError();
    }
    start+=4;
    int remaining=rowLength - (pageSize - start);
    offset=start;
    offsets[x]=offset;
    int previous=getPos();
    int dataOffset=pageSize;
    int page=index.getPageStore().allocatePage();
    firstOverflowPageId=page;
    this.overflowRowSize=pageSize + rowLength;
    write();
    rowRef=new SoftReference<Row>(rows[0]);
    rows[0]=null;
    do {
      int type, size, next;
      if (remaining <= pageSize - PageDataOverflow.START_LAST) {
        type=Page.TYPE_DATA_OVERFLOW | Page.FLAG_LAST;
        size=remaining;
        next=0;
      }
 else {
        type=Page.TYPE_DATA_OVERFLOW;
        size=pageSize - PageDataOverflow.START_MORE;
        next=index.getPageStore().allocatePage();
      }
      PageDataOverflow overflow=new PageDataOverflow(this,page,type,previous,next,data,dataOffset,size);
      index.getPageStore().updateRecord(overflow,true,null);
      dataOffset+=size;
      remaining-=size;
      previous=page;
      page=next;
    }
 while (remaining > 0);
    data.truncate(index.getPageStore().getPageSize());
  }
  return -1;
}