summaryrefslogtreecommitdiff
path: root/openjdkjvmti/ti_thread.cc
diff options
context:
space:
mode:
author Hans Boehm <hboehm@google.com> 2023-09-09 23:19:28 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2023-09-09 23:19:28 +0000
commita43e67ea1a314e5c6faf77457ffc5ea39c24d4ca (patch)
tree9ffb0fce0deed66670477257567bd9a617449105 /openjdkjvmti/ti_thread.cc
parentf9fdd3ce0180972dc8d4f0c8410ea7702828a703 (diff)
Revert "Revert^14 "Thread suspension cleanup and deadlock fix""
This reverts commit f9fdd3ce0180972dc8d4f0c8410ea7702828a703. Reason for revert: Very suspicious host-x86_64-debug failure on LUCI. Change-Id: Ia01dd3df8d64d6bc0d12319b06a8380f64a46785
Diffstat (limited to 'openjdkjvmti/ti_thread.cc')
-rw-r--r--openjdkjvmti/ti_thread.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/openjdkjvmti/ti_thread.cc b/openjdkjvmti/ti_thread.cc
index 22aa8fe302..13eebbff04 100644
--- a/openjdkjvmti/ti_thread.cc
+++ b/openjdkjvmti/ti_thread.cc
@@ -547,7 +547,6 @@ static jint GetJavaStateFromInternal(const InternalThreadState& state) {
// Suspends the current thread if it has any suspend requests on it.
void ThreadUtil::SuspendCheck(art::Thread* self) {
- DCHECK(!self->ReadFlag(art::ThreadFlag::kSuspensionImmune));
art::ScopedObjectAccess soa(self);
// Really this is only needed if we are in FastJNI and actually have the mutator_lock_ already.
self->FullSuspendCheck();
@@ -901,13 +900,17 @@ jvmtiError ThreadUtil::SuspendOther(art::Thread* self,
}
}
}
+ bool timeout = true;
art::Thread* ret_target = art::Runtime::Current()->GetThreadList()->SuspendThreadByPeer(
- target_jthread, art::SuspendReason::kForUserCode);
- if (ret_target == nullptr) {
+ target_jthread,
+ art::SuspendReason::kForUserCode,
+ &timeout);
+ if (ret_target == nullptr && !timeout) {
// TODO It would be good to get more information about why exactly the thread failed to
// suspend.
return ERR(INTERNAL);
- } else {
+ } else if (!timeout) {
+ // we didn't time out and got a result.
return OK;
}
// We timed out. Just go around and try again.
@@ -924,7 +927,11 @@ jvmtiError ThreadUtil::SuspendSelf(art::Thread* self) {
// This can only happen if we race with another thread to suspend 'self' and we lose.
return ERR(THREAD_SUSPENDED);
}
- self->IncrementSuspendCount(self, nullptr, nullptr, art::SuspendReason::kForUserCode);
+ // We shouldn't be able to fail this.
+ if (!self->ModifySuspendCount(self, +1, nullptr, art::SuspendReason::kForUserCode)) {
+ // TODO More specific error would be nice.
+ return ERR(INTERNAL);
+ }
}
// Once we have requested the suspend we actually go to sleep. We need to do this after releasing
// the suspend_lock to make sure we can be woken up. This call gains the mutator lock causing us