Program: 196709
Project: 196709
Buggy source:
public void systemReady(final Runnable goingCallback){
synchronized (this) {
    if (mSystemReady) {
      if (goingCallback != null) {
        goingCallback.run();
      }
      return;
    }
    updateCurrentProfileIdsLocked();
    if (mRecentTasks == null) {
      mRecentTasks=mTaskPersister.restoreTasksLocked();
      if (!mRecentTasks.isEmpty()) {
        mStackSupervisor.createStackForRestoredTaskHistory(mRecentTasks);
      }
      cleanupRecentTasksLocked(UserHandle.USER_ALL);
      mTaskPersister.startPersisting();
    }
    if (!mDidUpdate) {
      if (mWaitingUpdate) {
        return;
      }
      final ArrayList<ComponentName> doneReceivers=new ArrayList<ComponentName>();
      mWaitingUpdate=deliverPreBootCompleted(new Runnable(){
        public void run(){
synchronized (ActivityManagerService.this) {
            mDidUpdate=true;
          }
          writeLastDonePreBootReceivers(doneReceivers);
          showBootMessage(mContext.getText(R.string.android_upgrading_complete),false);
          systemReady(goingCallback);
        }
      }
,doneReceivers,UserHandle.USER_OWNER);
      if (mWaitingUpdate) {
        return;
      }
      mDidUpdate=true;
    }
    mAppOpsService.systemReady();
    mSystemReady=true;
  }
  ArrayList<ProcessRecord> procsToKill=null;
synchronized (mPidsSelfLocked) {
    for (int i=mPidsSelfLocked.size() - 1; i >= 0; i--) {
      ProcessRecord proc=mPidsSelfLocked.valueAt(i);
      if (!isAllowedWhileBooting(proc.info)) {
        if (procsToKill == null) {
          procsToKill=new ArrayList<ProcessRecord>();
        }
        procsToKill.add(proc);
      }
    }
  }
synchronized (this) {
    if (procsToKill != null) {
      for (int i=procsToKill.size() - 1; i >= 0; i--) {
        ProcessRecord proc=procsToKill.get(i);
        Slog.i(TAG,"String_Node_Str" + proc);
        removeProcessLocked(proc,true,false,"String_Node_Str");
      }
    }
    mProcessesReady=true;
  }
  Slog.i(TAG,"String_Node_Str");
  EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_AMS_READY,SystemClock.uptimeMillis());
