diff options
author | rockot <rockot@chromium.org> | 2016-02-19 19:40:59 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-20 03:41:51 +0000 |
commit | 935f2631aeb6bd2fb107a36fac368f7dc309ccfc (patch) | |
tree | 6a6c47789e051f033b5b340c8c06ab38f30ebe51 /mojo/edk | |
parent | a397f08a60ca6da5faff590a491b2af348958f8b (diff) | |
download | chromium_src-935f2631aeb6bd2fb107a36fac368f7dc309ccfc.zip chromium_src-935f2631aeb6bd2fb107a36fac368f7dc309ccfc.tar.gz chromium_src-935f2631aeb6bd2fb107a36fac368f7dc309ccfc.tar.bz2 |
Mojo: Guard lazy NodeController initialization
Threads can race to start using the EDK, so they can race
to the first Core::GetNodeController call. Recently introduced
code which uses the EDK earlier on the main thread would explain
all of the crashing on uninitialized state, as GPU host startup
uses the EDK very early on the IO thread as well.
This guards NodeController init/access with a lock for now.
In the future we should be able to do away with lazy
initialization, but that's a slightly more complex change.
BUG=588095,587807,587826,588376
TBR=amistry@chromium.org
Review URL: https://codereview.chromium.org/1717103002
Cr-Commit-Position: refs/heads/master@{#376617}
Diffstat (limited to 'mojo/edk')
-rw-r--r-- | mojo/edk/system/core.cc | 1 | ||||
-rw-r--r-- | mojo/edk/system/core.h | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/mojo/edk/system/core.cc b/mojo/edk/system/core.cc index 20fa669..11892be 100644 --- a/mojo/edk/system/core.cc +++ b/mojo/edk/system/core.cc @@ -69,6 +69,7 @@ void Core::SetIOTaskRunner(scoped_refptr<base::TaskRunner> io_task_runner) { } NodeController* Core::GetNodeController() { + base::AutoLock lock(node_controller_lock_); if (!node_controller_) node_controller_.reset(new NodeController(this)); return node_controller_.get(); diff --git a/mojo/edk/system/core.h b/mojo/edk/system/core.h index 0e08a8c..938726a 100644 --- a/mojo/edk/system/core.h +++ b/mojo/edk/system/core.h @@ -219,6 +219,16 @@ class MOJO_SYSTEM_IMPL_EXPORT Core { static void PassNodeControllerToIOThread( scoped_ptr<NodeController> node_controller); + // Guards node_controller_. + // + // TODO(rockot): Consider removing this. It's only needed because we + // initialize node_controller_ lazily and that may happen on any thread. + // Otherwise it's effectively const and shouldn't need to be guarded. + // + // We can get rid of lazy initialization if we defer Mojo initialization far + // enough that zygotes don't do it. The zygote can't create a NodeController. + base::Lock node_controller_lock_; + // This is lazily initialized on first access. Always use GetNodeController() // to access it. scoped_ptr<NodeController> node_controller_; |