From 55accd5725442026c8c32dc773b1cd12a65f90f6 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Tue, 24 May 2016 17:41:21 -0700 Subject: [PATCH] Fix broken DCHECK Dex cache may now contain references into boot image. Only check classes that are actually in the application image. Bug: 28295348 Change-Id: I9d92137c99a53924b13182ded6afabdeb441437d --- runtime/class_linker.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 26544946b..d2e23aac1 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -1348,7 +1348,8 @@ bool ClassLinker::UpdateAppImageClassLoadersAndDexCaches( for (int32_t j = 0; j < static_cast(num_types); j++) { // The image space is not yet added to the heap, avoid read barriers. mirror::Class* klass = types[j].Read(); - if (klass != nullptr) { + // There may also be boot image classes, + if (space->HasAddress(klass)) { DCHECK_NE(klass->GetStatus(), mirror::Class::kStatusError); // Update the class loader from the one in the image class loader to the one that loaded // the app image. @@ -1387,6 +1388,9 @@ bool ClassLinker::UpdateAppImageClassLoadersAndDexCaches( VLOG(image) << PrettyMethod(&m); } } + } else { + DCHECK(klass == nullptr || heap->ObjectIsInBootImageSpace(klass)) + << klass << " " << PrettyClass(klass); } } } @@ -1394,10 +1398,10 @@ bool ClassLinker::UpdateAppImageClassLoadersAndDexCaches( for (int32_t j = 0; j < static_cast(num_types); j++) { // The image space is not yet added to the heap, avoid read barriers. mirror::Class* klass = types[j].Read(); - if (klass != nullptr) { + if (space->HasAddress(klass)) { DCHECK_NE(klass->GetStatus(), mirror::Class::kStatusError); if (kIsDebugBuild) { - if (new_class_set != nullptr) { + if (new_class_set != nullptr) { auto it = new_class_set->Find(GcRoot(klass)); DCHECK(it != new_class_set->end()); DCHECK_EQ(it->Read(), klass); -- 2.11.0