Re: When will a patch be issued to correct Android issue #52890 - ActivityManagerService ANR

422 views
Skip to first unread message

John P Masseria

unread,
Mar 11, 2013, 8:39:57 PM3/11/13
to android-...@googlegroups.com
Actually, looking at the Android source code for Master (https://android.googlesource.com/platform/frameworks/base/+/master), the patch I referenced doesn't appear to apply to this issue and is probably already integrated.

Could I be having this problem because I have Developer options enabled?

I mean this happens to me on both my Android devices (Nexus 7 4.2.2) and Samsung Galaxy S3 (4.1.1) several times a day!  I can't imagine why this isn't happening to more users?


On Friday, March 8, 2013 8:58:24 PM UTC-5, John P Masseria wrote:
I keep getting:
    *** WATCHDOG KILLING SYSTEM PROCESS: com.android.server.am.ActivityManagerService

This is happening on my Nexus 7 running Android 4.2.2 Build JDQ39

This problem can happen several times a day and is very annoying and frustrating.

Looking at the stacks dumped into /data/anr/traces.txt I can see a deadlock between threads of system_server, specifically, tid=1 is trying to lock <0x41503730> which is held by tid=53 (LocationManagerService) which is waiting to lock <0x41422fe0> (a com.android.server.am.ActivityManagerService) held by tid=1 (main).

This is a classic deadlock.

This issues is similar to issues # 41465 & 46806.

The reporter of #41465 found the patch below which appears to correct this problem.

https://android.googlesource.com/platform/frameworks/base/+/73c14161ec85629ebd6b5e24605a174305187e24

How do I get a version of Android that is corrected for this issue?

----- pid 1876 at 2013-03-01 14:41:50 -----
Cmd line: system_server

DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0)

"main" prio=5 tid=1 MONITOR
  | group="main" sCount=1 dsCount=0 obj=0x40ce49a0 self=0x40094010
  | sysTid=1876 nice=0 sched=0/0 cgrp=apps handle=1074512860
  | state=S schedstat=( 3340884000 2417058000 11366 ) utm=272 stm=62 core=2
  at android.app.ActivityThread.acquireExistingProvider(ActivityThread.java:~4546)
  - waiting to lock <0x41503730> (a java.util.HashMap) held by tid=63 (LocationManagerService)
  at android.app.ContextImpl$ApplicationContentResolver.acquireExistingProvider(ContextImpl.java:1992)
  at android.content.ContentResolver.acquireExistingProvider(ContentResolver.java:1073)
  at android.content.ContentResolver.getType(ContentResolver.java:215)
  at android.content.Intent.resolveType(Intent.java:4030)
  at android.content.IntentFilter.match(IntentFilter.java:1070)
  at com.android.server.am.ActivityManagerService.getStickiesLocked(ActivityManagerService.java:11291)
  at com.android.server.am.ActivityManagerService.registerReceiver(ActivityManagerService.java:11362)
  at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:305)
  at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1674)
  at android.os.Binder.execTransact(Binder.java:351)
  at com.android.server.SystemServer.init1(Native Method)
  at com.android.server.SystemServer.main(SystemServer.java:1064)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:511)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
  at dalvik.system.NativeStart.main(Native Method)

And

"LocationManagerService" prio=5 tid=63 MONITOR
  | group="main" sCount=1 dsCount=0 obj=0x41934bf0 self=0x66f8f0e8
  | sysTid=2075 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1729685536
  | state=S schedstat=( 509137000 9870895000 3967 ) utm=32 stm=18 core=2
  at com.android.server.am.ActivityManagerService.refContentProvider(ActivityManagerService.java:~6804)
  - waiting to lock <0x41422fe0> (a com.android.server.am.ActivityManagerService) held by tid=1 (main)
  at android.app.ActivityThread.incProviderRefLocked(ActivityThread.java:4505)
  at android.app.ActivityThread.acquireExistingProvider(ActivityThread.java:4568)
  at android.app.ActivityThread.acquireProvider(ActivityThread.java:4449)
  at android.app.ContextImpl$ApplicationContentResolver.acquireProvider(ContextImpl.java:1987)
  at android.content.ContentResolver.acquireProvider(ContentResolver.java:1054)
  at android.content.ContentResolver.query(ContentResolver.java:394)
  at android.content.ContentResolver.query(ContentResolver.java:315)
  at com.android.server.location.GpsLocationProvider.getSelectedApn(GpsLocationProvider.java:1559)
  at com.android.server.location.GpsLocationProvider.handleUpdateNetworkState(GpsLocationProvider.java:536)
  at com.android.server.location.GpsLocationProvider.access$2000(GpsLocationProvider.java:82)
  at com.android.server.location.GpsLocationProvider$ProviderHandler.handleMessage(GpsLocationProvider.java:1512)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:137)
  at com.android.server.LocationManagerService.run(LocationManagerService.java:205)
  at java.lang.Thread.run(Thread.java:856)