synchronized (this) {
    if (mFactoryTest == FactoryTest.FACTORY_TEST_LOW_LEVEL) {
      ResolveInfo ri=mContext.getPackageManager().resolveActivity(new Intent(Intent.ACTION_FACTORY_TEST),STOCK_PM_FLAGS);
      CharSequence errorMsg=null;
      if (ri != null) {
        ActivityInfo ai=ri.activityInfo;
        ApplicationInfo app=ai.applicationInfo;
        if ((app.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
          mTopAction=Intent.ACTION_FACTORY_TEST;
          mTopData=null;
          mTopComponent=new ComponentName(app.packageName,ai.name);
        }
 else {
          errorMsg=mContext.getResources().getText(com.android.internal.R.string.factorytest_not_system);
        }
      }
 else {
        errorMsg=mContext.getResources().getText(com.android.internal.R.string.factorytest_no_action);
      }
      if (errorMsg != null) {
        mTopAction=null;
        mTopData=null;
        mTopComponent=null;
        Message msg=Message.obtain();
        msg.what=SHOW_FACTORY_ERROR_MSG;
        msg.getData().putCharSequence("String_Node_Str",errorMsg);
        mHandler.sendMessage(msg);
      }
    }
  }
  retrieveSettings();
  loadResourcesOnSystemReady();
synchronized (this) {
    readGrantedUriPermissionsLocked();
  }
  if (goingCallback != null)   goingCallback.run();
  mBatteryStatsService.noteEvent(BatteryStats.HistoryItem.EVENT_USER_RUNNING_START,Integer.toString(mCurrentUserId),mCurrentUserId);
  mBatteryStatsService.noteEvent(BatteryStats.HistoryItem.EVENT_USER_FOREGROUND_START,Integer.toString(mCurrentUserId),mCurrentUserId);
  mSystemServiceManager.startUser(mCurrentUserId);
synchronized (this) {
    if (mFactoryTest != FactoryTest.FACTORY_TEST_LOW_LEVEL) {
      try {
        List apps=AppGlobals.getPackageManager().getPersistentApplications(STOCK_PM_FLAGS);
        if (apps != null) {
          int N=apps.size();
          int i;
          for (i=0; i < N; i++) {
            ApplicationInfo info=(ApplicationInfo)apps.get(i);
            if (info != null && !info.packageName.equals("String_Node_Str")) {
              addAppLocked(info,false,null);
            }
          }
        }
      }
 catch (      RemoteException ex) {
      }
    }
    mBooting=true;
    try {
      if (AppGlobals.getPackageManager().hasSystemUidErrors()) {
        Message msg=Message.obtain();
        msg.what=SHOW_UID_ERROR_MSG;
        mHandler.sendMessage(msg);
      }
    }
 catch (    RemoteException e) {
    }
    long ident=Binder.clearCallingIdentity();
    try {
      Intent intent=new Intent(Intent.ACTION_USER_STARTED);
      intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND);
      intent.putExtra(Intent.EXTRA_USER_HANDLE,mCurrentUserId);
      broadcastIntentLocked(null,null,intent,null,null,0,null,null,null,AppOpsManager.OP_NONE,false,false,MY_PID,Process.SYSTEM_UID,mCurrentUserId);
      intent=new Intent(Intent.ACTION_USER_STARTING);
      intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
      intent.putExtra(Intent.EXTRA_USER_HANDLE,mCurrentUserId);
      broadcastIntentLocked(null,null,intent,null,new IIntentReceiver.Stub(){
        @Override public void performReceive(        Intent intent,        int resultCode,        String data,        Bundle extras,        boolean ordered,        boolean sticky,        int sendingUser) throws RemoteException {
        }
      }
,0,null,null,INTERACT_ACROSS_USERS,AppOpsManager.OP_NONE,true,false,MY_PID,Process.SYSTEM_UID,UserHandle.USER_ALL);
    }
 catch (    Throwable t) {
      Slog.wtf(TAG,"String_Node_Str",t);
    }
 finally {
      Binder.restoreCallingIdentity(ident);
    }
    mStackSupervisor.resumeTopActivitiesLocked();
    sendUserSwitchBroadcastsLocked(-1,mCurrentUserId);
  }
}

Fixed version (ground truth):
public void systemReady(final Runnable goingCallback){
synchronized (this) {
    if (mSystemReady) {
      if (goingCallback != null) {
        goingCallback.run();
      }
      return;
    }
    updateCurrentProfileIdsLocked();
    if (mRecentTasks == null) {
      mRecentTasks=mTaskPersister.restoreTasksLocked();
      if (!mRecentTasks.isEmpty()) {
        mStackSupervisor.createStackForRestoredTaskHistory(mRecentTasks);
      }
      cleanupRecentTasksLocked(UserHandle.USER_ALL);
      mTaskPersister.startPersisting();
    }
    if (!mDidUpdate) {
      if (mWaitingUpdate) {
        return;
      }
      final ArrayList<ComponentName> doneReceivers=new ArrayList<ComponentName>();
      mWaitingUpdate=deliverPreBootCompleted(new Runnable(){
        public void run(){
synchronized (ActivityManagerService.this) {
            mDidUpdate=true;
          }
          writeLastDonePreBootReceivers(doneReceivers);
          showBootMessage(mContext.getText(R.string.android_upgrading_complete),false);
          systemReady(goingCallback);
        }
      }
,doneReceivers,UserHandle.USER_OWNER);
      if (mWaitingUpdate) {
        return;
      }
      mDidUpdate=true;
    }
    mAppOpsService.systemReady();
    mSystemReady=true;
  }
  ArrayList<ProcessRecord> procsToKill=null;
synchronized (mPidsSelfLocked) {
    for (int i=mPidsSelfLocked.size() - 1; i >= 0; i--) {
      ProcessRecord proc=mPidsSelfLocked.valueAt(i);
      if (!isAllowedWhileBooting(proc.info)) {
        if (procsToKill == null) {
          procsToKill=new ArrayList<ProcessRecord>();
        }
        procsToKill.add(proc);
      }
    }
  }
synchronized (this) {
    if (procsToKill != null) {
      for (int i=procsToKill.size() - 1; i >= 0; i--) {
        ProcessRecord proc=procsToKill.get(i);
        Slog.i(TAG,"String_Node_Str" + proc);
        removeProcessLocked(proc,true,false,"String_Node_Str");
      }
    }
    mProcessesReady=true;
  }
  Slog.i(TAG,"String_Node_Str");
  EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_AMS_READY,SystemClock.uptimeMillis());
