nus-yam/ex-repair huggingface dataset:
Program: 1066
Project: 1066
Buggy source:
void incActiveServices(){
  if (mCommonProcess != this) {
    mCommonProcess.incActiveServices();
  }
  mNumActiveServices++;
}

Fixed version (ground truth):
void incActiveServices(String serviceName){
  if (DEBUG && "String_Node_Str".equals(mName)) {
    RuntimeException here=new RuntimeException("String_Node_Str");
    here.fillInStackTrace();
    Slog.d(TAG,"String_Node_Str" + this + "String_Node_Str"+ serviceName+ "String_Node_Str"+ (mNumActiveServices + 1),here);
  }
  if (mCommonProcess != this) {
    mCommonProcess.incActiveServices(serviceName);
  }
  mNumActiveServices++;
}
Program: 1067
Project: 1067
Buggy source:
public void dumpSummaryLocked(PrintWriter pw,String reqPackage,long now){
  long totalTime=dumpSingleTime(null,null,mMemFactorDurations,mMemFactor,mStartTime,now);
  dumpFilteredSummaryLocked(pw,null,"String_Node_Str",ALL_SCREEN_ADJ,ALL_MEM_ADJ,ALL_PROC_STATES,NON_CACHED_PROC_STATES,now,totalTime,reqPackage);
  pw.println();
  dumpTotalsLocked(pw,now);
}

Fixed version (ground truth):
public void dumpSummaryLocked(PrintWriter pw,String reqPackage,long now,boolean activeOnly){
  long totalTime=dumpSingleTime(null,null,mMemFactorDurations,mMemFactor,mStartTime,now);
  dumpFilteredSummaryLocked(pw,null,"String_Node_Str",ALL_SCREEN_ADJ,ALL_MEM_ADJ,ALL_PROC_STATES,NON_CACHED_PROC_STATES,now,totalTime,reqPackage,activeOnly);
  pw.println();
  dumpTotalsLocked(pw,now);
}
Program: 1068
Project: 1068
Buggy source:
boolean validateLongOffset(int off){
  int arr=(off >> OFFSET_ARRAY_SHIFT) & OFFSET_ARRAY_MASK;
  if (arr >= mLongs.size()) {
    return false;
  }
  int idx=(off >> OFFSET_INDEX_SHIFT) & OFFSET_INDEX_MASK;
  if (idx >= LONGS_SIZE) {
    return false;
  }
  if (DEBUG)   Slog.d(TAG,"String_Node_Str" + printLongOffset(off) + "String_Node_Str"+ getLong(off,0));
  return true;
}

Fixed version (ground truth):
boolean validateLongOffset(int off){
  int arr=(off >> OFFSET_ARRAY_SHIFT) & OFFSET_ARRAY_MASK;
  if (arr >= mLongs.size()) {
    return false;
  }
  int idx=(off >> OFFSET_INDEX_SHIFT) & OFFSET_INDEX_MASK;
  if (idx >= LONGS_SIZE) {
    return false;
  }
  if (DEBUG_PARCEL)   Slog.d(TAG,"String_Node_Str" + printLongOffset(off) + "String_Node_Str"+ getLong(off,0));
  return true;
}
Program: 1070
Project: 1070
Buggy source:
static byte[] readFully(InputStream stream,int[] outLen) throws IOException {
  int pos=0;
  final int initialAvail=stream.available();
  byte[] data=new byte[initialAvail > 0 ? (initialAvail + 1) : 16384];
  while (true) {
    int amt=stream.read(data,pos,data.length - pos);
    if (DEBUG)     Slog.i("String_Node_Str","String_Node_Str" + amt + "String_Node_Str"+ pos+ "String_Node_Str"+ data.length);
    if (amt < 0) {
      if (DEBUG)       Slog.i("String_Node_Str","String_Node_Str" + pos + "String_Node_Str"+ data.length);
      outLen[0]=pos;
      return data;
    }
    pos+=amt;
    if (pos >= data.length) {
      byte[] newData=new byte[pos + 16384];
      if (DEBUG)       Slog.i(TAG,"String_Node_Str" + pos + "String_Node_Str"+ newData.length);
      System.arraycopy(data,0,newData,0,pos);
      data=newData;
    }
  }
}

Fixed version (ground truth):
static byte[] readFully(InputStream stream,int[] outLen) throws IOException {
  int pos=0;
  final int initialAvail=stream.available();
  byte[] data=new byte[initialAvail > 0 ? (initialAvail + 1) : 16384];
  while (true) {
    int amt=stream.read(data,pos,data.length - pos);
    if (DEBUG_PARCEL)     Slog.i("String_Node_Str","String_Node_Str" + amt + "String_Node_Str"+ pos+ "String_Node_Str"+ data.length);
    if (amt < 0) {
      if (DEBUG_PARCEL)       Slog.i("String_Node_Str","String_Node_Str" + pos + "String_Node_Str"+ data.length);
      outLen[0]=pos;
      return data;
    }
    pos+=amt;
    if (pos >= data.length) {
      byte[] newData=new byte[pos + 16384];
      if (DEBUG_PARCEL)       Slog.i(TAG,"String_Node_Str" + pos + "String_Node_Str"+ newData.length);
      System.arraycopy(data,0,newData,0,pos);
      data=newData;
    }
  }
}
Program: 1071
Project: 1071
Buggy source:
public void setStarted(boolean started,int memFactor,long now){
  if (mActive <= 0) {
    throw new IllegalStateException("String_Node_Str" + this + "String_Node_Str"+ mActive);
  }
  final boolean wasStarted=mStartedState != STATE_NOTHING;
  final int state=started ? memFactor : STATE_NOTHING;
  if (mStartedState != state) {
    if (mStartedState != STATE_NOTHING) {
      addDuration(SERVICE_STARTED + (mStartedState * SERVICE_COUNT),now - mStartedStartTime);
    }
 else     if (started) {
      mStartedCount++;
    }
    mStartedState=state;
    mStartedStartTime=now;
    mProc=mProc.pullFixedProc(mPackage);
    if (wasStarted != started) {
      if (started) {
        mProc.incStartedServices(memFactor,now);
      }
 else {
        mProc.decStartedServices(memFactor,now);
      }
    }
    updateRunning(memFactor,now);
  }
}

Fixed version (ground truth):
public void setStarted(boolean started,int memFactor,long now){
  if (mOwner == null) {
    Slog.wtf(TAG,"String_Node_Str" + this + "String_Node_Str");
  }
  final boolean wasStarted=mStartedState != STATE_NOTHING;
  final int state=started ? memFactor : STATE_NOTHING;
  if (mStartedState != state) {
    if (mStartedState != STATE_NOTHING) {
      addDuration(SERVICE_STARTED + (mStartedState * SERVICE_COUNT),now - mStartedStartTime);
    }
 else     if (started) {
      mStartedCount++;
    }
    mStartedState=state;
    mStartedStartTime=now;
    mProc=mProc.pullFixedProc(mPackage);
    if (wasStarted != started) {
      if (started) {
        mProc.incStartedServices(memFactor,now);
      }
 else {
        mProc.decStartedServices(memFactor,now);
      }
    }
    updateRunning(memFactor,now);
  }
}
Program: 1073
Project: 1073
Buggy source:
void writeDurationsToParcel(Parcel out){
  out.writeInt(mDurationsTableSize);
  for (int i=0; i < mDurationsTableSize; i++) {
    if (DEBUG)     Slog.i(TAG,"String_Node_Str" + mName + "String_Node_Str"+ i+ "String_Node_Str"+ printLongOffset(mDurationsTable[i]));
    out.writeInt(mDurationsTable[i]);
  }
}

