summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Calin Juravle <calin@google.com> 2018-03-23 03:07:44 +0000
committer android-build-merger <android-build-merger@google.com> 2018-03-23 03:07:44 +0000
commit7fac4617502880577eb28a40d65af5035c45cc99 (patch)
tree18762aa83fc12f1e7f36df0d4dc97a9e1603623d
parent889da15d94086e4b9ce09a99ed2089148b58d72d (diff)
parent2df6aa4178a70e967c690db53399fbd0a7bab8db (diff)
Merge "Add extra checks around the profile file descriptor." into pi-dev
am: 2df6aa4178 Change-Id: Ibe5118538ab78dbe3cd390387359fd8af267854e
-rw-r--r--services/core/java/com/android/server/pm/dex/ArtManagerService.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/pm/dex/ArtManagerService.java b/services/core/java/com/android/server/pm/dex/ArtManagerService.java
index 062a6b866c2b..41ed6f22ea36 100644
--- a/services/core/java/com/android/server/pm/dex/ArtManagerService.java
+++ b/services/core/java/com/android/server/pm/dex/ArtManagerService.java
@@ -198,7 +198,14 @@ public class ArtManagerService extends android.content.pm.dex.IArtManager.Stub {
ParcelFileDescriptor fd = null;
try {
fd = ParcelFileDescriptor.open(snapshotProfile, ParcelFileDescriptor.MODE_READ_ONLY);
- postSuccess(packageName, fd, callback);
+ if (fd == null || !fd.getFileDescriptor().valid()) {
+ Slog.wtf(TAG,
+ "ParcelFileDescriptor.open returned an invalid descriptor for "
+ + packageName + ":" + snapshotProfile + ". isNull=" + (fd == null));
+ postError(callback, packageName, ArtManager.SNAPSHOT_FAILED_INTERNAL_ERROR);
+ } else {
+ postSuccess(packageName, fd, callback);
+ }
} catch (FileNotFoundException e) {
Slog.w(TAG, "Could not open snapshot profile for " + packageName + ":"
+ snapshotProfile, e);
@@ -264,7 +271,7 @@ public class ArtManagerService extends android.content.pm.dex.IArtManager.Stub {
mHandler.post(() -> {
try {
callback.onError(errCode);
- } catch (RemoteException e) {
+ } catch (Exception e) {
Slog.w(TAG, "Failed to callback after profile snapshot for " + packageName, e);
}
});
@@ -277,8 +284,17 @@ public class ArtManagerService extends android.content.pm.dex.IArtManager.Stub {
}
mHandler.post(() -> {
try {
- callback.onSuccess(fd);
- } catch (RemoteException e) {
+ // Double check that the descriptor is still valid.
+ // We've seen production issues (b/76028139) where this can turn invalid (there are
+ // suspicions around the finalizer behaviour).
+ if (fd.getFileDescriptor().valid()) {
+ callback.onSuccess(fd);
+ } else {
+ Slog.wtf(TAG, "The snapshot FD became invalid before posting the result for "
+ + packageName);
+ callback.onError(ArtManager.SNAPSHOT_FAILED_INTERNAL_ERROR);
+ }
+ } catch (Exception e) {
Slog.w(TAG,
"Failed to call onSuccess after profile snapshot for " + packageName, e);
} finally {