diff options
Diffstat (limited to 'runtime/thread.cc')
-rw-r--r-- | runtime/thread.cc | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/runtime/thread.cc b/runtime/thread.cc index 80542e8b55..7335e409bf 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -991,8 +991,10 @@ static void UnsafeLogFatalForSuspendCount(Thread* self, Thread* thread) NO_THREA LOG(FATAL) << ss.str(); } -bool Thread::ModifySuspendCount(Thread* self, int delta, AtomicInteger* suspend_barrier, - bool for_debugger) { +bool Thread::ModifySuspendCountInternal(Thread* self, + int delta, + AtomicInteger* suspend_barrier, + bool for_debugger) { if (kIsDebugBuild) { DCHECK(delta == -1 || delta == +1 || delta == -tls32_.debug_suspend_count) << delta << " " << tls32_.debug_suspend_count << " " << this; @@ -1007,6 +1009,12 @@ bool Thread::ModifySuspendCount(Thread* self, int delta, AtomicInteger* suspend_ return false; } + if (kUseReadBarrier && delta > 0 && this != self && tlsPtr_.flip_function != nullptr) { + // Force retry of a suspend request if it's in the middle of a thread flip to avoid a + // deadlock. b/31683379. + return false; + } + uint16_t flags = kSuspendRequest; if (delta > 0 && suspend_barrier != nullptr) { uint32_t available_barrier = kMaxSuspendBarriers; @@ -1854,7 +1862,7 @@ mirror::Object* Thread::DecodeJObject(jobject obj) const { } IndirectRef ref = reinterpret_cast<IndirectRef>(obj); IndirectRefKind kind = GetIndirectRefKind(ref); - mirror::Object* result; + ObjPtr<mirror::Object> result; bool expect_null = false; // The "kinds" below are sorted by the frequency we expect to encounter them. if (kind == kLocal) { @@ -1867,7 +1875,7 @@ mirror::Object* Thread::DecodeJObject(jobject obj) const { if (LIKELY(HandleScopeContains(obj))) { // Read from handle scope. result = reinterpret_cast<StackReference<mirror::Object>*>(obj)->AsMirrorPtr(); - VerifyObject(result); + VerifyObject(result.Ptr()); } else { tlsPtr_.jni_env->vm->JniAbortF(nullptr, "use of invalid jobject %p", obj); expect_null = true; @@ -1889,7 +1897,7 @@ mirror::Object* Thread::DecodeJObject(jobject obj) const { tlsPtr_.jni_env->vm->JniAbortF(nullptr, "use of deleted %s %p", ToStr<IndirectRefKind>(kind).c_str(), obj); } - return result; + return result.Ptr(); } bool Thread::IsJWeakCleared(jweak obj) const { |