Workaround for class loader issues in verifier.
bug: 73760543
bug: 73549918
bug: 64759619
Test: 676-resolve-field-type
Change-Id: Iac30bd2dcfb7266c8ef6f5e283de5b6951ca07bf
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 63d47e6..418c01c 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -7957,17 +7957,18 @@
// In case of jmvti, the dex file gets verified before being registered, so first
// check if it's registered before checking class tables.
const DexFile& dex_file = *dex_cache->GetDexFile();
- CHECK(!IsDexFileRegistered(Thread::Current(), dex_file) ||
- FindClassTable(Thread::Current(), dex_cache) == ClassTableForClassLoader(class_loader))
+ DCHECK(!IsDexFileRegistered(Thread::Current(), dex_file) ||
+ FindClassTable(Thread::Current(), dex_cache) == ClassTableForClassLoader(class_loader))
<< "DexFile referrer: " << dex_file.GetLocation()
<< " ClassLoader: " << DescribeLoaders(class_loader, "");
// Be a good citizen and update the dex cache to speed subsequent calls.
dex_cache->SetResolvedMethod(method_idx, resolved, image_pointer_size_);
- const DexFile::MethodId& method_id = dex_file.GetMethodId(method_idx);
- DCHECK(LookupResolvedType(method_id.class_idx_, dex_cache, class_loader) != nullptr)
- << "Method: " << resolved->PrettyMethod() << ", "
- << "Class: " << klass->PrettyClass() << " (" << klass->GetStatus() << "), "
- << "DexFile referrer: " << dex_file.GetLocation();
+ // Disable the following invariant check as the verifier breaks it. b/73760543
+ // const DexFile::MethodId& method_id = dex_file.GetMethodId(method_idx);
+ // DCHECK(LookupResolvedType(method_id.class_idx_, dex_cache, class_loader) != nullptr)
+ // << "Method: " << resolved->PrettyMethod() << ", "
+ // << "Class: " << klass->PrettyClass() << " (" << klass->GetStatus() << "), "
+ // << "DexFile referrer: " << dex_file.GetLocation();
}
return resolved;
}
@@ -7999,13 +8000,9 @@
DCHECK(resolved->GetDeclaringClassUnchecked() != nullptr) << resolved->GetDexMethodIndex();
klass = LookupResolvedType(method_id.class_idx_, dex_cache.Get(), class_loader.Get());
if (UNLIKELY(klass == nullptr)) {
- const char* descriptor = dex_file.StringByTypeIdx(method_id.class_idx_);
- LOG(FATAL) << "Check failed: klass != nullptr Bug: 64759619 Method: "
- << resolved->PrettyMethod() << ";" << resolved
- << "/0x" << std::hex << resolved->GetAccessFlags()
- << " ReferencedClass: " << descriptor
- << " DexFile referrer: " << dex_file.GetLocation()
- << " ClassLoader: " << DescribeLoaders(class_loader.Get(), descriptor);
+ // We normaly should not end up here. However the verifier currently doesn't guarantee
+ // the invariant of having the klass in the class table. b/73760543
+ klass = ResolveType(method_id.class_idx_, dex_cache, class_loader);
}
} else {
// The method was not in the DexCache, resolve the declaring class.