Program: 42038
Project: 42038
Buggy source:
void destroySurfaceLocked(){
  mKeyWaiter.finishedKey(mSession,mClient,true,KeyWaiter.RETURN_NOTHING);
  mKeyWaiter.releasePendingPointerLocked(mSession);
  mKeyWaiter.releasePendingTrackballLocked(mSession);
  if (mAppToken != null && this == mAppToken.startingWindow) {
    mAppToken.startingDisplayed=false;
  }
  if (mSurface != null) {
    mDrawPending=false;
    mCommitDrawPending=false;
    mReadyToShow=false;
    int i=mChildWindows.size();
    while (i > 0) {
      i--;
      WindowState c=(WindowState)mChildWindows.get(i);
      c.mAttachedHidden=true;
    }
    if (mReportDestroySurface) {
      mReportDestroySurface=false;
      mSurfacePendingDestroy=true;
      try {
        mClient.dispatchGetNewSurface();
        return;
      }
 catch (      RemoteException e) {
      }
    }
    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"+ mSurface+ "String_Node_Str"+ mSession,e);
      }
      if (SHOW_TRANSACTIONS) {
        RuntimeException e=null;
        if (!HIDE_STACK_CRAWLS) {
          e=new RuntimeException();
          e.fillInStackTrace();
        }
        if (SHOW_TRANSACTIONS)         logSurface(this,"String_Node_Str",e);
      }
      mSurface.destroy();
    }
 catch (    RuntimeException e) {
      Slog.w(TAG,"String_Node_Str" + this + "String_Node_Str"+ mSurface+ "String_Node_Str"+ mSession+ "String_Node_Str"+ e.toString());
    }
    mSurface=null;
  }
}

Fixed version (ground truth):
void destroySurfaceLocked(){
  mKeyWaiter.finishedKey(mSession,mClient,true,KeyWaiter.RETURN_NOTHING);
  mKeyWaiter.releasePendingPointerLocked(mSession);
  mKeyWaiter.releasePendingTrackballLocked(mSession);
  if (mAppToken != null && this == mAppToken.startingWindow) {
    mAppToken.startingDisplayed=false;
  }
  if (mSurface != null) {
    mDrawPending=false;
    mCommitDrawPending=false;
    mReadyToShow=false;
    int i=mChildWindows.size();
    while (i > 0) {
      i--;
      WindowState c=(WindowState)mChildWindows.get(i);
      c.mAttachedHidden=true;
    }
    if (mReportDestroySurface) {
      mReportDestroySurface=false;
      mSurfacePendingDestroy=true;
      try {
        mClient.dispatchGetNewSurface();
        return;
      }
 catch (      RemoteException e) {
      }
    }
    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"+ mSurface+ "String_Node_Str"+ mSession,e);
      }
      if (SHOW_TRANSACTIONS) {
        RuntimeException e=null;
        if (!HIDE_STACK_CRAWLS) {
          e=new RuntimeException();
          e.fillInStackTrace();
        }
        if (SHOW_TRANSACTIONS)         logSurface(this,"String_Node_Str",e);
      }
      mSurface.destroy();
    }
 catch (    RuntimeException e) {
      Slog.w(TAG,"String_Node_Str" + this + "String_Node_Str"+ mSurface+ "String_Node_Str"+ mSession+ "String_Node_Str"+ e.toString());
    }
    mSurfaceShown=false;
    mSurface=null;
  }
}