Hold dex caches live in class table
Prevents temporary dex caches being unloaded for the same dex file.
Usually this is OK, but if someone resolved a string in that dex
cache, it could leave stale pointers in BSS. Also it can use extra
memory in linear alloc if we allocate dex cache arrays multiple
times.
Bug: 29083330
Change-Id: Ia44668f013ceef1f5eb80f653a48d0f8004548c9
diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc
index f5458c0..aa4635d 100644
--- a/oatdump/oatdump.cc
+++ b/oatdump/oatdump.cc
@@ -1118,8 +1118,7 @@
ScopedObjectAccess soa(Thread::Current());
Runtime* const runtime = Runtime::Current();
Handle<mirror::DexCache> dex_cache(
- hs->NewHandle(runtime->GetClassLinker()->RegisterDexFile(*dex_file,
- runtime->GetLinearAlloc())));
+ hs->NewHandle(runtime->GetClassLinker()->RegisterDexFile(*dex_file, nullptr)));
DCHECK(options_.class_loader_ != nullptr);
return verifier::MethodVerifier::VerifyMethodAndDump(
soa.Self(), vios, dex_method_idx, dex_file, dex_cache, *options_.class_loader_,
@@ -2283,7 +2282,7 @@
std::string error_msg;
const DexFile* const dex_file = OpenDexFile(odf, &error_msg);
CHECK(dex_file != nullptr) << error_msg;
- class_linker->RegisterDexFile(*dex_file, runtime->GetLinearAlloc());
+ class_linker->RegisterDexFile(*dex_file, nullptr);
class_path.push_back(dex_file);
}