diff options
author | Sebastien Hertz <shertz@google.com> | 2015-04-07 15:54:25 +0200 |
---|---|---|
committer | Sebastien Hertz <shertz@google.com> | 2015-04-08 12:13:28 +0200 |
commit | 692063955ae845d8bd9fa2d22a50a1e06513bdcf (patch) | |
tree | 39771e7a445ec9ff5d6c79bb37ff268e44d8ef64 /runtime/jdwp | |
parent | 1b8e8cac2c96f6d2af8e7217f997a30e11c098b5 (diff) | |
download | art-692063955ae845d8bd9fa2d22a50a1e06513bdcf.tar.gz art-692063955ae845d8bd9fa2d22a50a1e06513bdcf.tar.bz2 art-692063955ae845d8bd9fa2d22a50a1e06513bdcf.zip |
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.cc | 4 | ||||
-rw-r--r-- | runtime/jdwp/object_registry.h | 12 |
2 files changed, 13 insertions, 3 deletions
diff --git a/runtime/jdwp/object_registry.cc b/runtime/jdwp/object_registry.cc index 99a005df21..a42a58f601 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 0693f334bf..27a4e55f41 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_) |