Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(852)

Issue 1106213002: Adds a SHUTDOWN_TASK_QUEUE and a PreShutdown api to the scheduler. (Closed)

Created:
5 years, 8 months ago by Sami
Modified:
5 years, 7 months ago
Reviewers:
rmcilroy
CC:
chromium-reviews, jam, scheduler-bugs_chromium.org, darin-cc_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Adds a SHUTDOWN_TASK_QUEUE and a PreShutdown api to the scheduler. Unfortunately webworkers have a complicated shutdown process and we need to be very careful to prevent execution of timers once the shutdown process has started or we risk UAF bugs. This patch adds the concept of a SHUTDOWN_TASK_QUEUE to the SchedulerHelper (which is always on) and a PreShutdown API which turns off all other queues except for the shutdown and control ones. Original patch by Alex Clarke <alexclarke@chromium.org>; (https://codereview.chromium.org/1101703003/). BUG=463143 TBR=sky@chromium.org

Patch Set 1 #

Total comments: 5

Patch Set 2 : Rebased. #

Patch Set 3 : Review comments. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+248 lines, -22 lines) Patch
M components/html_viewer/web_scheduler_impl.h View 1 chunk +4 lines, -0 lines 0 comments Download
M components/html_viewer/web_scheduler_impl.cc View 1 chunk +19 lines, -1 line 0 comments Download
M components/scheduler/child/child_scheduler.h View 1 2 2 chunks +8 lines, -0 lines 0 comments Download
M components/scheduler/child/null_worker_scheduler.h View 2 chunks +2 lines, -0 lines 0 comments Download
M components/scheduler/child/null_worker_scheduler.cc View 2 chunks +8 lines, -0 lines 0 comments Download
M components/scheduler/child/scheduler_helper.h View 1 2 4 chunks +13 lines, -0 lines 0 comments Download
M components/scheduler/child/scheduler_helper.cc View 1 2 10 chunks +40 lines, -11 lines 0 comments Download
M components/scheduler/child/scheduler_helper_unittest.cc View 1 2 6 chunks +54 lines, -2 lines 0 comments Download
M components/scheduler/child/web_scheduler_impl.h View 3 chunks +7 lines, -1 line 0 comments Download
M components/scheduler/child/web_scheduler_impl.cc View 2 chunks +22 lines, -2 lines 0 comments Download
M components/scheduler/child/webthread_impl_for_worker_scheduler.cc View 2 chunks +6 lines, -4 lines 0 comments Download
M components/scheduler/child/webthread_impl_for_worker_scheduler_unittest.cc View 1 2 2 chunks +18 lines, -0 lines 0 comments Download
M components/scheduler/child/worker_scheduler_impl.h View 1 chunk +2 lines, -0 lines 0 comments Download
M components/scheduler/child/worker_scheduler_impl.cc View 2 chunks +11 lines, -0 lines 0 comments Download
M components/scheduler/renderer/null_renderer_scheduler.h View 2 chunks +2 lines, -0 lines 0 comments Download
M components/scheduler/renderer/null_renderer_scheduler.cc View 2 chunks +8 lines, -0 lines 0 comments Download
M components/scheduler/renderer/renderer_scheduler_impl.h View 2 chunks +2 lines, -0 lines 0 comments Download
M components/scheduler/renderer/renderer_scheduler_impl.cc View 2 chunks +10 lines, -0 lines 0 comments Download
M components/scheduler/renderer/webthread_impl_for_renderer_scheduler.cc View 1 chunk +2 lines, -1 line 0 comments Download
M content/test/fake_renderer_scheduler.h View 2 chunks +2 lines, -0 lines 0 comments Download
M content/test/fake_renderer_scheduler.cc View 2 chunks +8 lines, -0 lines 0 comments Download

Messages

Total messages: 4 (1 generated)
Sami
Ross, mind having a look? The main difference to before is that the selector no ...
5 years, 8 months ago (2015-04-27 16:57:47 UTC) #2
rmcilroy
A couple of questions / suggestions but lgtm - although I really wish we didn't ...
5 years, 7 months ago (2015-04-28 09:51:10 UTC) #3
Sami
5 years, 7 months ago (2015-04-28 11:52:47 UTC) #4
Thanks Ross!

> A couple of questions / suggestions but lgtm - although I really wish we
didn't
> need to do this :(.

Likewise :P However given the way worker threads are set up on the Blink side I
don't see a simpler option. I guess one option would be to wrap all worker tasks
-- a little how is being done at the moment but maybe more at the WebThread
level. I think I'll see how that would look before landing this.

https://codereview.chromium.org/1106213002/diff/1/components/scheduler/child/...
File components/scheduler/child/scheduler_helper.cc (right):

https://codereview.chromium.org/1106213002/diff/1/components/scheduler/child/...
components/scheduler/child/scheduler_helper.cc:108: if (i == CONTROL_TASK_QUEUE
|| i == SHUTDOWN_TASK_QUEUE)
On 2015/04/28 09:51:09, rmcilroy wrote:
> I'm wondering whether we even need the control task queue here? I don't think
we
> need anything on that queue after preshutdown, but it might be safer to keep
it
> running. I'll leave it up to you.

I thought Alex originally made kept the control queue stay alive because the
worker shutdown task was posted through there, but looks like that actually goes
through the shutdown queue. I think I agree that just having one queue be
special is better, so I'll do that. I'll run the layout tests to see if anything
breaks before landing though.

https://codereview.chromium.org/1106213002/diff/1/components/scheduler/child/...
File components/scheduler/child/scheduler_helper_unittest.cc (right):

https://codereview.chromium.org/1106213002/diff/1/components/scheduler/child/...
components/scheduler/child/scheduler_helper_unittest.cc:932:
PostTestTasks(&run_order, "D1 I1 T1");
I noticed we weren't actually posting a shutdown task. Fixed.

https://codereview.chromium.org/1106213002/diff/1/components/scheduler/child/...
File components/scheduler/child/webthread_impl_for_worker_scheduler_unittest.cc
(right):

https://codereview.chromium.org/1106213002/diff/1/components/scheduler/child/...
components/scheduler/child/webthread_impl_for_worker_scheduler_unittest.cc:129:
base::Lock lock;
On 2015/04/28 09:51:10, rmcilroy wrote:
> Can you not just use a WaitableEvent and check !completion.IsSignaled() in
> TestThreadShutdownAfterPreShutdown?

Good idea, that's cleaner.

Also found out that these tests weren't actually being run anymore:
https://codereview.chromium.org/1112523003/ :P

Powered by Google App Engine
This is Rietveld 408576698