synchronized (this) {
    if (mFactoryTest == FactoryTest.FACTORY_TEST_LOW_LEVEL) {
      ResolveInfo ri=mContext.getPackageManager().resolveActivity(new Intent(Intent.ACTION_FACTORY_TEST),STOCK_PM_FLAGS);
      CharSequence errorMsg=null;
      if (ri != null) {
        ActivityInfo ai=ri.activityInfo;
        ApplicationInfo app=ai.applicationInfo;
        if ((app.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
          mTopAction=Intent.ACTION_FACTORY_TEST;
          mTopData=null;
          mTopComponent=new ComponentName(app.packageName,ai.name);
        }
 else {
          errorMsg=mContext.getResources().getText(com.android.internal.R.string.factorytest_not_system);
        }
      }
 else {
        errorMsg=mContext.getResources().getText(com.android.internal.R.string.factorytest_no_action);
      }
      if (errorMsg != null) {
        mTopAction=null;
        mTopData=null;
        mTopComponent=null;
        Message msg=Message.obtain();
        msg.what=SHOW_FACTORY_ERROR_MSG;
        msg.getData().putCharSequence("String_Node_Str",errorMsg);
        mHandler.sendMessage(msg);
      }
    }
  }
  retrieveSettings();
  loadResourcesOnSystemReady();
synchronized (this) {
    readGrantedUriPermissionsLocked();
  }
  if (goingCallback != null)   goingCallback.run();
  mBatteryStatsService.noteEvent(BatteryStats.HistoryItem.EVENT_USER_RUNNING_START,Integer.toString(mCurrentUserId),mCurrentUserId);
  mBatteryStatsService.noteEvent(BatteryStats.HistoryItem.EVENT_USER_FOREGROUND_START,Integer.toString(mCurrentUserId),mCurrentUserId);
  mSystemServiceManager.startUser(mCurrentUserId);
synchronized (this) {
    if (mFactoryTest != FactoryTest.FACTORY_TEST_LOW_LEVEL) {
      try {
        List apps=AppGlobals.getPackageManager().getPersistentApplications(STOCK_PM_FLAGS);
        if (apps != null) {
          int N=apps.size();
          int i;
          for (i=0; i < N; i++) {
            ApplicationInfo info=(ApplicationInfo)apps.get(i);
            if (info != null && !info.packageName.equals("String_Node_Str")) {
              addAppLocked(info,false,null);
            }
          }
        }
      }
 catch (      RemoteException ex) {
      }
    }
    mBooting=true;
    startHomeActivityLocked(mCurrentUserId);
    try {
      if (AppGlobals.getPackageManager().hasSystemUidErrors()) {
        Message msg=Message.obtain();
        msg.what=SHOW_UID_ERROR_MSG;
        mHandler.sendMessage(msg);
      }
    }
 catch (    RemoteException e) {
    }
    long ident=Binder.clearCallingIdentity();
    try {
      Intent intent=new Intent(Intent.ACTION_USER_STARTED);
      intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND);
      intent.putExtra(Intent.EXTRA_USER_HANDLE,mCurrentUserId);
      broadcastIntentLocked(null,null,intent,null,null,0,null,null,null,AppOpsManager.OP_NONE,false,false,MY_PID,Process.SYSTEM_UID,mCurrentUserId);
      intent=new Intent(Intent.ACTION_USER_STARTING);
      intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
      intent.putExtra(Intent.EXTRA_USER_HANDLE,mCurrentUserId);
      broadcastIntentLocked(null,null,intent,null,new IIntentReceiver.Stub(){
        @Override public void performReceive(        Intent intent,        int resultCode,        String data,        Bundle extras,        boolean ordered,        boolean sticky,        int sendingUser) throws RemoteException {
        }
      }
,0,null,null,INTERACT_ACROSS_USERS,AppOpsManager.OP_NONE,true,false,MY_PID,Process.SYSTEM_UID,UserHandle.USER_ALL);
    }
 catch (    Throwable t) {
      Slog.wtf(TAG,"String_Node_Str",t);
    }
 finally {
      Binder.restoreCallingIdentity(ident);
    }
    mStackSupervisor.resumeTopActivitiesLocked();
    sendUserSwitchBroadcastsLocked(-1,mCurrentUserId);
  }
}