Program: 192929
Project: 192929
Buggy source:
void destroySurfaceLocked(){
  final AppWindowToken wtoken=mWin.mAppToken;
  if (wtoken != null) {
    wtoken.mAnimatingWithSavedSurface=false;
    if (mWin == wtoken.startingWindow) {
      wtoken.startingDisplayed=false;
    }
  }
  mWin.mSurfaceSaved=false;
  if (mSurfaceController != null) {
    int i=mWin.mChildWindows.size();
    while (!mDestroyPreservedSurfaceUponRedraw && i > 0) {
      i--;
      WindowState c=mWin.mChildWindows.get(i);
      c.mAttachedHidden=true;
    }
    try {
      if (DEBUG_VISIBILITY) {
        RuntimeException e=null;
        if (!HIDE_STACK_CRAWLS) {
          e=new RuntimeException();
          e.fillInStackTrace();
        }
        Slog.w(TAG,"String_Node_Str" + this + "String_Node_Str"+ mSurfaceController+ "String_Node_Str"+ mSession,e);
      }
      if (mSurfaceDestroyDeferred) {
        if (mSurfaceController != null && mPendingDestroySurface != mSurfaceController) {
          if (mPendingDestroySurface != null) {
            if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) {
              RuntimeException e=null;
              if (!HIDE_STACK_CRAWLS) {
                e=new RuntimeException();
                e.fillInStackTrace();
              }
              WindowManagerService.logSurface(mWin,"String_Node_Str",e);
            }
            mPendingDestroySurface.destroyInTransaction();
          }
          mPendingDestroySurface=mSurfaceController;
        }
      }
 else {
        if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) {
          RuntimeException e=null;
          if (!HIDE_STACK_CRAWLS) {
            e=new RuntimeException();
            e.fillInStackTrace();
          }
          WindowManagerService.logSurface(mWin,"String_Node_Str",null);
        }
        destroySurface();
      }
      if (!(mSurfaceDestroyDeferred && mDestroyPreservedSurfaceUponRedraw)) {
        mWallpaperControllerLocked.hideWallpapers(mWin);
      }
    }
 catch (    RuntimeException e) {
      Slog.w(TAG,"String_Node_Str" + this + "String_Node_Str"+ mSurfaceController+ "String_Node_Str"+ mSession+ "String_Node_Str"+ e.toString());
    }
    mWin.setHasSurface(false);
    if (mSurfaceController != null) {
      mSurfaceController.setShown(false);
    }
    mSurfaceController=null;
    mDrawState=NO_SURFACE;
  }
}

Fixed version (ground truth):
void destroySurfaceLocked(){
  final AppWindowToken wtoken=mWin.mAppToken;
  if (wtoken != null) {
    wtoken.mAnimatingWithSavedSurface=false;
    if (mWin == wtoken.startingWindow) {
      wtoken.startingDisplayed=false;
    }
  }
  mWin.mSurfaceSaved=false;
  if (mSurfaceController != null) {
    int i=mWin.mChildWindows.size();
    while (!mDestroyPreservedSurfaceUponRedraw && i > 0) {
      i--;
      WindowState c=mWin.mChildWindows.get(i);
      c.mAttachedHidden=true;
    }
    try {
      if (DEBUG_VISIBILITY)       logWithStack(TAG,"String_Node_Str" + this + "String_Node_Str"+ mSurfaceController+ "String_Node_Str"+ mSession);
      if (mSurfaceDestroyDeferred) {
        if (mSurfaceController != null && mPendingDestroySurface != mSurfaceController) {
          if (mPendingDestroySurface != null) {
            if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) {
              WindowManagerService.logSurface(mWin,"String_Node_Str",true);
            }
            mPendingDestroySurface.destroyInTransaction();
          }
          mPendingDestroySurface=mSurfaceController;
        }
      }
 else {
        if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) {
          WindowManagerService.logSurface(mWin,"String_Node_Str",true);
        }
        destroySurface();
      }
      if (!(mSurfaceDestroyDeferred && mDestroyPreservedSurfaceUponRedraw)) {
        mWallpaperControllerLocked.hideWallpapers(mWin);
      }
    }
 catch (    RuntimeException e) {
      Slog.w(TAG,"String_Node_Str" + this + "String_Node_Str"+ mSurfaceController+ "String_Node_Str"+ mSession+ "String_Node_Str"+ e.toString());
    }
    mWin.setHasSurface(false);
    if (mSurfaceController != null) {
      mSurfaceController.setShown(false);
    }
    mSurfaceController=null;
    mDrawState=NO_SURFACE;
  }
}