summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alex Light <allight@google.com> 2017-07-20 10:04:11 -0700
committer Alex Light <allight@google.com> 2017-07-20 10:31:41 -0700
commit6ee332cc58d602bb7f16513795dc32568b176efa (patch)
tree60bd28decf56445fff6bdf0bdff4e25b84bb7237
parente8f48da635c4d07bbe431e5819da8e1fad91a8ef (diff)
Ensure that we don't overwrite suspension target thread
Thanks to Ivan Maidanski for noticing this issue. Contributed-By: Ivan Maidanski <i.maidanski@samsung.com> Test: ./test.py --host -j40 Change-Id: I826e3770645ecaedd8a4c5e5201747010ddcf550
-rw-r--r--runtime/openjdkjvmti/ti_thread.cc6
-rw-r--r--runtime/openjdkjvmti/ti_thread.h4
2 files changed, 6 insertions, 4 deletions
diff --git a/runtime/openjdkjvmti/ti_thread.cc b/runtime/openjdkjvmti/ti_thread.cc
index f16b419ab7..9acea2a288 100644
--- a/runtime/openjdkjvmti/ti_thread.cc
+++ b/runtime/openjdkjvmti/ti_thread.cc
@@ -701,7 +701,7 @@ jvmtiError ThreadUtil::RunAgentThread(jvmtiEnv* jvmti_env,
jvmtiError ThreadUtil::SuspendOther(art::Thread* self,
jthread target_jthread,
- art::Thread* target) {
+ const art::Thread* target) {
// Loop since we need to bail out and try again if we would end up getting suspended while holding
// the user_code_suspension_lock_ due to a SuspendReason::kForUserCode. In this situation we
// release the lock, wait to get resumed and try again.
@@ -729,12 +729,12 @@ jvmtiError ThreadUtil::SuspendOther(art::Thread* self,
if (state == art::ThreadState::kTerminated || state == art::ThreadState::kStarting) {
return ERR(THREAD_NOT_ALIVE);
}
- target = art::Runtime::Current()->GetThreadList()->SuspendThreadByPeer(
+ art::Thread* ret_target = art::Runtime::Current()->GetThreadList()->SuspendThreadByPeer(
target_jthread,
/* request_suspension */ true,
art::SuspendReason::kForUserCode,
&timeout);
- if (target == nullptr && !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);
diff --git a/runtime/openjdkjvmti/ti_thread.h b/runtime/openjdkjvmti/ti_thread.h
index d07dc0682b..0f7e8379fd 100644
--- a/runtime/openjdkjvmti/ti_thread.h
+++ b/runtime/openjdkjvmti/ti_thread.h
@@ -98,7 +98,9 @@ class ThreadUtil {
// cause the thread to wake up if the thread is suspended for the debugger or gc or something.
static jvmtiError SuspendSelf(art::Thread* self)
REQUIRES(!art::Locks::mutator_lock_, !art::Locks::user_code_suspension_lock_);
- static jvmtiError SuspendOther(art::Thread* self, jthread target_jthread, art::Thread* target)
+ static jvmtiError SuspendOther(art::Thread* self,
+ jthread target_jthread,
+ const art::Thread* target)
REQUIRES(!art::Locks::mutator_lock_, !art::Locks::user_code_suspension_lock_);
static art::ArtField* context_class_loader_;