From 7c8835df16147b9096dd4c9380ab4b5f700ea17d Mon Sep 17 00:00:00 2001 From: Hans Boehm Date: Sat, 10 Sep 2022 00:08:42 +0000 Subject: Revert "Thread suspension cleanup and deadlock fix" This reverts commit 7c39c86b17c91e651de1fcc0876fe5565e3f5204. Reason for revert: We're see a number of new, somewhat rare, timeouts on multiple tests. Change-Id: Ida9a4f80b64b6fedc16db176a8df9c2e985ef482 --- runtime/native/java_lang_Thread.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'runtime/native/java_lang_Thread.cc') 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."; } } -- cgit v1.2.3-59-g8ed1b