Protect the construction of the verification thread pool. am: 30ba3a02a5 am: 4ae3c7f582 am: 41170d43f5
Original change: https://android-review.googlesource.com/c/platform/art/+/1660238
Change-Id: Icda25bc400e0afa51b0d56b71fecd12e8b294db3
diff --git a/runtime/oat_file_manager.cc b/runtime/oat_file_manager.cc
index 74fe110..e485413 100644
--- a/runtime/oat_file_manager.cc
+++ b/runtime/oat_file_manager.cc
@@ -803,16 +803,18 @@
return;
}
- std::string vdex_filename = GetVdexFilename(odex_filename);
- if (verification_thread_pool_ == nullptr) {
- verification_thread_pool_.reset(
- new ThreadPool("Verification thread pool", /* num_threads= */ 1));
- verification_thread_pool_->StartWorkers(self);
+ {
+ WriterMutexLock mu(self, *Locks::oat_file_manager_lock_);
+ if (verification_thread_pool_ == nullptr) {
+ verification_thread_pool_.reset(
+ new ThreadPool("Verification thread pool", /* num_threads= */ 1));
+ verification_thread_pool_->StartWorkers(self);
+ }
}
verification_thread_pool_->AddTask(self, new BackgroundVerificationTask(
dex_files,
class_loader,
- vdex_filename));
+ GetVdexFilename(odex_filename)));
}
void OatFileManager::WaitForWorkersToBeCreated() {
diff --git a/runtime/thread_pool.cc b/runtime/thread_pool.cc
index f991c05..57d7f61 100644
--- a/runtime/thread_pool.cc
+++ b/runtime/thread_pool.cc
@@ -164,7 +164,7 @@
bool create_peers,
size_t worker_stack_size)
: name_(name),
- task_queue_lock_("task queue lock"),
+ task_queue_lock_("task queue lock", kGenericBottomLock),
task_queue_condition_("task queue condition", task_queue_lock_),
completion_condition_("task completion condition", task_queue_lock_),
started_(false),