nus-yam/ex-repair huggingface dataset:
Program: 1120
Project: 1120
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: 1121
Project: 1121
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: 1124
Project: 1124
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: 1125
Project: 1125
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: 1126
Project: 1126
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: 1127
Project: 1127
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: 1128
Project: 1128
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: 1129
Project: 1129
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: 1130
Project: 1130
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: 1131
Project: 1131
Buggy source:
public void makeActive(){
  if (mActive == 0) {
    mProc.incActiveServices();
  }
  mActive++;
}

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

Fixed version (ground truth):
public void makeInactive(){
  mActive=false;
}
Program: 1134
Project: 1134
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: 1135
Project: 1135
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: 1136
Project: 1136
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: 1138
Project: 1138
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: 1139
Project: 1139
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: 1141
Project: 1141
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: 1142
Project: 1142
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: 1143
Project: 1143
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: 1144
Project: 1144
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: 1145
Project: 1145
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: 1146
Project: 1146
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: 1147
Project: 1147
Buggy source:
public boolean isInUse(){
  return mActive > 0;
}

Fixed version (ground truth):
public boolean isInUse(){
  return mOwner != null;
}
Program: 1148
Project: 1148
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: 1149
Project: 1149
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: 1150
Project: 1150
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: 1154
Project: 1154
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: 1155
Project: 1155
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: 1158
Project: 1158
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: 1159
Project: 1159
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: 1160
Project: 1160
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: 1161
Project: 1161
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: 1162
Project: 1162
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: 1163
Project: 1163
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: 1164
Project: 1164
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: 1165
Project: 1165
Buggy source:
public void makeActive(){
  if (mActive == 0) {
    mProc.incActiveServices();
  }
  mActive++;
}

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

Fixed version (ground truth):
public void makeInactive(){
  mActive=false;
}
Program: 1168
Project: 1168
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: 1169
Project: 1169
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: 1170
Project: 1170
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: 1172
Project: 1172
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: 1173
Project: 1173
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: 1175
Project: 1175
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]);
  }
}