Fixed version (ground truth):
void writeDurationsToParcel(Parcel out){
  out.writeInt(mDurationsTableSize);
  for (int i=0; i < mDurationsTableSize; i++) {
    if (DEBUG_PARCEL)     Slog.i(TAG,"String_Node_Str" + mName + "String_Node_Str"+ i+ "String_Node_Str"+ printLongOffset(mDurationsTable[i]));
    out.writeInt(mDurationsTable[i]);
  }
}
Program: 1074
Project: 1074
Buggy source:
void decStartedServices(int memFactor,long now){
  if (mCommonProcess != this) {
    mCommonProcess.decStartedServices(memFactor,now);
  }
  mNumStartedServices--;
  if (mNumStartedServices == 0 && mCurState == STATE_SERVICE_RESTARTING) {
    setState(STATE_NOTHING,memFactor,now,null);
  }
 else   if (mNumStartedServices < 0) {
    throw new IllegalStateException("String_Node_Str" + mPackage + "String_Node_Str"+ mUid+ "String_Node_Str"+ mName);
  }
}

Fixed version (ground truth):
void decStartedServices(int memFactor,long now){
  if (mCommonProcess != this) {
    mCommonProcess.decStartedServices(memFactor,now);
  }
  mNumStartedServices--;
  if (mNumStartedServices == 0 && mCurState == STATE_SERVICE_RESTARTING) {
    setState(STATE_NOTHING,memFactor,now,null);
  }
 else   if (mNumStartedServices < 0) {
    Slog.wtfStack(TAG,"String_Node_Str" + mPackage + "String_Node_Str"+ mUid+ "String_Node_Str"+ mName);
    mNumStartedServices=0;
  }
}
Program: 1075
Project: 1075
Buggy source:
void decActiveServices(){
  if (mCommonProcess != this) {
    mCommonProcess.decActiveServices();
  }
  mNumActiveServices--;
  if (mNumActiveServices < 0) {
    throw new IllegalStateException("String_Node_Str" + mPackage + "String_Node_Str"+ mUid+ "String_Node_Str"+ mName);
  }
}

Fixed version (ground truth):
void decActiveServices(String serviceName){
  if (DEBUG && "String_Node_Str".equals(mName)) {
    RuntimeException here=new RuntimeException("String_Node_Str");
    here.fillInStackTrace();
    Slog.d(TAG,"String_Node_Str" + this + "String_Node_Str"+ serviceName+ "String_Node_Str"+ (mNumActiveServices - 1),here);
  }
  if (mCommonProcess != this) {
    mCommonProcess.decActiveServices(serviceName);
  }
  mNumActiveServices--;
  if (mNumActiveServices < 0) {
    Slog.wtfStack(TAG,"String_Node_Str" + mPackage + "String_Node_Str"+ mUid+ "String_Node_Str"+ mName+ "String_Node_Str"+ serviceName);
    mNumActiveServices=0;
  }
}
Program: 1076
Project: 1076
Buggy source:
private ProcessState pullFixedProc(ArrayMap<String,ProcessState> pkgList,int index){
  ProcessState proc=pkgList.valueAt(index);
  if (mDead && proc.mCommonProcess != proc) {
    Log.wtf(TAG,"String_Node_Str" + mName + "String_Node_Str"+ mPackage+ "String_Node_Str"+ mUid+ "String_Node_Str"+ mCommonProcess.mName);
    proc=mStats.getProcessStateLocked(proc.mPackage,proc.mUid,proc.mName);
  }
  if (proc.mMultiPackage) {
    PackageState pkg=mStats.mPackages.get(pkgList.keyAt(index),proc.mUid);
    if (pkg == null) {
      throw new IllegalStateException("String_Node_Str" + pkgList.keyAt(index) + "String_Node_Str"+ proc.mName);
    }
    proc=pkg.mProcesses.get(proc.mName);
    if (proc == null) {
      throw new IllegalStateException("String_Node_Str");
    }
    pkgList.setValueAt(index,proc);
  }
  return proc;
}

Fixed version (ground truth):
private ProcessState pullFixedProc(ArrayMap<String,ProcessState> pkgList,int index){
  ProcessState proc=pkgList.valueAt(index);
  if (mDead && proc.mCommonProcess != proc) {
    Log.wtf(TAG,"String_Node_Str" + mName + "String_Node_Str"+ mPackage+ "String_Node_Str"+ mUid+ "String_Node_Str"+ mCommonProcess.mName);
    proc=mStats.getProcessStateLocked(proc.mPackage,proc.mUid,proc.mName);
  }
  if (proc.mMultiPackage) {
    PackageState pkg=mStats.mPackages.get(pkgList.keyAt(index),proc.mUid);
    if (pkg == null) {
      throw new IllegalStateException("String_Node_Str" + pkgList.keyAt(index) + "String_Node_Str"+ proc.mUid+ "String_Node_Str"+ proc.mName);
    }
    proc=pkg.mProcesses.get(proc.mName);
    if (proc == null) {
      throw new IllegalStateException("String_Node_Str" + proc.mName + "String_Node_Str"+ pkg.mPackageName+ "String_Node_Str"+ pkg.mUid);
    }
    pkgList.setValueAt(index,proc);
  }
  return proc;
}
Program: 1077
Project: 1077
Buggy source:
ProcessState clone(String pkg,long now){
  ProcessState pnew=new ProcessState(this,pkg,mUid,mName,now);
  copyDurationsTo(pnew);
  if (mPssTable != null) {
    mStats.mAddLongTable=new int[mPssTable.length];
    mStats.mAddLongTableSize=0;
    for (int i=0; i < mPssTableSize; i++) {
      int origEnt=mPssTable[i];
      int type=(origEnt >> OFFSET_TYPE_SHIFT) & OFFSET_TYPE_MASK;
      int newOff=mStats.addLongData(i,type,PSS_COUNT);
      mStats.mAddLongTable[i]=newOff | type;
      for (int j=0; j < PSS_COUNT; j++) {
        mStats.setLong(newOff,j,mStats.getLong(origEnt,j));
      }
    }
    pnew.mPssTable=mStats.mAddLongTable;
    pnew.mPssTableSize=mStats.mAddLongTableSize;
  }
  pnew.mNumExcessiveWake=mNumExcessiveWake;
  pnew.mNumExcessiveCpu=mNumExcessiveCpu;
  pnew.mNumCachedKill=mNumCachedKill;
  pnew.mMinCachedKillPss=mMinCachedKillPss;
  pnew.mAvgCachedKillPss=mAvgCachedKillPss;
  pnew.mMaxCachedKillPss=mMaxCachedKillPss;
  pnew.mActive=mActive;
  pnew.mNumStartedServices=mNumStartedServices;
  return pnew;
}

