Program: 196524
Project: 196524
Buggy source:
private final void realStartServiceLocked(ServiceRecord r,ProcessRecord app,boolean execInFg) throws RemoteException {
  if (app.thread == null) {
    throw new RemoteException();
  }
  if (DEBUG_MU)   Slog.v(TAG_MU,"String_Node_Str" + r.appInfo.uid + "String_Node_Str"+ app.uid);
  r.app=app;
  r.restartTime=r.lastActivity=SystemClock.uptimeMillis();
  app.services.add(r);
  bumpServiceExecutingLocked(r,execInFg,"String_Node_Str");
  mAm.updateLruProcessLocked(app,false,null);
  mAm.updateOomAdjLocked();
  boolean created=false;
  try {
    String nameTerm;
    int lastPeriod=r.shortName.lastIndexOf('.');
    nameTerm=lastPeriod >= 0 ? r.shortName.substring(lastPeriod) : r.shortName;
    EventLogTags.writeAmCreateService(r.userId,System.identityHashCode(r),nameTerm,r.app.uid,r.app.pid);
synchronized (r.stats.getBatteryStats()) {
      r.stats.startLaunchedLocked();
    }
    mAm.ensurePackageDexOpt(r.serviceInfo.packageName);
    app.forceProcessStateUpTo(ActivityManager.PROCESS_STATE_SERVICE);
    app.thread.scheduleCreateService(r,r.serviceInfo,mAm.compatibilityInfoForPackageLocked(r.serviceInfo.applicationInfo),app.repProcState);
    r.postNotification();
    created=true;
  }
 catch (  DeadObjectException e) {
    Slog.w(TAG,"String_Node_Str" + r);
    mAm.appDiedLocked(app);
  }
 finally {
    if (!created) {
      app.services.remove(r);
      r.app=null;
      scheduleServiceRestartLocked(r,false);
      return;
    }
  }
  requestServiceBindingsLocked(r,execInFg);
  updateServiceClientActivitiesLocked(app,null,true);
  if (r.startRequested && r.callStart && r.pendingStarts.size() == 0) {
    r.pendingStarts.add(new ServiceRecord.StartItem(r,false,r.makeNextStartId(),null,null));
  }
  sendServiceArgsLocked(r,execInFg,true);
  if (r.delayed) {
    if (DEBUG_DELAYED_STARTS)     Slog.v(TAG,"String_Node_Str" + r);
    getServiceMap(r.userId).mDelayedStartList.remove(r);
    r.delayed=false;
  }
  if (r.delayedStop) {
    r.delayedStop=false;
    if (r.startRequested) {
      if (DEBUG_DELAYED_STARTS)       Slog.v(TAG,"String_Node_Str" + r);
      stopServiceLocked(r);
    }
  }
}

Fixed version (ground truth):
private final void realStartServiceLocked(ServiceRecord r,ProcessRecord app,boolean execInFg) throws RemoteException {
  if (app.thread == null) {
    throw new RemoteException();
  }
  if (DEBUG_MU)   Slog.v(TAG_MU,"String_Node_Str" + r.appInfo.uid + "String_Node_Str"+ app.uid);
  r.app=app;
  r.restartTime=r.lastActivity=SystemClock.uptimeMillis();
  app.services.add(r);
  bumpServiceExecutingLocked(r,execInFg,"String_Node_Str");
  mAm.updateLruProcessLocked(app,false,null);
  mAm.updateOomAdjLocked();
  boolean created=false;
  try {
    String nameTerm;
    int lastPeriod=r.shortName.lastIndexOf('.');
    nameTerm=lastPeriod >= 0 ? r.shortName.substring(lastPeriod) : r.shortName;
    if (LOG_SERVICE_START_STOP) {
      EventLogTags.writeAmCreateService(r.userId,System.identityHashCode(r),nameTerm,r.app.uid,r.app.pid);
    }
synchronized (r.stats.getBatteryStats()) {
      r.stats.startLaunchedLocked();
    }
    mAm.ensurePackageDexOpt(r.serviceInfo.packageName);
    app.forceProcessStateUpTo(ActivityManager.PROCESS_STATE_SERVICE);
    app.thread.scheduleCreateService(r,r.serviceInfo,mAm.compatibilityInfoForPackageLocked(r.serviceInfo.applicationInfo),app.repProcState);
    r.postNotification();
    created=true;
  }
 catch (  DeadObjectException e) {
    Slog.w(TAG,"String_Node_Str" + r);
    mAm.appDiedLocked(app);
  }
 finally {
    if (!created) {
      app.services.remove(r);
      r.app=null;
      scheduleServiceRestartLocked(r,false);
      return;
    }
  }
  requestServiceBindingsLocked(r,execInFg);
  updateServiceClientActivitiesLocked(app,null,true);
  if (r.startRequested && r.callStart && r.pendingStarts.size() == 0) {
    r.pendingStarts.add(new ServiceRecord.StartItem(r,false,r.makeNextStartId(),null,null));
  }
  sendServiceArgsLocked(r,execInFg,true);
  if (r.delayed) {
    if (DEBUG_DELAYED_STARTS)     Slog.v(TAG,"String_Node_Str" + r);
    getServiceMap(r.userId).mDelayedStartList.remove(r);
    r.delayed=false;
  }
  if (r.delayedStop) {
    r.delayedStop=false;
    if (r.startRequested) {
      if (DEBUG_DELAYED_STARTS)       Slog.v(TAG,"String_Node_Str" + r);
      stopServiceLocked(r);
    }
  }
}