John P Masseria

unread,
Mar 12, 2013, 10:57:59 AM3/12/13
to android-...@googlegroups.com
After studying the Android source the problem appears to be that android.app.ActivityThread.acquireExistingProvider(ActivityThread.java:4568) locks synchronized (mProviderMap)and then eventually calls ActivityManagerNative.getDefault().refContentProvider which tries to lock ActivityServiceManager using synchronized (this)

The problem is that anyone who has called ActivityManagerService.getStickiesLocked already has ActivityServiceManager locked and then tries to lock  synchronized (mProviderMap) which results in the deadlock.

Semaphores need to be locked in the same order or deadlocks can result.

My recommendation (although please forgive my naivety I'm just learning Android) is to alter ActivityThread.acquireExistingProvider to lock the ActivityServiceManager right before trying to lock mProviderMap.  Again, I'm new to use, but possibly use:

synchronized (this) {
synchronized (mProviderMap) {
.
.
.
}
}


Again, I haven't fully studied this and I don't know what the downside to doing this is such as what if (this) is already synchronized (locked), i.e. will that cause an exception.


Whatever the case, this issue is rendering my Android 4.1.1 and 4.2.2 devices USELESS as they ANR multiple times a day and usually at the most inopportune moments!

Thank you,
John Masseria

John P Masseria

unread,
Mar 13, 2013, 11:59:59 AM3/13/13
to android-...@googlegroups.com
There are at least two additional open issues reported on this problem in code.google.com/android/issues, they are issue # 46806 and 41465.  Including my issue #52890 they all involve ActivityManagerService and ActivityThread not locking semaphores in a consistent order.

Can someone responsible for this code please at least acknowledge that this is indeed a code issue and that a fix for the issue is being worked on?

I am willing to run a debug version of code if you need more information to debug and correct the problem.  I have a Nexus 7 and Samsung GS3 that both exhibit different versions of this same issue.  The Nexus involves LocationManagerServer while the Samsung (4.1.1) involves GpsLocationProvider.  I have dozens of /data/anr/traces.txt instances of this problem if required.

Thank you,
John

John P Masseria

unread,
Mar 19, 2013, 10:48:11 AM3/19/13
to android-...@googlegroups.com
Can anyone explain why this problem is so intermittent for me?  I've been running for a few days now without an re-occurrences.  Is this problem exacerbated by some application I am running?

Thanking you in advance for a response,

John P Masseria

unread,
Mar 20, 2013, 11:19:28 AM3/20/13
to android-...@googlegroups.com
Dianne Hackborn,

If you are reading the postings of this group, can I please get your opinion of my problem?

Am I doing something to my Android 4.1.1 and 4.2.2 devices that causes them to periodically have this ActivityManagerService ANR GUI restart?  (Is that the correct name to give to this problem?)

For the past few days my devices have not been exhibiting this problem which is very confusing to me as I don't believe that I have done anything unusual to them.  I haven't rooted the devices to even tried to root them.  I am learning to develop Android programs so I do have both devices in developer mode.

Thanking you in advance for your response to my questions,
John Masseria

John P Masseria

unread,
Mar 27, 2013, 10:42:17 AM3/27/13
to android-...@googlegroups.com
Can anyone think of a reason why this problem is no longer happening on my devices?  

Is it possible that an Android update has gotten pushed out that I am unaware of?

Thank you,
John

John P Masseria

unread,
Apr 3, 2013, 1:15:09 PM4/3/13
to android-...@googlegroups.com
Am I using this forum incorrectly?  I'm curious to understand why this thread hasn't received any replies?

Respectfully,
John

KaPiL.rIcKy

unread,
Apr 4, 2013, 4:08:20 AM4/4/13
to android-...@googlegroups.com
I am not sure about your problem cause and counter measure, but even i didnt get much help for my problems i posted before :-\



--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-platfo...@googlegroups.com.
To post to this group, send email to android-...@googlegroups.com.
Visit this group at http://groups.google.com/group/android-platform?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--

~~~~~~~~~~~~~~~~~~~~~~~~~~
Thanks and regards
Kapil Kumar
~~~~~~~~~~~~~~~~~~~~~~~~~~

Jean-Baptiste Queru

unread,
Apr 4, 2013, 10:39:09 AM4/4/13
to android-...@googlegroups.com
Nothing wrong on your side, people are just really really busy.

JBQ
> --
> You received this message because you are subscribed to the Google Groups
> "android-platform" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to android-platfo...@googlegroups.com.
> To post to this group, send email to android-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/android-platform?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Jean-Baptiste M. "JBQ" Queru
Technical Lead, Android Open Source Project, Google.

Questions sent directly to me that have no reason for being private
will likely get ignored or forwarded to a public forum with no further
warning.
Reply all
Reply to author
Forward
0 new messages