Fixed version (ground truth):
ProcessState clone(String pkg,long now){
  ProcessState pnew=new ProcessState(this,pkg,mUid,mName,now);
  copyDurationsTo(pnew);
  if (mPssTable != null) {
    mStats.mAddLongTable=new int[mPssTable.length];
    mStats.mAddLongTableSize=0;
    for (int i=0; i < mPssTableSize; i++) {
      int origEnt=mPssTable[i];
      int type=(origEnt >> OFFSET_TYPE_SHIFT) & OFFSET_TYPE_MASK;
      int newOff=mStats.addLongData(i,type,PSS_COUNT);
      mStats.mAddLongTable[i]=newOff | type;
      for (int j=0; j < PSS_COUNT; j++) {
        mStats.setLong(newOff,j,mStats.getLong(origEnt,j));
      }
    }
    pnew.mPssTable=mStats.mAddLongTable;
    pnew.mPssTableSize=mStats.mAddLongTableSize;
  }
  pnew.mNumExcessiveWake=mNumExcessiveWake;
  pnew.mNumExcessiveCpu=mNumExcessiveCpu;
  pnew.mNumCachedKill=mNumCachedKill;
  pnew.mMinCachedKillPss=mMinCachedKillPss;
  pnew.mAvgCachedKillPss=mAvgCachedKillPss;
  pnew.mMaxCachedKillPss=mMaxCachedKillPss;
  pnew.mActive=mActive;
  pnew.mNumActiveServices=mNumActiveServices;
  pnew.mNumStartedServices=mNumStartedServices;
  return pnew;
}
Program: 1078
Project: 1078
Buggy source:
public void setBound(boolean bound,int memFactor,long now){
  if (mActive <= 0) {
    throw new IllegalStateException("String_Node_Str" + this + "String_Node_Str"+ mActive);
  }
  final int state=bound ? memFactor : STATE_NOTHING;
  if (mBoundState != state) {
    if (mBoundState != STATE_NOTHING) {
      addDuration(SERVICE_BOUND + (mBoundState * SERVICE_COUNT),now - mBoundStartTime);
    }
 else     if (bound) {
      mBoundCount++;
    }
    mBoundState=state;
    mBoundStartTime=now;
    updateRunning(memFactor,now);
  }
}

Fixed version (ground truth):
public void setBound(boolean bound,int memFactor,long now){
  if (mOwner == null) {
    Slog.wtf(TAG,"String_Node_Str" + this + "String_Node_Str");
  }
  final int state=bound ? memFactor : STATE_NOTHING;
  if (mBoundState != state) {
    if (mBoundState != STATE_NOTHING) {
      addDuration(SERVICE_BOUND + (mBoundState * SERVICE_COUNT),now - mBoundStartTime);
    }
 else     if (bound) {
      mBoundCount++;
    }
    mBoundState=state;
    mBoundStartTime=now;
    updateRunning(memFactor,now);
  }
}
Program: 1079
Project: 1079
Buggy source:
public boolean isInUse(){
  return mActive > 0;
}

Fixed version (ground truth):
public boolean isInUse(){
  return mOwner != null;
}
Program: 1080
Project: 1080
Buggy source:
@Override public boolean onTransact(int code,Parcel data,Parcel reply,int flags) throws RemoteException {
  try {
    return super.onTransact(code,data,reply,flags);
  }
 catch (  RuntimeException e) {
    Slog.w("String_Node_Str","String_Node_Str",e);
    throw e;
  }
}

Fixed version (ground truth):
@Override public boolean onTransact(int code,Parcel data,Parcel reply,int flags) throws RemoteException {
  try {
    return super.onTransact(code,data,reply,flags);
  }
 catch (  RuntimeException e) {
    if (!(e instanceof SecurityException)) {
      Slog.wtf("String_Node_Str","String_Node_Str",e);
    }
    throw e;
  }
}
Program: 1081
Project: 1081
Buggy source:
@Override public boolean onTransact(int code,Parcel data,Parcel reply,int flags) throws RemoteException {
  try {
    return super.onTransact(code,data,reply,flags);
  }
 catch (  RuntimeException e) {
    if (!(e instanceof SecurityException)) {
      Slog.e(TAG,"String_Node_Str",e);
    }
    throw e;
  }
}

Fixed version (ground truth):
@Override public boolean onTransact(int code,Parcel data,Parcel reply,int flags) throws RemoteException {
  try {
    return super.onTransact(code,data,reply,flags);
  }
 catch (  RuntimeException e) {
    if (!(e instanceof SecurityException)) {
      Slog.wtf(TAG,"String_Node_Str",e);
    }
    throw e;
  }
}
Program: 1082
Project: 1082
Buggy source:
private void serviceDoneExecutingLocked(ServiceRecord r,boolean inStopping){
  if (DEBUG_SERVICE)   Slog.v(TAG,"String_Node_Str" + r + "String_Node_Str"+ r.executeNesting+ "String_Node_Str"+ inStopping+ "String_Node_Str"+ r.app);
 else   if (DEBUG_SERVICE_EXECUTING)   Slog.v(TAG,"String_Node_Str" + r.shortName);
  r.executeNesting--;
  if (r.executeNesting <= 0) {
    if (r.app != null) {
      if (DEBUG_SERVICE)       Slog.v(TAG,"String_Node_Str" + r.shortName);
      r.app.execServicesFg=false;
      r.app.executingServices.remove(r);
      if (r.app.executingServices.size() == 0) {
        if (DEBUG_SERVICE || DEBUG_SERVICE_EXECUTING)         Slog.v(TAG,"String_Node_Str" + r.shortName);
        mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_TIMEOUT_MSG,r.app);
      }
 else       if (r.executeFg) {
        for (int i=r.app.executingServices.size() - 1; i >= 0; i--) {
          if (r.app.executingServices.valueAt(i).executeFg) {
            r.app.execServicesFg=true;
            break;
          }
        }
      }
      if (inStopping) {
        if (DEBUG_SERVICE)         Slog.v(TAG,"String_Node_Str" + r);
        mStoppingServices.remove(r);
        r.bindings.clear();
      }
      mAm.updateOomAdjLocked(r.app);
    }
    r.executeFg=false;
    if (r.tracker != null) {
      r.tracker.setExecuting(false,mAm.mProcessStats.getMemFactorLocked(),SystemClock.uptimeMillis());
      if (inStopping) {
        r.tracker.makeInactive();
        r.tracker=null;
      }
    }
  }
}

