summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/class_linker.cc15
-rw-r--r--runtime/oat_file.cc7
2 files changed, 19 insertions, 3 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 9ac27a126e..c9c3136d38 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -2092,6 +2092,21 @@ mirror::DexCache* ClassLinker::AllocDexCache(Thread* self,
reinterpret_cast<ArtMethod**>(raw_arrays + layout.MethodsOffset());
ArtField** fields = (dex_file.NumFieldIds() == 0u) ? nullptr :
reinterpret_cast<ArtField**>(raw_arrays + layout.FieldsOffset());
+ if (kIsDebugBuild) {
+ // Sanity check to make sure all the dex cache arrays are empty. b/28992179
+ for (size_t i = 0; i < dex_file.NumStringIds(); ++i) {
+ CHECK(strings[i].Read<kWithoutReadBarrier>() == nullptr);
+ }
+ for (size_t i = 0; i < dex_file.NumTypeIds(); ++i) {
+ CHECK(types[i].Read<kWithoutReadBarrier>() == nullptr);
+ }
+ for (size_t i = 0; i < dex_file.NumMethodIds(); ++i) {
+ CHECK(mirror::DexCache::GetElementPtrSize(methods, i, image_pointer_size_) == nullptr);
+ }
+ for (size_t i = 0; i < dex_file.NumFieldIds(); ++i) {
+ CHECK(mirror::DexCache::GetElementPtrSize(fields, i, image_pointer_size_) == nullptr);
+ }
+ }
dex_cache->Init(&dex_file,
location.Get(),
strings,
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index 995ea9974d..62c723e76f 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -500,11 +500,12 @@ class DlOpenOatFile FINAL : public OatFileBase {
~DlOpenOatFile() {
if (dlopen_handle_ != nullptr) {
- dlclose(dlopen_handle_);
-
if (!kIsTargetBuild) {
MutexLock mu(Thread::Current(), *Locks::host_dlopen_handles_lock_);
host_dlopen_handles_.erase(dlopen_handle_);
+ dlclose(dlopen_handle_);
+ } else {
+ dlclose(dlopen_handle_);
}
}
}
@@ -660,9 +661,9 @@ bool DlOpenOatFile::Dlopen(const std::string& elf_filename,
#else
UNUSED(oat_file_begin);
static_assert(!kIsTargetBuild, "host_dlopen_handles_ will leak handles");
+ MutexLock mu(Thread::Current(), *Locks::host_dlopen_handles_lock_);
dlopen_handle_ = dlopen(absolute_path.get(), RTLD_NOW);
if (dlopen_handle_ != nullptr) {
- MutexLock mu(Thread::Current(), *Locks::host_dlopen_handles_lock_);
if (!host_dlopen_handles_.insert(dlopen_handle_).second) {
dlclose(dlopen_handle_);
dlopen_handle_ = nullptr;