Program: 196053
Project: 196053
Buggy source:
void destroySurfaceLocked(){
  if (mWin.mAppToken != null && mWin == mWin.mAppToken.startingWindow) {
    mWin.mAppToken.startingDisplayed=false;
  }
  if (mSurfaceControl != null) {
    int i=mWin.mChildWindows.size();
    while (i > 0) {
      i--;
      WindowState c=mWin.mChildWindows.get(i);
      c.mAttachedHidden=true;
    }
    try {
      if (DEBUG_VISIBILITY) {
        RuntimeException e=null;
        if (!WindowManagerService.HIDE_STACK_CRAWLS) {
          e=new RuntimeException();
          e.fillInStackTrace();
        }
        Slog.w(TAG,"String_Node_Str" + this + "String_Node_Str"+ mSurfaceControl+ "String_Node_Str"+ mSession,e);
      }
      if (mSurfaceDestroyDeferred) {
        if (mSurfaceControl != null && mPendingDestroySurface != mSurfaceControl) {
          if (mPendingDestroySurface != null) {
            if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) {
              RuntimeException e=null;
              if (!WindowManagerService.HIDE_STACK_CRAWLS) {
                e=new RuntimeException();
                e.fillInStackTrace();
              }
              WindowManagerService.logSurface(mWin,"String_Node_Str",e);
            }
            mPendingDestroySurface.destroy();
          }
          mPendingDestroySurface=mSurfaceControl;
        }
      }
 else {
        if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) {
          RuntimeException e=null;
          if (!WindowManagerService.HIDE_STACK_CRAWLS) {
            e=new RuntimeException();
            e.fillInStackTrace();
          }
          WindowManagerService.logSurface(mWin,"String_Node_Str",e);
        }
        mSurfaceControl.destroy();
      }
      mAnimator.hideWallpapersLocked(mWin);
    }
 catch (    RuntimeException e) {
      Slog.w(TAG,"String_Node_Str" + this + "String_Node_Str"+ mSurfaceControl+ "String_Node_Str"+ mSession+ "String_Node_Str"+ e.toString());
    }
    mSurfaceShown=false;
    mSurfaceControl=null;
    mWin.mHasSurface=false;
    mDrawState=NO_SURFACE;
  }
  if (mAppAnimator != null) {
    mAppAnimator.clearDeferredThumbnail();
  }
}

Fixed version (ground truth):
void destroySurfaceLocked(){
  if (mWin.mAppToken != null && mWin == mWin.mAppToken.startingWindow) {
    mWin.mAppToken.startingDisplayed=false;
  }
  if (mSurfaceControl != null) {
    int i=mWin.mChildWindows.size();
    while (i > 0) {
      i--;
      WindowState c=mWin.mChildWindows.get(i);
      c.mAttachedHidden=true;
    }
    try {
      if (DEBUG_VISIBILITY) {
        RuntimeException e=null;
        if (!WindowManagerService.HIDE_STACK_CRAWLS) {
          e=new RuntimeException();
          e.fillInStackTrace();
        }
        Slog.w(TAG,"String_Node_Str" + this + "String_Node_Str"+ mSurfaceControl+ "String_Node_Str"+ mSession,e);
      }
      if (mSurfaceDestroyDeferred) {
        if (mSurfaceControl != null && mPendingDestroySurface != mSurfaceControl) {
          if (mPendingDestroySurface != null) {
            if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) {
              RuntimeException e=null;
              if (!WindowManagerService.HIDE_STACK_CRAWLS) {
                e=new RuntimeException();
                e.fillInStackTrace();
              }
              WindowManagerService.logSurface(mWin,"String_Node_Str",e);
            }
            mPendingDestroySurface.destroy();
          }
          mPendingDestroySurface=mSurfaceControl;
        }
      }
 else {
        if (SHOW_TRANSACTIONS || SHOW_SURFACE_ALLOC) {
          RuntimeException e=null;
          if (!WindowManagerService.HIDE_STACK_CRAWLS) {
            e=new RuntimeException();
            e.fillInStackTrace();
          }
          WindowManagerService.logSurface(mWin,"String_Node_Str",e);
        }
        mSurfaceControl.destroy();
      }
      mAnimator.hideWallpapersLocked(mWin);
    }
 catch (    RuntimeException e) {
      Slog.w(TAG,"String_Node_Str" + this + "String_Node_Str"+ mSurfaceControl+ "String_Node_Str"+ mSession+ "String_Node_Str"+ e.toString());
    }
    mSurfaceShown=false;
    mSurfaceControl=null;
    mWin.mHasSurface=false;
    mDrawState=NO_SURFACE;
  }
}