Fixed version (ground truth):
private void serviceDoneExecutingLocked(ServiceRecord r,boolean inDestroying,boolean finishing){
  if (DEBUG_SERVICE)   Slog.v(TAG,"String_Node_Str" + r + "String_Node_Str"+ r.executeNesting+ "String_Node_Str"+ inDestroying+ "String_Node_Str"+ r.app);
 else   if (DEBUG_SERVICE_EXECUTING)   Slog.v(TAG,"String_Node_Str" + r.shortName);
  r.executeNesting--;
  if (r.executeNesting <= 0) {
    if (r.app != null) {
      if (DEBUG_SERVICE)       Slog.v(TAG,"String_Node_Str" + r.shortName);
      r.app.execServicesFg=false;
      r.app.executingServices.remove(r);
      if (r.app.executingServices.size() == 0) {
        if (DEBUG_SERVICE || DEBUG_SERVICE_EXECUTING)         Slog.v(TAG,"String_Node_Str" + r.shortName);
        mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_TIMEOUT_MSG,r.app);
      }
 else       if (r.executeFg) {
        for (int i=r.app.executingServices.size() - 1; i >= 0; i--) {
          if (r.app.executingServices.valueAt(i).executeFg) {
            r.app.execServicesFg=true;
            break;
          }
        }
      }
      if (inDestroying) {
        if (DEBUG_SERVICE)         Slog.v(TAG,"String_Node_Str" + r);
        mDestroyingServices.remove(r);
        r.bindings.clear();
      }
      mAm.updateOomAdjLocked(r.app);
    }
    r.executeFg=false;
    if (r.tracker != null) {
      r.tracker.setExecuting(false,mAm.mProcessStats.getMemFactorLocked(),SystemClock.uptimeMillis());
      if (finishing) {
        r.tracker.clearCurrentOwner(r);
        r.tracker=null;
      }
    }
  }
}
Program: 1086
Project: 1086
Buggy source:
void unbindFinishedLocked(ServiceRecord r,Intent intent,boolean doRebind){
  final long origId=Binder.clearCallingIdentity();
  try {
    if (r != null) {
      Intent.FilterComparison filter=new Intent.FilterComparison(intent);
      IntentBindRecord b=r.bindings.get(filter);
      if (DEBUG_SERVICE)       Slog.v(TAG,"String_Node_Str" + r + "String_Node_Str"+ b+ "String_Node_Str"+ (b != null ? b.apps.size() : 0));
      boolean inStopping=mStoppingServices.contains(r);
      if (b != null) {
        if (b.apps.size() > 0 && !inStopping) {
          boolean inFg=false;
          for (int i=b.apps.size() - 1; i >= 0; i--) {
            ProcessRecord client=b.apps.valueAt(i).client;
            if (client != null && client.setSchedGroup != Process.THREAD_GROUP_BG_NONINTERACTIVE) {
              inFg=true;
              break;
            }
          }
          requestServiceBindingLocked(r,b,inFg,true);
        }
 else {
          b.doRebind=true;
        }
      }
      serviceDoneExecutingLocked(r,inStopping);
    }
  }
  finally {
    Binder.restoreCallingIdentity(origId);
  }
}

Fixed version (ground truth):
void unbindFinishedLocked(ServiceRecord r,Intent intent,boolean doRebind){
  final long origId=Binder.clearCallingIdentity();
  try {
    if (r != null) {
      Intent.FilterComparison filter=new Intent.FilterComparison(intent);
      IntentBindRecord b=r.bindings.get(filter);
      if (DEBUG_SERVICE)       Slog.v(TAG,"String_Node_Str" + r + "String_Node_Str"+ b+ "String_Node_Str"+ (b != null ? b.apps.size() : 0));
      boolean inDestroying=mDestroyingServices.contains(r);
      if (b != null) {
        if (b.apps.size() > 0 && !inDestroying) {
          boolean inFg=false;
          for (int i=b.apps.size() - 1; i >= 0; i--) {
            ProcessRecord client=b.apps.valueAt(i).client;
            if (client != null && client.setSchedGroup != Process.THREAD_GROUP_BG_NONINTERACTIVE) {
              inFg=true;
              break;
            }
          }
          requestServiceBindingLocked(r,b,inFg,true);
        }
 else {
          b.doRebind=true;
        }
      }
      serviceDoneExecutingLocked(r,inDestroying,false);
    }
  }
  finally {
    Binder.restoreCallingIdentity(origId);
  }
}
Program: 1087
Project: 1087
Buggy source:
private final void bringDownServiceIfNeededLocked(ServiceRecord r,boolean knowConn,boolean hasConn){
  if (r.startRequested) {
    return;
  }
  if (!knowConn) {
    hasConn=r.hasAutoCreateConnections();
  }
  if (hasConn) {
    return;
  }
  if (mPendingServices.contains(r)) {
    return;
  }
  bringDownServiceLocked(r);
}

Fixed version (ground truth):
private final void bringDownServiceIfNeededLocked(ServiceRecord r,boolean knowConn,boolean hasConn){
  if (isServiceNeeded(r,knowConn,hasConn)) {
    return;
  }
  if (mPendingServices.contains(r)) {
    return;
  }
  bringDownServiceLocked(r);
}
Program: 1090
Project: 1090
Buggy source:
@Override public boolean onTransact(int code,Parcel data,Parcel reply,int flags) throws RemoteException {
  if (code == SYSPROPS_TRANSACTION) {
    ArrayList<IBinder> procs=new ArrayList<IBinder>();
synchronized (this) {
      final int NP=mProcessNames.getMap().size();
      for (int ip=0; ip < NP; ip++) {
        SparseArray<ProcessRecord> apps=mProcessNames.getMap().valueAt(ip);
        final int NA=apps.size();
        for (int ia=0; ia < NA; ia++) {
          ProcessRecord app=apps.valueAt(ia);
          if (app.thread != null) {
            procs.add(app.thread.asBinder());
          }
        }
      }
    }
    int N=procs.size();
    for (int i=0; i < N; i++) {
      Parcel data2=Parcel.obtain();
      try {
        procs.get(i).transact(IBinder.SYSPROPS_TRANSACTION,data2,null,0);
      }
 catch (      RemoteException e) {
      }
      data2.recycle();
    }
  }
  try {
    return super.onTransact(code,data,reply,flags);
  }
 catch (  RuntimeException e) {
    if (!(e instanceof SecurityException)) {
      Slog.e(TAG,"String_Node_Str",e);
    }
    throw e;
  }
}

Fixed version (ground truth):
@Override public boolean onTransact(int code,Parcel data,Parcel reply,int flags) throws RemoteException {
  if (code == SYSPROPS_TRANSACTION) {
    ArrayList<IBinder> procs=new ArrayList<IBinder>();
synchronized (this) {
      final int NP=mProcessNames.getMap().size();
      for (int ip=0; ip < NP; ip++) {
        SparseArray<ProcessRecord> apps=mProcessNames.getMap().valueAt(ip);
        final int NA=apps.size();
        for (int ia=0; ia < NA; ia++) {
          ProcessRecord app=apps.valueAt(ia);
          if (app.thread != null) {
            procs.add(app.thread.asBinder());
          }
        }
      }
    }
    int N=procs.size();
    for (int i=0; i < N; i++) {
      Parcel data2=Parcel.obtain();
      try {
        procs.get(i).transact(IBinder.SYSPROPS_TRANSACTION,data2,null,0);
      }
 catch (      RemoteException e) {
      }
      data2.recycle();
    }
  }
  try {
    return super.onTransact(code,data,reply,flags);
  }
 catch (  RuntimeException e) {
    if (!(e instanceof SecurityException)) {
      Slog.wtf(TAG,"String_Node_Str",e);
    }
    throw e;
  }
}
Program: 1091
Project: 1091
Buggy source:
/** 
 * What a Terrible Failure: Report an exception that should never happen. Similar to   {@link #wtf(String,Throwable)}, with a message as well.
 * @param tag Used to identify the source of a log message.
 * @param msg The message you would like logged.
 * @param tr An exception to log.  May be null.
 */
public static int wtf(String tag,String msg,Throwable tr){
  TerribleFailure what=new TerribleFailure(msg,tr);
  int bytes=println_native(LOG_ID_MAIN,ASSERT,tag,msg + '\n' + getStackTraceString(tr));
  sWtfHandler.onTerribleFailure(tag,what);
  return bytes;
}

