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