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

Issue 1232573002: Fix a "benign" data race during thread construction (Closed)

Created:
5 years, 5 months ago by Sami
Modified:
5 years, 5 months ago
Reviewers:
danakj
CC:
chromium-reviews, erikwright+watch_chromium.org, sadrul, kinuko
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Fix a "benign" data race during thread construction This patch fixes data race on Thread::task_runner() which happens during thread creation: Origin thread New thread ------------- ---------- 1. Construct a Thread | '-----------------------------. | V 3. Call Thread::task_runner() 2. Bind the message loop on the thread => MessageLoop::task_runner() => MessageLoop::SetTaskRunner() Steps 2 and 3 introduce a data race with one thread reading the task runner pointer and the other writing to it. The race is "benign" because the new thread is setting MessageLoop::task_runner_ to the same value it already has (it is also initialized in the constructor). This patch fixes the problem by not unnecessarily writing to the task runner. BUG=508789

Patch Set 1 #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+11 lines, -1 line) Patch
M base/message_loop/message_loop.h View 1 chunk +4 lines, -0 lines 0 comments Download
M base/message_loop/message_loop.cc View 2 chunks +7 lines, -1 line 3 comments Download

Depends on Patchset:

Messages

Total messages: 6 (1 generated)
Sami
PTAL.
5 years, 5 months ago (2015-07-10 09:46:30 UTC) #2
danakj
https://codereview.chromium.org/1232573002/diff/1/base/message_loop/message_loop.cc File base/message_loop/message_loop.cc (right): https://codereview.chromium.org/1232573002/diff/1/base/message_loop/message_loop.cc#newcode410 base/message_loop/message_loop.cc:410: unbound_task_runner_ = nullptr; I'm feeling like this unbound_task_runner_ is ...
5 years, 5 months ago (2015-07-10 18:32:38 UTC) #3
Sami
Thanks for taking a look. https://codereview.chromium.org/1232573002/diff/1/base/message_loop/message_loop.cc File base/message_loop/message_loop.cc (right): https://codereview.chromium.org/1232573002/diff/1/base/message_loop/message_loop.cc#newcode410 base/message_loop/message_loop.cc:410: unbound_task_runner_ = nullptr; On ...
5 years, 5 months ago (2015-07-13 10:43:31 UTC) #4
danakj
https://codereview.chromium.org/1232573002/diff/1/base/message_loop/message_loop.cc File base/message_loop/message_loop.cc (right): https://codereview.chromium.org/1232573002/diff/1/base/message_loop/message_loop.cc#newcode410 base/message_loop/message_loop.cc:410: unbound_task_runner_ = nullptr; On 2015/07/13 10:43:31, Sami wrote: > ...
5 years, 5 months ago (2015-07-13 18:33:48 UTC) #5
Sami
5 years, 5 months ago (2015-07-13 18:40:48 UTC) #6
Thanks! I'll roll this into the original patch
(https://codereview.chromium.org/998063002/) and reland.

Powered by Google App Engine
This is Rietveld 408576698