Fixed version (ground truth):
static int wtf(int logId,String tag,String msg,Throwable tr){
  TerribleFailure what=new TerribleFailure(msg,tr);
  int bytes=println_native(logId,ASSERT,tag,msg + '\n' + getStackTraceString(tr));
  sWtfHandler.onTerribleFailure(tag,what);
  return bytes;
}
Program: 1092
Project: 1092
Buggy source:
void dumpFilteredSummaryLocked(PrintWriter pw,String header,String prefix,int[] screenStates,int[] memStates,int[] procStates,int[] sortProcStates,long now,long totalTime,String reqPackage){
  ArrayList<ProcessState> procs=collectProcessesLocked(screenStates,memStates,procStates,sortProcStates,now,reqPackage);
  if (procs.size() > 0) {
    if (header != null) {
      pw.println();
      pw.println(header);
    }
    dumpProcessSummaryLocked(pw,prefix,procs,screenStates,memStates,sortProcStates,now,totalTime);
  }
}

Fixed version (ground truth):
void dumpFilteredSummaryLocked(PrintWriter pw,String header,String prefix,int[] screenStates,int[] memStates,int[] procStates,int[] sortProcStates,long now,long totalTime,String reqPackage,boolean activeOnly){
  ArrayList<ProcessState> procs=collectProcessesLocked(screenStates,memStates,procStates,sortProcStates,now,reqPackage,activeOnly);
  if (procs.size() > 0) {
    if (header != null) {
      pw.println();
      pw.println(header);
    }
    dumpProcessSummaryLocked(pw,prefix,procs,screenStates,memStates,sortProcStates,now,totalTime);
  }
}
Program: 1093
Project: 1093
Buggy source:
public void setExecuting(boolean executing,int memFactor,long now){
  if (mActive <= 0) {
    throw new IllegalStateException("String_Node_Str" + this + "String_Node_Str"+ mActive);
  }
  final int state=executing ? memFactor : STATE_NOTHING;
  if (mExecState != state) {
    if (mExecState != STATE_NOTHING) {
      addDuration(SERVICE_EXEC + (mExecState * SERVICE_COUNT),now - mExecStartTime);
    }
 else     if (executing) {
      mExecCount++;
    }
    mExecState=state;
    mExecStartTime=now;
    updateRunning(memFactor,now);
  }
}

Fixed version (ground truth):
public void setExecuting(boolean executing,int memFactor,long now){
  if (mOwner == null) {
    Slog.wtf(TAG,"String_Node_Str" + this + "String_Node_Str");
  }
  final int state=executing ? memFactor : STATE_NOTHING;
  if (mExecState != state) {
    if (mExecState != STATE_NOTHING) {
      addDuration(SERVICE_EXEC + (mExecState * SERVICE_COUNT),now - mExecStartTime);
    }
 else     if (executing) {
      mExecCount++;
    }
    mExecState=state;
    mExecStartTime=now;
    updateRunning(memFactor,now);
  }
}
Program: 1094
Project: 1094
Buggy source:
private void ensureNotDead(){
  if (!mDead) {
    return;
  }
  throw new IllegalStateException("String_Node_Str" + mName + "String_Node_Str"+ mPackage+ "String_Node_Str"+ mUid+ "String_Node_Str"+ mCommonProcess.mName);
}

Fixed version (ground truth):
private void ensureNotDead(){
  if (!mDead) {
    return;
  }
  Slog.wtfStack(TAG,"String_Node_Str" + mName + "String_Node_Str"+ mPackage+ "String_Node_Str"+ mUid+ "String_Node_Str"+ mCommonProcess.mName);
}
Program: 1095
Project: 1095
Buggy source:
public ProcessStats.ServiceState getServiceStateLocked(String packageName,int uid,String processName,String className){
  final ProcessStats.PackageState as=getPackageStateLocked(packageName,uid);
  ProcessStats.ServiceState ss=as.mServices.get(className);
  if (ss != null) {
    return ss;
  }
  final ProcessStats.ProcessState ps=processName != null ? getProcessStateLocked(packageName,uid,processName) : null;
  ss=new ProcessStats.ServiceState(this,packageName,className,processName,ps);
  as.mServices.put(className,ss);
  return ss;
}

Fixed version (ground truth):
public ProcessStats.ServiceState getServiceStateLocked(String packageName,int uid,String processName,String className){
  final ProcessStats.PackageState as=getPackageStateLocked(packageName,uid);
  ProcessStats.ServiceState ss=as.mServices.get(className);
  if (ss != null) {
    if (DEBUG)     Slog.d(TAG,"String_Node_Str" + ss);
    return ss;
  }
  final ProcessStats.ProcessState ps=processName != null ? getProcessStateLocked(packageName,uid,processName) : null;
  ss=new ProcessStats.ServiceState(this,packageName,className,processName,ps);
  as.mServices.put(className,ss);
  if (DEBUG)   Slog.d(TAG,"String_Node_Str" + ss + "String_Node_Str"+ ps);
  return ss;
}
Program: 1096
Project: 1096
Buggy source:
private int[] readTableFromParcel(Parcel in,String name,String what){
  final int size=in.readInt();
  if (size < 0) {
    Slog.w(TAG,"String_Node_Str" + what + "String_Node_Str"+ size);
    return BAD_TABLE;
  }
  if (size == 0) {
    return null;
  }
  final int[] table=new int[size];
  for (int i=0; i < size; i++) {
    table[i]=in.readInt();
    if (DEBUG)     Slog.i(TAG,"String_Node_Str" + name + "String_Node_Str"+ i+ "String_Node_Str"+ ProcessStats.printLongOffset(table[i]));
    if (!validateLongOffset(table[i])) {
      Slog.w(TAG,"String_Node_Str" + what + "String_Node_Str"+ ProcessStats.printLongOffset(table[i]));
      return null;
    }
  }
  return table;
}

Fixed version (ground truth):
private int[] readTableFromParcel(Parcel in,String name,String what){
  final int size=in.readInt();
  if (size < 0) {
    Slog.w(TAG,"String_Node_Str" + what + "String_Node_Str"+ size);
    return BAD_TABLE;
  }
  if (size == 0) {
    return null;
  }
  final int[] table=new int[size];
  for (int i=0; i < size; i++) {
    table[i]=in.readInt();
    if (DEBUG_PARCEL)     Slog.i(TAG,"String_Node_Str" + name + "String_Node_Str"+ i+ "String_Node_Str"+ ProcessStats.printLongOffset(table[i]));
    if (!validateLongOffset(table[i])) {
      Slog.w(TAG,"String_Node_Str" + what + "String_Node_Str"+ ProcessStats.printLongOffset(table[i]));
      return null;
    }
  }
  return table;
}
Program: 1097
Project: 1097
Buggy source:
public void makeActive(){
  if (mActive == 0) {
    mProc.incActiveServices();
  }
  mActive++;
}

Fixed version (ground truth):
public void makeActive(){
  ensureNotDead();
  mActive=true;
}
Program: 1098
Project: 1098
Buggy source:
public void makeInactive(){
  mActive--;
  if (mActive == 0) {
    mProc.decActiveServices();
  }
}

Fixed version (ground truth):
public void makeInactive(){
  mActive=false;
}
Program: 1100
Project: 1100
Buggy source:
void incActiveServices(){
  if (mCommonProcess != this) {
    mCommonProcess.incActiveServices();
  }
  mNumActiveServices++;
}

