From e78cd4a8f142dee941e79cf12240004622e7b067 Mon Sep 17 00:00:00 2001 From: cobalt-github-releaser-bot <95661244+cobalt-github-releaser-bot@users.noreply.github.com> Date: Mon, 26 Jun 2023 10:53:38 -0700 Subject: [PATCH] Partially Revert Revert PR#554 and only leave the part of adding logs (#634) (#703) b/234788479 (cherry picked from commit ea5713ec33fa8b6932c0a89e3bd88ad6715e99a2) Co-authored-by: Sherry Zhou <128753035+sherryzy@users.noreply.github.com> --- base/single_thread_task_runner.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/base/single_thread_task_runner.cc b/base/single_thread_task_runner.cc index d4baf230dae4..2a937223408d 100644 --- a/base/single_thread_task_runner.cc +++ b/base/single_thread_task_runner.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "base/debug/stack_trace.h" #include "base/single_thread_task_runner.h" #include "base/message_loop/message_loop.h" #include "base/synchronization/waitable_event.h" @@ -47,7 +48,15 @@ void SingleThreadTaskRunner::PostBlockingTask(const base::Location& from_here, if (task_may_run) { // Wait for the task to complete before proceeding. - task_finished.Wait(); + do { + if (task_finished.TimedWait(base::TimeDelta::FromMilliseconds(1000))) { + break; + } +#if !defined(COBALT_BUILD_TYPE_GOLD) + base::debug::StackTrace trace; + trace.PrintWithPrefix("[task runner deadlock]"); +#endif // !defined(COBALT_BUILD_TYPE_GOLD) + } while (true); } } #endif