Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Spurious Death in Android?

Tags:

android

I know it sounds a lazy question.. but I really have no much clue about how this scenario happened, neither can I find much information about it on Google.

Background:

It's an app with IPC: I have a service running in separate process. Sometimes, the service is killed.. but it does not really "officially die", Instead, I got a term from the ActivityManager called "Spurious death". When this happened, services behaves like a zombie. It's alive but it's not really functioning.

04-12 10:03:37.935 728 830 I ActivityManager: Force finishing activity ActivityRecord{11eee41f u0 com.android.staging/com.android.activities.MainActivity t8210} 04-12 10:03:37.937 728 830 I ActivityManager: Force stopping service ServiceRecord{291a4c9b u0 com.android.staging/com.android.services.CallService} 04-12 10:03:37.969 728 2563 W ActivityManager: Spurious death for ProcessRecord{27ecf545 11057:com.android.staging/u0a268}, curProc for 11057: null

like image 725
xialin Avatar asked Apr 12 '15 14:04

xialin


1 Answers

The offending line can be found here: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.0_r1/com/android/server/am/ActivityManagerService.java/#4858 (Different line for different versions of Android L)

I assume you are using some form of Android L, since that particular error message wasn't added until then.

If you are running a ContentProvider in your process, these two comments in the ActivityManagerService might be of help:

9303                     // NOTE: there is still a race here where a signal could be
9304                     // pending on the process even though we managed to update its
9305                     // adj level.  Not sure what to do about this, but at least
9306                     // the race is now smaller.
9307                     if (!success) {
9308                         // Uh oh...  it looks like the provider's process
9309                         // has been killed on us.  We need to wait for a new
9310                         // process to be started, and make sure its death
9311                         // doesn't kill our process.

and then ...

9317                         appDiedLocked(cpr.proc);

appDiedLocked can be called from some other source files too: ActiveServices.java and ActivityStackSupervisor.java, one depends on DeadObjectException being thrown, the other on RemoteException.

appDiedLocked looks like this

4853     final void appDiedLocked(ProcessRecord app, int pid, IApplicationThread thread) {
4854         // First check if this ProcessRecord is actually active for the pid.
4855         synchronized (mPidsSelfLocked) {
4856             ProcessRecord curProc = mPidsSelfLocked.get(pid);
4857             if (curProc != app) {
4858                 Slog.w(TAG, "Spurious death for " + app + ", curProc for " + pid + ": " + curProc);
4859                 return;
4860             }
4861         }

For some reason, the curProc isn't the same as the app ProcessRecord, and the appDiedLocked method is cut short. In your case curProc is null, again for some reason.

Long story short: Your process died, or was killed, and some state or condition is preventing appDiedLocked from continuing down to run the killProcess commands. You have some more investigation / logging to do to find out why that happened.

If you have a service that you want to keep alive, unless you are doing it already, I would recommend that you attach a status bar notification to it, that way the likeliness of it being killed is lowered.

like image 80
Erik Zivkovic Avatar answered Oct 17 '22 01:10

Erik Zivkovic