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

Issue 2626883003: Make WebTaskRunner::postTask thread safe (Closed)

Created:
3 years, 11 months ago by Charlie Harrison
Modified:
3 years, 11 months ago
Reviewers:
esprehn, dcheng, Wez
CC:
blink-reviews, chromium-reviews, kinuko+watch
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Make WebTaskRunner::postTask thread safe Copying the summary from dcheng@ on the referenced bug: The current implementation looks like this: void WebTaskRunner::postTask(const WebTraceLocation& location, std::unique_ptr<CrossThreadClosure> task) { toSingleThreadTaskRunner()->PostTask(location, convertToBaseCallback(std::move(task))); } However, base::TaskRunner::PostTask() takes a const base::Closure&. When we convert the CrossThreadClosure to a base::Callback, we just extract the internal callback object. However, this callback object is never supposed to be copied, only moved. Since the base APIs haven't been updated to use base::OnceCallback, now we have two copies of the callback referencing the same base::BindState (which is holding the bound variables): one on the posting thread (call it thread 1), and one on the posted thread (call it thread 2). If the copy on thread 2 is destroyed before the copy on thread 1, base::BindState will be destroyed on thread 1. If base::BindState contained WTF::String or other thread-unsafe objects, and thread 2 copied it, this means that the thread-unsafe objects will be ref'ed and deref'ed on multiple threads, which is not good. BUG=679915, 680042 Review-Url: https://codereview.chromium.org/2626883003 Cr-Commit-Position: refs/heads/master@{#443028} Committed: https://chromium.googlesource.com/chromium/src/+/9b559c6994582ca25952810057dc778e82685ede

Patch Set 1 #

Patch Set 2 : all cross thread closures #

Total comments: 2

Patch Set 3 : dcheng review #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+15 lines, -3 lines) Patch
M third_party/WebKit/Source/platform/WebTaskRunner.cpp View 1 2 2 chunks +15 lines, -3 lines 1 comment Download

Dependent Patchsets:

Messages

Total messages: 33 (23 generated)
Charlie Harrison
dcheng, ptal? I had trouble reproing this with tsan with a custom SimTest or the ...
3 years, 11 months ago (2017-01-11 17:43:40 UTC) #14
dcheng
LGTM, but I'm not an OWNER in platform. I assume that the background html parser ...
3 years, 11 months ago (2017-01-11 18:19:16 UTC) #15
Charlie Harrison
https://codereview.chromium.org/2624443003 Is looking good with this patch applied to it. PS4 has a completed webkit_tests ...
3 years, 11 months ago (2017-01-11 18:43:34 UTC) #16
Charlie Harrison
+esprehn would you review this as platform owner?
3 years, 11 months ago (2017-01-11 18:44:12 UTC) #18
Wez
https://codereview.chromium.org/2626883003/diff/40001/third_party/WebKit/Source/platform/WebTaskRunner.cpp File third_party/WebKit/Source/platform/WebTaskRunner.cpp (right): https://codereview.chromium.org/2626883003/diff/40001/third_party/WebKit/Source/platform/WebTaskRunner.cpp#newcode117 third_party/WebKit/Source/platform/WebTaskRunner.cpp:117: // crbug.com/679915 for more details. Wouldn't it be better ...
3 years, 11 months ago (2017-01-11 21:21:49 UTC) #24
dcheng
On 2017/01/11 21:21:49, Wez wrote: > https://codereview.chromium.org/2626883003/diff/40001/third_party/WebKit/Source/platform/WebTaskRunner.cpp > File third_party/WebKit/Source/platform/WebTaskRunner.cpp (right): > > https://codereview.chromium.org/2626883003/diff/40001/third_party/WebKit/Source/platform/WebTaskRunner.cpp#newcode117 > ...
3 years, 11 months ago (2017-01-11 21:25:43 UTC) #25
esprehn
We should probably rename convertToBaseCallback() to convertToSameThreadCallback(), but we can do that in a follow ...
3 years, 11 months ago (2017-01-11 21:32:51 UTC) #26
esprehn
lgtm
3 years, 11 months ago (2017-01-11 21:33:24 UTC) #27
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2626883003/40001
3 years, 11 months ago (2017-01-11 21:34:51 UTC) #30
commit-bot: I haz the power
3 years, 11 months ago (2017-01-11 22:47:27 UTC) #33
Message was sent while issue was closed.
Committed patchset #3 (id:40001) as
https://chromium.googlesource.com/chromium/src/+/9b559c6994582ca25952810057dc...

Powered by Google App Engine
This is Rietveld 408576698