OSDN Git Service

Don't add or remove verifiers if aborting
authorMathieu Chartier <mathieuc@google.com>
Tue, 16 Dec 2014 03:26:29 +0000 (19:26 -0800)
committerMathieu Chartier <mathieuc@google.com>
Tue, 16 Dec 2014 03:31:40 +0000 (19:31 -0800)
Prevents deadlock if marking verifier roots fails when we attempt to
dump the stack traces. The deadlock occurs from FindLocksAtDexPC
since this allocates a new verifier then adds / removes it from the
method_verifiers_ array.

Bug: 18651054
Change-Id: Ia9b9470ce5e4ac20bfbb39bef0283974cf487765

runtime/runtime.cc

index 07e2ec0..e91f7c0 100644 (file)
@@ -1380,12 +1380,18 @@ void Runtime::SetCompileTimeClassPath(jobject class_loader,
 
 void Runtime::AddMethodVerifier(verifier::MethodVerifier* verifier) {
   DCHECK(verifier != nullptr);
+  if (gAborting) {
+    return;
+  }
   MutexLock mu(Thread::Current(), method_verifier_lock_);
   method_verifiers_.insert(verifier);
 }
 
 void Runtime::RemoveMethodVerifier(verifier::MethodVerifier* verifier) {
   DCHECK(verifier != nullptr);
+  if (gAborting) {
+    return;
+  }
   MutexLock mu(Thread::Current(), method_verifier_lock_);
   auto it = method_verifiers_.find(verifier);
   CHECK(it != method_verifiers_.end());