summaryrefslogtreecommitdiffstats
path: root/runtime/jdwp
diff options
context:
space:
mode:
authorSebastien Hertz <shertz@google.com>2015-04-07 15:54:25 +0200
committerSebastien Hertz <shertz@google.com>2015-04-08 12:13:28 +0200
commit692063955ae845d8bd9fa2d22a50a1e06513bdcf (patch)
tree39771e7a445ec9ff5d6c79bb37ff268e44d8ef64 /runtime/jdwp
parent1b8e8cac2c96f6d2af8e7217f997a30e11c098b5 (diff)
downloadart-692063955ae845d8bd9fa2d22a50a1e06513bdcf.zip
art-692063955ae845d8bd9fa2d22a50a1e06513bdcf.tar.gz
art-692063955ae845d8bd9fa2d22a50a1e06513bdcf.tar.bz2
JDWP: fix thread_list deadlock
Limits the scope of Locks::thread_list_lock_ locking in the debugger so we do not try to lock it twice when creating a JDWP id (because calling Object::IdentityHashCode may need to take the lock). Bug: 20048099 Change-Id: I305dd72ccc4d2d007d1603b0d52bcfa94b6842a7
Diffstat (limited to 'runtime/jdwp')
-rw-r--r--runtime/jdwp/object_registry.cc4
-rw-r--r--runtime/jdwp/object_registry.h12
2 files changed, 13 insertions, 3 deletions
diff --git a/runtime/jdwp/object_registry.cc b/runtime/jdwp/object_registry.cc
index 99a005d..a42a58f 100644
--- a/runtime/jdwp/object_registry.cc
+++ b/runtime/jdwp/object_registry.cc
@@ -50,6 +50,10 @@ JDWP::ObjectId ObjectRegistry::InternalAdd(mirror::Object* o) {
Thread* const self = Thread::Current();
self->AssertNoPendingException();
+ // Object::IdentityHashCode may cause these locks to be held so check we do not already
+ // hold them.
+ Locks::thread_list_lock_->AssertNotHeld(self);
+ Locks::thread_suspend_count_lock_->AssertNotHeld(self);
StackHandleScope<1> hs(self);
Handle<mirror::Object> obj_h(hs.NewHandle(o));
diff --git a/runtime/jdwp/object_registry.h b/runtime/jdwp/object_registry.h
index 0693f33..27a4e55 100644
--- a/runtime/jdwp/object_registry.h
+++ b/runtime/jdwp/object_registry.h
@@ -62,9 +62,13 @@ class ObjectRegistry {
ObjectRegistry();
JDWP::ObjectId Add(mirror::Object* o)
- SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) LOCKS_EXCLUDED(Locks::thread_list_lock_);
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
+ LOCKS_EXCLUDED(Locks::thread_list_lock_,
+ Locks::thread_suspend_count_lock_);
JDWP::RefTypeId AddRefType(mirror::Class* c)
- SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) LOCKS_EXCLUDED(Locks::thread_list_lock_);
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
+ LOCKS_EXCLUDED(Locks::thread_list_lock_,
+ Locks::thread_suspend_count_lock_);
template<typename T> T Get(JDWP::ObjectId id, JDWP::JdwpError* error)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
@@ -96,7 +100,9 @@ class ObjectRegistry {
private:
JDWP::ObjectId InternalAdd(mirror::Object* o)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
- LOCKS_EXCLUDED(lock_, Locks::thread_list_lock_);
+ LOCKS_EXCLUDED(lock_,
+ Locks::thread_list_lock_,
+ Locks::thread_suspend_count_lock_);
mirror::Object* InternalGet(JDWP::ObjectId id, JDWP::JdwpError* error)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)