Fixed version (ground truth):
void incActiveServices(String serviceName){
  if (DEBUG && "String_Node_Str".equals(mName)) {
    RuntimeException here=new RuntimeException("String_Node_Str");
    here.fillInStackTrace();
    Slog.d(TAG,"String_Node_Str" + this + "String_Node_Str"+ serviceName+ "String_Node_Str"+ (mNumActiveServices + 1),here);
  }
  if (mCommonProcess != this) {
    mCommonProcess.incActiveServices(serviceName);
  }
  mNumActiveServices++;
}
Program: 1101
Project: 1101
Buggy source:
public void dumpSummaryLocked(PrintWriter pw,String reqPackage,long now){
  long totalTime=dumpSingleTime(null,null,mMemFactorDurations,mMemFactor,mStartTime,now);
  dumpFilteredSummaryLocked(pw,null,"String_Node_Str",ALL_SCREEN_ADJ,ALL_MEM_ADJ,ALL_PROC_STATES,NON_CACHED_PROC_STATES,now,totalTime,reqPackage);
  pw.println();
  dumpTotalsLocked(pw,now);
}

Fixed version (ground truth):
public void dumpSummaryLocked(PrintWriter pw,String reqPackage,long now,boolean activeOnly){
  long totalTime=dumpSingleTime(null,null,mMemFactorDurations,mMemFactor,mStartTime,now);
  dumpFilteredSummaryLocked(pw,null,"String_Node_Str",ALL_SCREEN_ADJ,ALL_MEM_ADJ,ALL_PROC_STATES,NON_CACHED_PROC_STATES,now,totalTime,reqPackage,activeOnly);
  pw.println();
  dumpTotalsLocked(pw,now);
}
Program: 1102
Project: 1102
Buggy source:
boolean validateLongOffset(int off){
  int arr=(off >> OFFSET_ARRAY_SHIFT) & OFFSET_ARRAY_MASK;
  if (arr >= mLongs.size()) {
    return false;
  }
  int idx=(off >> OFFSET_INDEX_SHIFT) & OFFSET_INDEX_MASK;
  if (idx >= LONGS_SIZE) {
    return false;
  }
  if (DEBUG)   Slog.d(TAG,"String_Node_Str" + printLongOffset(off) + "String_Node_Str"+ getLong(off,0));
  return true;
}

Fixed version (ground truth):
boolean validateLongOffset(int off){
  int arr=(off >> OFFSET_ARRAY_SHIFT) & OFFSET_ARRAY_MASK;
  if (arr >= mLongs.size()) {
    return false;
  }
  int idx=(off >> OFFSET_INDEX_SHIFT) & OFFSET_INDEX_MASK;
  if (idx >= LONGS_SIZE) {
    return false;
  }
  if (DEBUG_PARCEL)   Slog.d(TAG,"String_Node_Str" + printLongOffset(off) + "String_Node_Str"+ getLong(off,0));
  return true;
}
Program: 1104
Project: 1104
Buggy source:
static byte[] readFully(InputStream stream,int[] outLen) throws IOException {
  int pos=0;
  final int initialAvail=stream.available();
  byte[] data=new byte[initialAvail > 0 ? (initialAvail + 1) : 16384];
  while (true) {
    int amt=stream.read(data,pos,data.length - pos);
    if (DEBUG)     Slog.i("String_Node_Str","String_Node_Str" + amt + "String_Node_Str"+ pos+ "String_Node_Str"+ data.length);
    if (amt < 0) {
      if (DEBUG)       Slog.i("String_Node_Str","String_Node_Str" + pos + "String_Node_Str"+ data.length);
      outLen[0]=pos;
      return data;
    }
    pos+=amt;
    if (pos >= data.length) {
      byte[] newData=new byte[pos + 16384];
      if (DEBUG)       Slog.i(TAG,"String_Node_Str" + pos + "String_Node_Str"+ newData.length);
      System.arraycopy(data,0,newData,0,pos);
      data=newData;
    }
  }
}

Fixed version (ground truth):
static byte[] readFully(InputStream stream,int[] outLen) throws IOException {
  int pos=0;
  final int initialAvail=stream.available();
  byte[] data=new byte[initialAvail > 0 ? (initialAvail + 1) : 16384];
  while (true) {
    int amt=stream.read(data,pos,data.length - pos);
    if (DEBUG_PARCEL)     Slog.i("String_Node_Str","String_Node_Str" + amt + "String_Node_Str"+ pos+ "String_Node_Str"+ data.length);
    if (amt < 0) {
      if (DEBUG_PARCEL)       Slog.i("String_Node_Str","String_Node_Str" + pos + "String_Node_Str"+ data.length);
      outLen[0]=pos;
      return data;
    }
    pos+=amt;
    if (pos >= data.length) {
      byte[] newData=new byte[pos + 16384];
      if (DEBUG_PARCEL)       Slog.i(TAG,"String_Node_Str" + pos + "String_Node_Str"+ newData.length);
      System.arraycopy(data,0,newData,0,pos);
      data=newData;
    }
  }
}
Program: 1105
Project: 1105
Buggy source:
public void setStarted(boolean started,int memFactor,long now){
  if (mActive <= 0) {
    throw new IllegalStateException("String_Node_Str" + this + "String_Node_Str"+ mActive);
  }
  final boolean wasStarted=mStartedState != STATE_NOTHING;
  final int state=started ? memFactor : STATE_NOTHING;
  if (mStartedState != state) {
    if (mStartedState != STATE_NOTHING) {
      addDuration(SERVICE_STARTED + (mStartedState * SERVICE_COUNT),now - mStartedStartTime);
    }
 else     if (started) {
      mStartedCount++;
    }
    mStartedState=state;
    mStartedStartTime=now;
    mProc=mProc.pullFixedProc(mPackage);
    if (wasStarted != started) {
      if (started) {
        mProc.incStartedServices(memFactor,now);
      }
 else {
        mProc.decStartedServices(memFactor,now);
      }
    }
    updateRunning(memFactor,now);
  }
}

Fixed version (ground truth):
public void setStarted(boolean started,int memFactor,long now){
  if (mOwner == null) {
    Slog.wtf(TAG,"String_Node_Str" + this + "String_Node_Str");
  }
  final boolean wasStarted=mStartedState != STATE_NOTHING;
  final int state=started ? memFactor : STATE_NOTHING;
  if (mStartedState != state) {
    if (mStartedState != STATE_NOTHING) {
      addDuration(SERVICE_STARTED + (mStartedState * SERVICE_COUNT),now - mStartedStartTime);
    }
 else     if (started) {
      mStartedCount++;
    }
    mStartedState=state;
    mStartedStartTime=now;
    mProc=mProc.pullFixedProc(mPackage);
    if (wasStarted != started) {
      if (started) {
        mProc.incStartedServices(memFactor,now);
      }
 else {
        mProc.decStartedServices(memFactor,now);
      }
    }
    updateRunning(memFactor,now);
  }
}
Program: 1107
Project: 1107
Buggy source:
void writeDurationsToParcel(Parcel out){
  out.writeInt(mDurationsTableSize);
  for (int i=0; i < mDurationsTableSize; i++) {
    if (DEBUG)     Slog.i(TAG,"String_Node_Str" + mName + "String_Node_Str"+ i+ "String_Node_Str"+ printLongOffset(mDurationsTable[i]));
    out.writeInt(mDurationsTable[i]);
  }
}

