Program: 183137
Project: 183137
Buggy source:
private final void performLayoutLockedInner(){
  final int dw=mDisplay.getWidth();
  final int dh=mDisplay.getHeight();
  final int N=mWindows.size();
  int repeats=0;
  int i;
  while (mLayoutNeeded) {
    mPolicy.beginLayoutLw(dw,dh);
    int topAttached=-1;
    for (i=N - 1; i >= 0; i--) {
      WindowState win=(WindowState)mWindows.get(i);
      final AppWindowToken atoken=win.mAppToken;
      final boolean gone=win.mViewVisibility == View.GONE || !win.mRelayoutCalled || win.mRootToken.hidden || (atoken != null && atoken.hiddenRequested) || !win.mPolicyVisibility || win.mAttachedHidden || win.mExiting || win.mDestroying;
      if (!gone || !win.mHaveFrame) {
        if (!win.mLayoutAttached) {
          mPolicy.layoutWindowLw(win,win.mAttrs,null);
        }
 else {
          if (topAttached < 0)           topAttached=i;
        }
      }
    }
    for (i=topAttached; i >= 0; i--) {
      WindowState win=(WindowState)mWindows.get(i);
      if (win.mLayoutAttached) {
        if ((win.mViewVisibility != View.GONE && win.mRelayoutCalled) || !win.mHaveFrame) {
          mPolicy.layoutWindowLw(win,win.mAttrs,win.mAttachedWindow);
        }
      }
    }
    int changes=mPolicy.finishLayoutLw();
    if ((changes & WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER) != 0) {
      if ((adjustWallpaperWindowsLocked() & ADJUST_WALLPAPER_LAYERS_CHANGED) != 0) {
        assignLayersLocked();
      }
    }
    if (changes == 0) {
      mLayoutNeeded=false;
    }
 else     if (repeats > 2) {
      Log.w(TAG,"String_Node_Str");
      mLayoutNeeded=false;
      if ((changes & WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG) != 0) {
        Configuration newConfig=updateOrientationFromAppTokensLocked(null,null);
        if (newConfig != null) {
          mLayoutNeeded=true;
          mH.sendEmptyMessage(H.COMPUTE_AND_SEND_NEW_CONFIGURATION);
        }
      }
    }
 else {
      repeats++;
      if ((changes & WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG) != 0) {
        Configuration newConfig=updateOrientationFromAppTokensLocked(null,null);
        if (newConfig != null) {
          mH.sendEmptyMessage(H.COMPUTE_AND_SEND_NEW_CONFIGURATION);
        }
      }
    }
  }
}

Fixed version (ground truth):
private final void performLayoutLockedInner(){
  final int dw=mDisplay.getWidth();
  final int dh=mDisplay.getHeight();
  final int N=mWindows.size();
  int repeats=0;
  int i;
  while (mLayoutNeeded) {
    mPolicy.beginLayoutLw(dw,dh);
    int topAttached=-1;
    for (i=N - 1; i >= 0; i--) {
      WindowState win=(WindowState)mWindows.get(i);
      final AppWindowToken atoken=win.mAppToken;
      final boolean gone=win.mViewVisibility == View.GONE || !win.mRelayoutCalled || win.mRootToken.hidden || (atoken != null && atoken.hiddenRequested) || win.mAttachedHidden || win.mExiting || win.mDestroying;
      if (!gone || !win.mHaveFrame) {
        if (!win.mLayoutAttached) {
          mPolicy.layoutWindowLw(win,win.mAttrs,null);
        }
 else {
          if (topAttached < 0)           topAttached=i;
        }
      }
    }
    for (i=topAttached; i >= 0; i--) {
      WindowState win=(WindowState)mWindows.get(i);
      if (win.mLayoutAttached) {
        if ((win.mViewVisibility != View.GONE && win.mRelayoutCalled) || !win.mHaveFrame) {
          mPolicy.layoutWindowLw(win,win.mAttrs,win.mAttachedWindow);
        }
      }
    }
    int changes=mPolicy.finishLayoutLw();
    if ((changes & WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER) != 0) {
      if ((adjustWallpaperWindowsLocked() & ADJUST_WALLPAPER_LAYERS_CHANGED) != 0) {
        assignLayersLocked();
      }
    }
    if (changes == 0) {
      mLayoutNeeded=false;
    }
 else     if (repeats > 2) {
      Log.w(TAG,"String_Node_Str");
      mLayoutNeeded=false;
      if ((changes & WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG) != 0) {
        Configuration newConfig=updateOrientationFromAppTokensLocked(null,null);
        if (newConfig != null) {
          mLayoutNeeded=true;
          mH.sendEmptyMessage(H.COMPUTE_AND_SEND_NEW_CONFIGURATION);
        }
      }
    }
 else {
      repeats++;
      if ((changes & WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG) != 0) {
        Configuration newConfig=updateOrientationFromAppTokensLocked(null,null);
        if (newConfig != null) {
          mH.sendEmptyMessage(H.COMPUTE_AND_SEND_NEW_CONFIGURATION);
        }
      }
    }
  }
}