From c0f64799da4ff941d5d132027a3b723fc76a5d5a Mon Sep 17 00:00:00 2001 From: Ulya Trafimovich Date: Thu, 4 Feb 2021 10:04:39 +0000 Subject: [PATCH] Don't write nonexistent DEX file paths to dexpreopt.config files. A path to an nonexistent file caused dex2oat to write an empty path in the class loader context stored inside of the OAT/ODEX file, which resulted in class loader context mistmatch and a failure to load dexpreopt code on device. An example of a faulty class loader context for GoogleDialer, can be seen either with oatdump or by grepping logcat for class loader context mimatch messages (the first empty PCL[] is expected, note the second empty PCL[] in the subcontext for shared libraries): PCL[]{PCL[]#PCL[/system/framework/org.apache.http.legacy.jar*22205474] This CL removes the nonexistent path from the generated dexpreopt.config file, which works in conjunction with a change in makefiles that stops using the removed config field. This is possible because makefiles can access DEX files using a module name and "intermediates-dir-for" macro. Bug: 132357300 Test: lunch cf_x86_64_phone-userdebug && m && launch_cvd \ adb wait-for-device && adb root && adb logcat \ | grep -E 'ClassLoaderContext [a-z ]+ mismatch' # empty grep output, no errors Change-Id: I8d16f77c6f76ad6234cc4114ad3545cbe572ef13 --- java/dexpreopt.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/java/dexpreopt.go b/java/dexpreopt.go index da621003a..29c73c11f 100644 --- a/java/dexpreopt.go +++ b/java/dexpreopt.go @@ -129,8 +129,6 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Wr dexLocation := android.InstallPathToOnDevicePath(ctx, d.installPath) - buildPath := android.PathForModuleOut(ctx, "dexpreopt", ctx.ModuleName()+".jar").OutputPath - providesUsesLib := ctx.ModuleName() if ulib, ok := ctx.Module().(ProvidesUsesLib); ok { name := ulib.ProvidesUsesLib() @@ -146,7 +144,6 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Wr slimDexpreoptConfig := &dexpreopt.ModuleConfig{ Name: ctx.ModuleName(), DexLocation: dexLocation, - BuildPath: buildPath, EnforceUsesLibraries: d.enforceUsesLibs, ProvidesUsesLibrary: providesUsesLib, ClassLoaderContexts: d.classLoaderContexts, @@ -218,7 +215,7 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Wr dexpreoptConfig := &dexpreopt.ModuleConfig{ Name: ctx.ModuleName(), DexLocation: dexLocation, - BuildPath: buildPath, + BuildPath: android.PathForModuleOut(ctx, "dexpreopt", ctx.ModuleName()+".jar").OutputPath, DexPath: dexJarFile, ManifestPath: d.manifestFile, UncompressedDex: d.uncompressedDex,