Fixed version (ground truth):
void writeDurationsToParcel(Parcel out){
  out.writeInt(mDurationsTableSize);
  for (int i=0; i < mDurationsTableSize; i++) {
    if (DEBUG_PARCEL)     Slog.i(TAG,"String_Node_Str" + mName + "String_Node_Str"+ i+ "String_Node_Str"+ printLongOffset(mDurationsTable[i]));
    out.writeInt(mDurationsTable[i]);
  }
}
Program: 1108
Project: 1108
Buggy source:
void decStartedServices(int memFactor,long now){
  if (mCommonProcess != this) {
    mCommonProcess.decStartedServices(memFactor,now);
  }
  mNumStartedServices--;
  if (mNumStartedServices == 0 && mCurState == STATE_SERVICE_RESTARTING) {
    setState(STATE_NOTHING,memFactor,now,null);
  }
 else   if (mNumStartedServices < 0) {
    throw new IllegalStateException("String_Node_Str" + mPackage + "String_Node_Str"+ mUid+ "String_Node_Str"+ mName);
  }
}

Fixed version (ground truth):
void decStartedServices(int memFactor,long now){
  if (mCommonProcess != this) {
    mCommonProcess.decStartedServices(memFactor,now);
  }
  mNumStartedServices--;
  if (mNumStartedServices == 0 && mCurState == STATE_SERVICE_RESTARTING) {
    setState(STATE_NOTHING,memFactor,now,null);
  }
 else   if (mNumStartedServices < 0) {
    Slog.wtfStack(TAG,"String_Node_Str" + mPackage + "String_Node_Str"+ mUid+ "String_Node_Str"+ mName);
    mNumStartedServices=0;
  }
}
Program: 1109
Project: 1109
Buggy source:
void decActiveServices(){
  if (mCommonProcess != this) {
    mCommonProcess.decActiveServices();
  }
  mNumActiveServices--;
  if (mNumActiveServices < 0) {
    throw new IllegalStateException("String_Node_Str" + mPackage + "String_Node_Str"+ mUid+ "String_Node_Str"+ mName);
  }
}

Fixed version (ground truth):
void decActiveServices(String serviceName){
  if (DEBUG && "String_Node_Str".equals(mName)) {
    RuntimeException here=new RuntimeException("String_Node_Str");
    here.fillInStackTrace();
    Slog.d(TAG,"String_Node_Str" + this + "String_Node_Str"+ serviceName+ "String_Node_Str"+ (mNumActiveServices - 1),here);
  }
  if (mCommonProcess != this) {
    mCommonProcess.decActiveServices(serviceName);
  }
  mNumActiveServices--;
  if (mNumActiveServices < 0) {
    Slog.wtfStack(TAG,"String_Node_Str" + mPackage + "String_Node_Str"+ mUid+ "String_Node_Str"+ mName+ "String_Node_Str"+ serviceName);
    mNumActiveServices=0;
  }
}
Program: 1110
Project: 1110
Buggy source:
private ProcessState pullFixedProc(ArrayMap<String,ProcessState> pkgList,int index){
  ProcessState proc=pkgList.valueAt(index);
  if (mDead && proc.mCommonProcess != proc) {
    Log.wtf(TAG,"String_Node_Str" + mName + "String_Node_Str"+ mPackage+ "String_Node_Str"+ mUid+ "String_Node_Str"+ mCommonProcess.mName);
    proc=mStats.getProcessStateLocked(proc.mPackage,proc.mUid,proc.mName);
  }
  if (proc.mMultiPackage) {
    PackageState pkg=mStats.mPackages.get(pkgList.keyAt(index),proc.mUid);
    if (pkg == null) {
      throw new IllegalStateException("String_Node_Str" + pkgList.keyAt(index) + "String_Node_Str"+ proc.mName);
    }
    proc=pkg.mProcesses.get(proc.mName);
    if (proc == null) {
      throw new IllegalStateException("String_Node_Str");
    }
    pkgList.setValueAt(index,proc);
  }
  return proc;
}

Fixed version (ground truth):
private ProcessState pullFixedProc(ArrayMap<String,ProcessState> pkgList,int index){
  ProcessState proc=pkgList.valueAt(index);
  if (mDead && proc.mCommonProcess != proc) {
    Log.wtf(TAG,"String_Node_Str" + mName + "String_Node_Str"+ mPackage+ "String_Node_Str"+ mUid+ "String_Node_Str"+ mCommonProcess.mName);
    proc=mStats.getProcessStateLocked(proc.mPackage,proc.mUid,proc.mName);
  }
  if (proc.mMultiPackage) {
    PackageState pkg=mStats.mPackages.get(pkgList.keyAt(index),proc.mUid);
    if (pkg == null) {
      throw new IllegalStateException("String_Node_Str" + pkgList.keyAt(index) + "String_Node_Str"+ proc.mUid+ "String_Node_Str"+ proc.mName);
    }
    proc=pkg.mProcesses.get(proc.mName);
    if (proc == null) {
      throw new IllegalStateException("String_Node_Str" + proc.mName + "String_Node_Str"+ pkg.mPackageName+ "String_Node_Str"+ pkg.mUid);
    }
    pkgList.setValueAt(index,proc);
  }
  return proc;
}
Program: 1111
Project: 1111
Buggy source:
ProcessState clone(String pkg,long now){
  ProcessState pnew=new ProcessState(this,pkg,mUid,mName,now);
  copyDurationsTo(pnew);
  if (mPssTable != null) {
    mStats.mAddLongTable=new int[mPssTable.length];
    mStats.mAddLongTableSize=0;
    for (int i=0; i < mPssTableSize; i++) {
      int origEnt=mPssTable[i];
      int type=(origEnt >> OFFSET_TYPE_SHIFT) & OFFSET_TYPE_MASK;
      int newOff=mStats.addLongData(i,type,PSS_COUNT);
      mStats.mAddLongTable[i]=newOff | type;
      for (int j=0; j < PSS_COUNT; j++) {
        mStats.setLong(newOff,j,mStats.getLong(origEnt,j));
      }
    }
    pnew.mPssTable=mStats.mAddLongTable;
    pnew.mPssTableSize=mStats.mAddLongTableSize;
  }
  pnew.mNumExcessiveWake=mNumExcessiveWake;
  pnew.mNumExcessiveCpu=mNumExcessiveCpu;
  pnew.mNumCachedKill=mNumCachedKill;
  pnew.mMinCachedKillPss=mMinCachedKillPss;
  pnew.mAvgCachedKillPss=mAvgCachedKillPss;
  pnew.mMaxCachedKillPss=mMaxCachedKillPss;
  pnew.mActive=mActive;
  pnew.mNumStartedServices=mNumStartedServices;
  return pnew;
}

