summaryrefslogtreecommitdiffstats
path: root/runtime/base
diff options
context:
space:
mode:
authorbowen_lai <bowen_lai@htc.com>2015-03-13 14:34:40 +0800
committerMathieu Chartier <mathieuc@google.com>2015-03-13 10:20:40 -0700
commit2435a43f6c851c23922d8508fb17c6079248201c (patch)
treea0eea938dfbafc8f8e1546528295005d3a55ecee /runtime/base
parentc685bce4e6cfec075cb5b468d06b2fcdeeda2005 (diff)
downloadart-2435a43f6c851c23922d8508fb17c6079248201c.zip
art-2435a43f6c851c23922d8508fb17c6079248201c.tar.gz
art-2435a43f6c851c23922d8508fb17c6079248201c.tar.bz2
ART: Add entries_ lock for race condition
GCDaemon thread would visit incorrect RegType content when there is another thread initializing classes. Add a lock to protect entries_. https://code.google.com/p/android/issues/detail?id=159849 Change-Id: Iabaa1c7f5cc5106b60a6e3856152e0797e8a5d6d
Diffstat (limited to 'runtime/base')
-rw-r--r--runtime/base/mutex.cc5
-rw-r--r--runtime/base/mutex.h5
2 files changed, 9 insertions, 1 deletions
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc
index 13dcb8c..2ec2b0c 100644
--- a/runtime/base/mutex.cc
+++ b/runtime/base/mutex.cc
@@ -46,6 +46,7 @@ Mutex* Locks::intern_table_lock_ = nullptr;
Mutex* Locks::jni_libraries_lock_ = nullptr;
Mutex* Locks::logging_lock_ = nullptr;
Mutex* Locks::mem_maps_lock_ = nullptr;
+Mutex* Locks::method_verifiers_lock_ = nullptr;
Mutex* Locks::modify_ldt_lock_ = nullptr;
ReaderWriterMutex* Locks::mutator_lock_ = nullptr;
Mutex* Locks::profiler_lock_ = nullptr;
@@ -1001,6 +1002,10 @@ void Locks::Init() {
classlinker_classes_lock_ = new ReaderWriterMutex("ClassLinker classes lock",
current_lock_level);
+ UPDATE_CURRENT_LOCK_LEVEL(kMethodVerifiersLock);
+ DCHECK(method_verifiers_lock_ == nullptr);
+ method_verifiers_lock_ = new Mutex("Method verifiers lock", current_lock_level);
+
UPDATE_CURRENT_LOCK_LEVEL(kMonitorPoolLock);
DCHECK(allocated_monitor_ids_lock_ == nullptr);
allocated_monitor_ids_lock_ = new Mutex("allocated monitor ids lock", current_lock_level);
diff --git a/runtime/base/mutex.h b/runtime/base/mutex.h
index 3b052c0..f9e1e62 100644
--- a/runtime/base/mutex.h
+++ b/runtime/base/mutex.h
@@ -86,6 +86,7 @@ enum LockLevel {
kModifyLdtLock,
kAllocatedThreadIdsLock,
kMonitorPoolLock,
+ kMethodVerifiersLock,
kClassLinkerClassesLock,
kBreakpointLock,
kMonitorLock,
@@ -587,9 +588,11 @@ class Locks {
// Guards lists of classes within the class linker.
static ReaderWriterMutex* classlinker_classes_lock_ ACQUIRED_AFTER(breakpoint_lock_);
+ static Mutex* method_verifiers_lock_ ACQUIRED_AFTER(classlinker_classes_lock_);
+
// When declaring any Mutex add DEFAULT_MUTEX_ACQUIRED_AFTER to use annotalysis to check the code
// doesn't try to hold a higher level Mutex.
- #define DEFAULT_MUTEX_ACQUIRED_AFTER ACQUIRED_AFTER(Locks::classlinker_classes_lock_)
+ #define DEFAULT_MUTEX_ACQUIRED_AFTER ACQUIRED_AFTER(Locks::method_verifiers_lock_)
static Mutex* allocated_monitor_ids_lock_ ACQUIRED_AFTER(classlinker_classes_lock_);