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

Issue 807423002: [Thread-safe] Apply base::Passed to WebThread::Task (Closed)

Created:
6 years ago by hiroshige
Modified:
6 years ago
Reviewers:
dcheng, nasko
CC:
darin-cc_chromium.org, jam
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[Thread-safe] Apply base::Passed to WebThread::Task WebThread::Task can contain RefPtr to a thread-unsafe-reference-counted object (e.g. WorkerThreadTask can contain RefPtr to WebKit's StringImpl). This caused a race condition: [A] When WebThread::Task::run is executed, more RefPtr's to the refcounted object can be created and the reference counter of the object can be modified via these RefPtr's (as intended) on the thread where the task is executed. [B] However, base::Closure still retains the ownership of WebThread::Task even after WebThread::Task::run is called. When base::Closure is deleted, WebThread::Task is deleted and the reference counter of the object is decreased by one, possibly from a different thread from [A], which is a race condition. This CL removes the ownership of WebThread::Task from base::Closure after WebThread::Task::run is executed by using scoped_ptr and base::Passed. This removes the reference counter modification of [B] and hence removes the race condition. BUG=390851 Committed: https://crrev.com/8446b33c7ea20bd1596f876ab225034b7c5d1162 Cr-Commit-Position: refs/heads/master@{#309396}

Patch Set 1 #

Total comments: 8

Patch Set 2 : #

Total comments: 6

Patch Set 3 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+33 lines, -4 lines) Patch
M content/child/webthread_impl.cc View 1 2 2 chunks +33 lines, -4 lines 0 comments Download

Messages

Total messages: 13 (3 generated)
hiroshige
PTAL.
6 years ago (2014-12-18 09:00:45 UTC) #2
nasko
dcheng@ is probably a better reviewer of this CL than myself. I've noted couple of ...
6 years ago (2014-12-18 17:53:25 UTC) #4
dcheng
https://codereview.chromium.org/807423002/diff/1/content/child/webthread_impl.cc File content/child/webthread_impl.cc (right): https://codereview.chromium.org/807423002/diff/1/content/child/webthread_impl.cc#newcode63 content/child/webthread_impl.cc:63: static void RunWebThreadTask(scoped_ptr<blink::WebThread::Task> task) This code is really subtle. ...
6 years ago (2014-12-18 19:31:38 UTC) #5
hiroshige
Thank you for reviewing! https://codereview.chromium.org/807423002/diff/1/content/child/webthread_impl.cc File content/child/webthread_impl.cc (right): https://codereview.chromium.org/807423002/diff/1/content/child/webthread_impl.cc#newcode63 content/child/webthread_impl.cc:63: static void RunWebThreadTask(scoped_ptr<blink::WebThread::Task> task) Added ...
6 years ago (2014-12-19 09:16:12 UTC) #6
dcheng
Thanks for the updated explanations. This looks reasonable to me but you'll need approval from ...
6 years ago (2014-12-19 09:20:37 UTC) #7
nasko
Based on dcheng@'s review, LGTM. I do have a few nits to improve the comment ...
6 years ago (2014-12-19 17:22:44 UTC) #8
hiroshige
Thanks! https://codereview.chromium.org/807423002/diff/20001/content/child/webthread_impl.cc File content/child/webthread_impl.cc (right): https://codereview.chromium.org/807423002/diff/20001/content/child/webthread_impl.cc#newcode63 content/child/webthread_impl.cc:63: // |RunWebThreadTask| takes the ownership of |task| from ...
6 years ago (2014-12-22 04:18:47 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/807423002/40001
6 years ago (2014-12-22 04:23:07 UTC) #11
commit-bot: I haz the power
Committed patchset #3 (id:40001)
6 years ago (2014-12-22 05:45:30 UTC) #12
commit-bot: I haz the power
6 years ago (2014-12-22 05:46:20 UTC) #13
Message was sent while issue was closed.
Patchset 3 (id:??) landed as
https://crrev.com/8446b33c7ea20bd1596f876ab225034b7c5d1162
Cr-Commit-Position: refs/heads/master@{#309396}

Powered by Google App Engine
This is Rietveld 408576698