diff options
author | 2022-10-13 02:47:24 +0000 | |
---|---|---|
committer | 2022-10-13 02:47:24 +0000 | |
commit | ebd76406bf5fa74185998bc29f0f27c20fa2e683 (patch) | |
tree | beec1accc089bbbc432a140dfebe28bb7278a909 /openjdkjvmti/ti_thread.cc | |
parent | fd20a745227aa7cae7a08728bb29e5bfce64ea87 (diff) |
Revert "Revert^2 "Thread suspension cleanup and deadlock fix""
This reverts commit fd20a745227aa7cae7a08728bb29e5bfce64ea87.
Reason for revert: Lots of libartd failures due to new checkpoint lock level check.
Change-Id: I0cf88ff893f8743a9a830a49489807d0921199a3
Diffstat (limited to 'openjdkjvmti/ti_thread.cc')
-rw-r--r-- | openjdkjvmti/ti_thread.cc | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/openjdkjvmti/ti_thread.cc b/openjdkjvmti/ti_thread.cc index 7d39fdf452..7fb789d558 100644 --- a/openjdkjvmti/ti_thread.cc +++ b/openjdkjvmti/ti_thread.cc @@ -900,14 +900,16 @@ 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) { + 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; } @@ -925,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 |