summaryrefslogtreecommitdiffstats
path: root/runtime/debugger.cc
diff options
context:
space:
mode:
authorSebastien Hertz <shertz@google.com>2015-01-13 22:48:34 +0100
committerSebastien Hertz <shertz@google.com>2015-01-13 23:11:06 +0100
commit55f6534f260ec82ef2d69a0667b1883f13d11399 (patch)
tree6e00c7f32242baf3a1482db3656816a0b2f134a4 /runtime/debugger.cc
parent8fccea249b1a6f1469eeea42c2b2cca06ce1c70d (diff)
downloadart-55f6534f260ec82ef2d69a0667b1883f13d11399.tar.gz
art-55f6534f260ec82ef2d69a0667b1883f13d11399.tar.bz2
art-55f6534f260ec82ef2d69a0667b1883f13d11399.zip
JDWP: fix deadlock with GC
This CL fixes a deadlock where JDWP thread and running GC thread are waiting for each other. Here is the sequence of the deadlock: 1. GC thread disables access to weak global references, then releases mutator lock. 2. JDWP thread takes mutator lock exclusively after suspending all threads. 3. GC thread waits for shared mutator lock which is held by JDWP thread. 4. JDWP thread clears weak global references but need to wait for GC thread to re-enable access to them. To avoid that situation, we ensure the JDWP thread does not attempt to delete weak global references while holding the mutator exclusively so GC thread is not blocked. Bug: 18995321 Change-Id: Ia7e82f463c27ffdcfd730c3117337a6a33d111e7
Diffstat (limited to 'runtime/debugger.cc')
-rw-r--r--runtime/debugger.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index fe1e3a4aa5..229a1af6b1 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -819,10 +819,15 @@ void Dbg::Disconnected() {
}
gDebuggerActive = false;
}
- gRegistry->Clear();
- gDebuggerConnected = false;
CHECK_EQ(self->SetStateUnsafe(old_state), kRunnable);
runtime->GetThreadList()->ResumeAll();
+
+ {
+ ScopedObjectAccess soa(self);
+ gRegistry->Clear();
+ }
+
+ gDebuggerConnected = false;
}
bool Dbg::IsDebuggerActive() {