diff options
author | 2023-08-24 03:34:15 +0000 | |
---|---|---|
committer | 2023-08-24 18:11:34 +0000 | |
commit | 2a52e8a50c3bc9011713a085f058130bb13fd6a6 (patch) | |
tree | 3a93cc8b7f5a37cb2b67f54411a13b9d569e54e4 /runtime/native/java_lang_Thread.cc | |
parent | fc11133bad774ad3a6289863e1c252a57a94485d (diff) |
Revert "Revert^12 "Thread suspension cleanup and deadlock fix""
This reverts commit 996cbb566a5521ca3b0653007e7921469f58981a.
Reason for revert: Some new intermittent master-art-host buildbot failures look related and need investigation.
PS2: Fix oat.h merge conflict by not letting the revert touch it.
PS3: Correct PS2 to actually bump the version once more instead.
Change-Id: I70c46dc4494b585768f36e5074d34645d2fb562a
Diffstat (limited to 'runtime/native/java_lang_Thread.cc')
-rw-r--r-- | runtime/native/java_lang_Thread.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/runtime/native/java_lang_Thread.cc b/runtime/native/java_lang_Thread.cc index fd67a0a7fa..570c554782 100644 --- a/runtime/native/java_lang_Thread.cc +++ b/runtime/native/java_lang_Thread.cc @@ -147,8 +147,11 @@ static void Thread_setNativeName(JNIEnv* env, jobject peer, jstring java_name) { // thread list lock to avoid this, as setting the thread name causes mutator to lock/unlock // in the DDMS send code. ThreadList* thread_list = Runtime::Current()->GetThreadList(); + bool timed_out; // Take suspend thread lock to avoid races with threads trying to suspend this one. - Thread* thread = thread_list->SuspendThreadByPeer(peer, SuspendReason::kInternal); + Thread* thread = thread_list->SuspendThreadByPeer(peer, + SuspendReason::kInternal, + &timed_out); if (thread != nullptr) { { ScopedObjectAccess soa(env); @@ -156,6 +159,9 @@ static void Thread_setNativeName(JNIEnv* env, jobject peer, jstring java_name) { } bool resumed = thread_list->Resume(thread, SuspendReason::kInternal); DCHECK(resumed); + } else if (timed_out) { + LOG(ERROR) << "Trying to set thread name to '" << name.c_str() << "' failed as the thread " + "failed to suspend within a generous timeout."; } } |