Shutdown hang when single-threaded BLOCK_SHUTDOWN task is posted after single-threaded CONTINUE_ON_SHUTDOWN task |
||||
Issue description
I have a dump from a shutdown hang (67.0.3387.0 canary) that appears to be due to a task blocking shutdown, but I don't see such a task.
The UI thread is blocked on the Wait in TaskTracker::PerformShutdown:
// It is safe to access |shutdown_event_| without holding |lock_| because the
// pointer never changes after being set above.
{
base::ThreadRestrictions::ScopedAllowWait allow_wait;
shutdown_event_->Wait();
}
The only thread that's within a call to RunTask is on a COM thread that was supposedly started with CONTINUE_ON_SHUTDOWN. It's posted from here:
void BackgroundDownloader::DoStartDownload(const GURL& url) {
DCHECK(thread_checker_.CalledOnValidThread());
com_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&BackgroundDownloader::BeginDownload,
base::Unretained(this), url));
}
and the task runner was created with:
com_task_runner_(base::CreateCOMSTATaskRunnerWithTraits(
kTaskTraitsBackgroundDownloader)),
where kTaskTraitsBackgroundDownloader is:
constexpr base::TaskTraits kTaskTraitsBackgroundDownloader = {
base::MayBlock(), base::TaskPriority::BACKGROUND,
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN};
Here's a full memory dump if anyone wants to take a look: https://drive.google.com/file/d/0B54adY1TO21BM0VHVTBQZFhEU1k/view?usp=sharing.
,
Apr 6 2018
,
Apr 6 2018
Agreed with solution in #1, thanks!
,
Apr 12 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/a016f19dced52530584d5e8609bca4b1ce9a0453 commit a016f19dced52530584d5e8609bca4b1ce9a0453 Author: Francois Doray <fdoray@chromium.org> Date: Thu Apr 12 15:44:18 2018 TaskScheduler: Prevent single-threaded CONTINUE_ON_SHUTDOWN from blocking shutdown. Previously, tasks posted to a shared SingleThreadTaskRunner with the same traits were scheduled on the same thread. If single-threaded task A (BACKGROUND, CONTINUE_ON_SHUTDOWN) was scheduled on the thread and single-threaded task B (BACKGROUND, BLOCK_SHUTDOWN) was posted afterwards, shutdown could not complete until task A finished and allowed task B to run on the thread. This CL fixes the issue by scheduling shared single-threaded tasks that are CONTINUE_ON_SHUTDOWN/non-CONTINUE_ON_SHUTDOWN on different threads. Bug: 829786 Change-Id: Ia0b556971895c2a5799157f8dcf1a1ee6ce650c9 Reviewed-on: https://chromium-review.googlesource.com/1005422 Commit-Queue: François Doray <fdoray@chromium.org> Reviewed-by: Gabriel Charette <gab@chromium.org> Cr-Commit-Position: refs/heads/master@{#550216} [modify] https://crrev.com/a016f19dced52530584d5e8609bca4b1ce9a0453/base/task_scheduler/scheduler_single_thread_task_runner_manager.cc [modify] https://crrev.com/a016f19dced52530584d5e8609bca4b1ce9a0453/base/task_scheduler/scheduler_single_thread_task_runner_manager.h [modify] https://crrev.com/a016f19dced52530584d5e8609bca4b1ce9a0453/base/task_scheduler/scheduler_single_thread_task_runner_manager_unittest.cc
,
Apr 12 2018
,
Apr 17 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/a016f19dced52530584d5e8609bca4b1ce9a0453 commit a016f19dced52530584d5e8609bca4b1ce9a0453 Author: Francois Doray <fdoray@chromium.org> Date: Thu Apr 12 15:44:18 2018 TaskScheduler: Prevent single-threaded CONTINUE_ON_SHUTDOWN from blocking shutdown. Previously, tasks posted to a shared SingleThreadTaskRunner with the same traits were scheduled on the same thread. If single-threaded task A (BACKGROUND, CONTINUE_ON_SHUTDOWN) was scheduled on the thread and single-threaded task B (BACKGROUND, BLOCK_SHUTDOWN) was posted afterwards, shutdown could not complete until task A finished and allowed task B to run on the thread. This CL fixes the issue by scheduling shared single-threaded tasks that are CONTINUE_ON_SHUTDOWN/non-CONTINUE_ON_SHUTDOWN on different threads. Bug: 829786 Change-Id: Ia0b556971895c2a5799157f8dcf1a1ee6ce650c9 Reviewed-on: https://chromium-review.googlesource.com/1005422 Commit-Queue: François Doray <fdoray@chromium.org> Reviewed-by: Gabriel Charette <gab@chromium.org> Cr-Commit-Position: refs/heads/master@{#550216} [modify] https://crrev.com/a016f19dced52530584d5e8609bca4b1ce9a0453/base/task_scheduler/scheduler_single_thread_task_runner_manager.cc [modify] https://crrev.com/a016f19dced52530584d5e8609bca4b1ce9a0453/base/task_scheduler/scheduler_single_thread_task_runner_manager.h [modify] https://crrev.com/a016f19dced52530584d5e8609bca4b1ce9a0453/base/task_scheduler/scheduler_single_thread_task_runner_manager_unittest.cc |
||||
►
Sign in to add a comment |
||||
Comment 1 by fdoray@chromium.org
, Apr 6 2018Status: Assigned (was: Untriaged)