From 9ccb85d344bd9e569efee47b3450c2c6c4f8049c Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Thu, 17 Nov 2016 17:14:20 -0700 Subject: [PATCH] wtf() should not be fatal for core components. Core system components (such as those marked as "persistent") are aggressively restarted by the system, so crashing them as a side effect of wtf() could easily cause system instability. Instead, this change now treats persistent processes the same as the system_server; we still log the wtf() event, but we don't crash the app. This change also causes wtf() events to be fatal on "eng" builds, which will result in bugs being caught earlier during development instead of later during QA testing. Test: builds, boots, SystemUI no longer crashes Bug: 32976626 Change-Id: Ib2d1a73379be40556f8dab5d1f15b9ed91ba7082 --- .../com/android/server/am/ActivityManagerService.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 77d36f2568036..2e272cfbc506e 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -13523,9 +13523,11 @@ public class ActivityManagerService extends IActivityManager.Stub final ProcessRecord r = handleApplicationWtfInner(callingUid, callingPid, app, tag, crashInfo); - if (r != null && r.pid != Process.myPid() && - Settings.Global.getInt(mContext.getContentResolver(), - Settings.Global.WTF_IS_FATAL, 0) != 0) { + final boolean isFatal = "eng".equals(Build.TYPE) || Settings.Global + .getInt(mContext.getContentResolver(), Settings.Global.WTF_IS_FATAL, 0) != 0; + final boolean isSystem = (r == null) || r.persistent; + + if (isFatal && !isSystem) { mAppErrors.crashApplication(r, crashInfo); return true; } else {