Program: 3523
Project: 3523
Buggy source:
@Override public void onLayoutChildren(RecyclerView.Recycler recycler,RecyclerView.State state){
  if (getItemCount() == 0) {
    detachAndScrapAttachedViews(recycler);
    return;
  }
  if (getChildCount() == 0) {
    View scrap=recycler.getViewForPosition(0);
    addView(scrap);
    measureChildWithMargins(scrap,0,0);
    mDecoratedChildWidth=getDecoratedMeasuredWidth(scrap);
    mDecoratedChildHeight=getDecoratedMeasuredHeight(scrap);
    detachAndScrapView(scrap,recycler);
  }
  updateWindowSizing();
  int childLeft;
  int childTop;
  if (getChildCount() == 0) {
    mFirstVisiblePosition=0;
    childLeft=childTop=0;
  }
 else   if (getVisibleChildCount() > getItemCount()) {
    mFirstVisiblePosition=0;
    childLeft=childTop=0;
  }
 else {
    final View topChild=getChildAt(0);
    if (mForceClearOffsets) {
      childLeft=childTop=0;
      mForceClearOffsets=false;
    }
 else {
      childLeft=getDecoratedLeft(topChild);
      childTop=getDecoratedTop(topChild);
    }
    int lastVisiblePosition=positionOfIndex(getVisibleChildCount() - 1);
    if (lastVisiblePosition >= getItemCount()) {
      lastVisiblePosition=(getItemCount() - 1);
      int lastColumn=mVisibleColumnCount - 1;
      int lastRow=mVisibleRowCount - 1;
      mFirstVisiblePosition=Math.max(lastVisiblePosition - lastColumn - (lastRow * getTotalColumnCount()),0);
      childLeft=getHorizontalSpace() - (mDecoratedChildWidth * mVisibleColumnCount);
      childTop=getVerticalSpace() - (mDecoratedChildHeight * mVisibleRowCount);
      if (getFirstVisibleRow() == 0) {
        childTop=Math.min(childTop,0);
      }
      if (getFirstVisibleColumn() == 0) {
        childLeft=Math.min(childLeft,0);
      }
    }
  }
  detachAndScrapAttachedViews(recycler);
  fillGrid(DIRECTION_NONE,childLeft,childTop,recycler);
}

Fixed version (ground truth):
@Override public void onLayoutChildren(RecyclerView.Recycler recycler,RecyclerView.State state){
  if (getItemCount() == 0) {
    detachAndScrapAttachedViews(recycler);
    return;
  }
  if (getChildCount() == 0) {
    View scrap=recycler.getViewForPosition(0);
    addView(scrap);
    measureChildWithMargins(scrap,0,0);
    mDecoratedChildWidth=getDecoratedMeasuredWidth(scrap);
    mDecoratedChildHeight=getDecoratedMeasuredHeight(scrap);
    detachAndScrapView(scrap,recycler);
  }
  updateWindowSizing();
  int childLeft;
  int childTop;
  if (getChildCount() == 0) {
    mFirstVisiblePosition=0;
    childLeft=childTop=0;
  }
 else   if (getVisibleChildCount() > getItemCount()) {
    mFirstVisiblePosition=0;
    childLeft=childTop=0;
  }
 else {
    final View topChild=getChildAt(0);
    if (mForceClearOffsets) {
      childLeft=childTop=0;
      mForceClearOffsets=false;
    }
 else {
      childLeft=getDecoratedLeft(topChild);
      childTop=getDecoratedTop(topChild);
    }
    int maxFirstRow=getTotalRowCount() - (mVisibleRowCount - 1);
    int maxFirstCol=getTotalColumnCount() - (mVisibleColumnCount - 1);
    boolean isOutOfRowBounds=getFirstVisibleRow() > maxFirstRow;
    boolean isOutOfColBounds=getFirstVisibleColumn() > maxFirstCol;
    if (isOutOfRowBounds || isOutOfColBounds) {
      int firstRow;
      if (isOutOfRowBounds) {
        firstRow=maxFirstRow;
      }
 else {
        firstRow=getFirstVisibleRow();
      }
      int firstCol;
      if (isOutOfColBounds) {
        firstCol=maxFirstCol;
      }
 else {
        firstCol=getFirstVisibleColumn();
      }
      mFirstVisiblePosition=firstRow * getTotalColumnCount() + firstCol;
      childLeft=getHorizontalSpace() - (mDecoratedChildWidth * mVisibleColumnCount);
      childTop=getVerticalSpace() - (mDecoratedChildHeight * mVisibleRowCount);
      if (getFirstVisibleRow() == 0) {
        childTop=Math.min(childTop,0);
      }
      if (getFirstVisibleColumn() == 0) {
        childLeft=Math.min(childLeft,0);
      }
    }
  }
  detachAndScrapAttachedViews(recycler);
  fillGrid(DIRECTION_NONE,childLeft,childTop,recycler);
}