Fixed version (ground truth):
ProcessState clone(String pkg,long now){
  ProcessState pnew=new ProcessState(this,pkg,mUid,mName,now);
  copyDurationsTo(pnew);
  if (mPssTable != null) {
    mStats.mAddLongTable=new int[mPssTable.length];
    mStats.mAddLongTableSize=0;
    for (int i=0; i < mPssTableSize; i++) {
      int origEnt=mPssTable[i];
      int type=(origEnt >> OFFSET_TYPE_SHIFT) & OFFSET_TYPE_MASK;
      int newOff=mStats.addLongData(i,type,PSS_COUNT);
      mStats.mAddLongTable[i]=newOff | type;
      for (int j=0; j < PSS_COUNT; j++) {
        mStats.setLong(newOff,j,mStats.getLong(origEnt,j));
      }
    }
    pnew.mPssTable=mStats.mAddLongTable;
    pnew.mPssTableSize=mStats.mAddLongTableSize;
  }
  pnew.mNumExcessiveWake=mNumExcessiveWake;
  pnew.mNumExcessiveCpu=mNumExcessiveCpu;
  pnew.mNumCachedKill=mNumCachedKill;
  pnew.mMinCachedKillPss=mMinCachedKillPss;
  pnew.mAvgCachedKillPss=mAvgCachedKillPss;
  pnew.mMaxCachedKillPss=mMaxCachedKillPss;
  pnew.mActive=mActive;
  pnew.mNumActiveServices=mNumActiveServices;
  pnew.mNumStartedServices=mNumStartedServices;
  return pnew;
}
Program: 1112
Project: 1112
Buggy source:
public void setBound(boolean bound,int memFactor,long now){
  if (mActive <= 0) {
    throw new IllegalStateException("String_Node_Str" + this + "String_Node_Str"+ mActive);
  }
  final int state=bound ? memFactor : STATE_NOTHING;
  if (mBoundState != state) {
    if (mBoundState != STATE_NOTHING) {
      addDuration(SERVICE_BOUND + (mBoundState * SERVICE_COUNT),now - mBoundStartTime);
    }
 else     if (bound) {
      mBoundCount++;
    }
    mBoundState=state;
    mBoundStartTime=now;
    updateRunning(memFactor,now);
  }
}

Fixed version (ground truth):
public void setBound(boolean bound,int memFactor,long now){
  if (mOwner == null) {
    Slog.wtf(TAG,"String_Node_Str" + this + "String_Node_Str");
  }
  final int state=bound ? memFactor : STATE_NOTHING;
  if (mBoundState != state) {
    if (mBoundState != STATE_NOTHING) {
      addDuration(SERVICE_BOUND + (mBoundState * SERVICE_COUNT),now - mBoundStartTime);
    }
 else     if (bound) {
      mBoundCount++;
    }
    mBoundState=state;
    mBoundStartTime=now;
    updateRunning(memFactor,now);
  }
}
Program: 1113
Project: 1113
Buggy source:
public boolean isInUse(){
  return mActive > 0;
}

Fixed version (ground truth):
public boolean isInUse(){
  return mOwner != null;
}
Program: 1114
Project: 1114
Buggy source:
@Override public boolean onTransact(int code,Parcel data,Parcel reply,int flags) throws RemoteException {
  try {
    return super.onTransact(code,data,reply,flags);
  }
 catch (  RuntimeException e) {
    Slog.w("String_Node_Str","String_Node_Str",e);
    throw e;
  }
}

Fixed version (ground truth):
@Override public boolean onTransact(int code,Parcel data,Parcel reply,int flags) throws RemoteException {
  try {
    return super.onTransact(code,data,reply,flags);
  }
 catch (  RuntimeException e) {
    if (!(e instanceof SecurityException)) {
      Slog.wtf("String_Node_Str","String_Node_Str",e);
    }
    throw e;
  }
}
Program: 1115
Project: 1115
Buggy source:
@Override public boolean onTransact(int code,Parcel data,Parcel reply,int flags) throws RemoteException {
  try {
    return super.onTransact(code,data,reply,flags);
  }
 catch (  RuntimeException e) {
    if (!(e instanceof SecurityException)) {
      Slog.e(TAG,"String_Node_Str",e);
    }
    throw e;
  }
}

Fixed version (ground truth):
@Override public boolean onTransact(int code,Parcel data,Parcel reply,int flags) throws RemoteException {
  try {
    return super.onTransact(code,data,reply,flags);
  }
 catch (  RuntimeException e) {
    if (!(e instanceof SecurityException)) {
      Slog.wtf(TAG,"String_Node_Str",e);
    }
    throw e;
  }
}
Program: 1116
Project: 1116
Buggy source:
private void serviceDoneExecutingLocked(ServiceRecord r,boolean inStopping){
  if (DEBUG_SERVICE)   Slog.v(TAG,"String_Node_Str" + r + "String_Node_Str"+ r.executeNesting+ "String_Node_Str"+ inStopping+ "String_Node_Str"+ r.app);
 else   if (DEBUG_SERVICE_EXECUTING)   Slog.v(TAG,"String_Node_Str" + r.shortName);
  r.executeNesting--;
  if (r.executeNesting <= 0) {
    if (r.app != null) {
      if (DEBUG_SERVICE)       Slog.v(TAG,"String_Node_Str" + r.shortName);
      r.app.execServicesFg=false;
      r.app.executingServices.remove(r);
      if (r.app.executingServices.size() == 0) {
        if (DEBUG_SERVICE || DEBUG_SERVICE_EXECUTING)         Slog.v(TAG,"String_Node_Str" + r.shortName);
        mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_TIMEOUT_MSG,r.app);
      }
 else       if (r.executeFg) {
        for (int i=r.app.executingServices.size() - 1; i >= 0; i--) {
          if (r.app.executingServices.valueAt(i).executeFg) {
            r.app.execServicesFg=true;
            break;
          }
        }
      }
      if (inStopping) {
        if (DEBUG_SERVICE)         Slog.v(TAG,"String_Node_Str" + r);
        mStoppingServices.remove(r);
        r.bindings.clear();
      }
      mAm.updateOomAdjLocked(r.app);
    }
    r.executeFg=false;
    if (r.tracker != null) {
      r.tracker.setExecuting(false,mAm.mProcessStats.getMemFactorLocked(),SystemClock.uptimeMillis());
      if (inStopping) {
        r.tracker.makeInactive();
        r.tracker=null;
      }
    }
  }
}

Fixed version (ground truth):
private void serviceDoneExecutingLocked(ServiceRecord r,boolean inDestroying,boolean finishing){
  if (DEBUG_SERVICE)   Slog.v(TAG,"String_Node_Str" + r + "String_Node_Str"+ r.executeNesting+ "String_Node_Str"+ inDestroying+ "String_Node_Str"+ r.app);
 else   if (DEBUG_SERVICE_EXECUTING)   Slog.v(TAG,"String_Node_Str" + r.shortName);
  r.executeNesting--;
  if (r.executeNesting <= 0) {
    if (r.app != null) {
      if (DEBUG_SERVICE)       Slog.v(TAG,"String_Node_Str" + r.shortName);
      r.app.execServicesFg=false;
      r.app.executingServices.remove(r);
      if (r.app.executingServices.size() == 0) {
        if (DEBUG_SERVICE || DEBUG_SERVICE_EXECUTING)         Slog.v(TAG,"String_Node_Str" + r.shortName);
        mAm.mHandler.removeMessages(ActivityManagerService.SERVICE_TIMEOUT_MSG,r.app);
      }
 else       if (r.executeFg) {
        for (int i=r.app.executingServices.size() - 1; i >= 0; i--) {
          if (r.app.executingServices.valueAt(i).executeFg) {
            r.app.execServicesFg=true;
            break;
          }
        }
      }
      if (inDestroying) {
        if (DEBUG_SERVICE)         Slog.v(TAG,"String_Node_Str" + r);
        mDestroyingServices.remove(r);
        r.bindings.clear();
      }
      mAm.updateOomAdjLocked(r.app);
    }
    r.executeFg=false;
    if (r.tracker != null) {
      r.tracker.setExecuting(false,mAm.mProcessStats.getMemFactorLocked(),SystemClock.uptimeMillis());
      if (finishing) {
        r.tracker.clearCurrentOwner(r);
        r.tracker=null;
      }
    }
  }
}