summaryrefslogtreecommitdiffstats
path: root/mojo
diff options
context:
space:
mode:
authorerg <erg@chromium.org>2015-11-10 15:40:41 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-10 23:42:09 +0000
commitf786c621fe5559d054a793f44ce365e86c6210a8 (patch)
tree28daa91272aa52789bb7ff0fb3658505996a34af /mojo
parentd67d36141e516432d33fc0031e5e3bc5ee1ff756 (diff)
downloadchromium_src-f786c621fe5559d054a793f44ce365e86c6210a8.zip
chromium_src-f786c621fe5559d054a793f44ce365e86c6210a8.tar.gz
chromium_src-f786c621fe5559d054a793f44ce365e86c6210a8.tar.bz2
Revert of mandoline: Fix ICU initialization. (patchset #31 id:570001 of https://codereview.chromium.org/1425853003/ )
Reason for revert: Failures on Chromium Mojo Linux Perf which appears to be because the perf bots don't have an up to date kernel and on Chromium Mojo Android which has some weird crash. Original issue's description: > mandoline: Fix ICU initialization. > > We need to complete the initialization of ICU before we raise the > sandbox. That means we can't pass a file descriptor to the ICU data file > across mojo pipes. Due to how Android handles resources files, we also > can't pass a file descriptor around inside the same process. So pass a > raw pointer to a memory mapped file during the sandbox warm-up phase, > and make a new option to initialize ICU from this raw pointer. > > But that just uncovers a bigger issue: we don't always call what was the > sandbox warming code. If it's general initialization that needs to be > called before we run MojoMain(), we need to include initialization code > in most all main.cc implementations. This bakes a base initialize call > into the mojo application library. > > This fixes a crash in the page cycler set, which happens when a page > tries to do date operations, which fail because of missing locale data. > This should let us raise the sandbox on the page cycler. > > BUG=546644 > > Committed: https://crrev.com/e5735ff0a8ddb61672d964a44ebc8a8ebe2b6242 > Cr-Commit-Position: refs/heads/master@{#358904} TBR=sky@chromium.org,jam@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=546644 Review URL: https://codereview.chromium.org/1429263005 Cr-Commit-Position: refs/heads/master@{#358955}
Diffstat (limited to 'mojo')
-rw-r--r--mojo/application/public/cpp/BUILD.gn2
-rw-r--r--mojo/application/public/cpp/initialize_base_and_icu.cc43
-rw-r--r--mojo/runner/BUILD.gn8
-rw-r--r--mojo/runner/child_process.cc15
-rw-r--r--mojo/runner/context.cc5
-rw-r--r--mojo/runner/in_process_native_runner.cc2
-rw-r--r--mojo/runner/init.cc19
-rw-r--r--mojo/runner/init.h6
8 files changed, 10 insertions, 90 deletions
diff --git a/mojo/application/public/cpp/BUILD.gn b/mojo/application/public/cpp/BUILD.gn
index 578463f..12b0e51 100644
--- a/mojo/application/public/cpp/BUILD.gn
+++ b/mojo/application/public/cpp/BUILD.gn
@@ -26,7 +26,6 @@ source_set("sources") {
"application_impl.h",
"application_runner.h",
"connect.h",
- "initialize_base_and_icu.cc",
"interface_factory.h",
"interface_factory_impl.h",
"lib/app_lifetime_helper.cc",
@@ -45,7 +44,6 @@ source_set("sources") {
deps = [
"//base",
- "//base:i18n",
"//mojo/application/public/interfaces",
"//mojo/common",
"//mojo/environment:chromium",
diff --git a/mojo/application/public/cpp/initialize_base_and_icu.cc b/mojo/application/public/cpp/initialize_base_and_icu.cc
deleted file mode 100644
index dd65129..0000000
--- a/mojo/application/public/cpp/initialize_base_and_icu.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// This file declares a raw symbol and should be included only once in a
-// certain binary target. This needs to be run before we raise the sandbox,
-// which means that it can't use mojo. Our runners will dig around in the
-// symbol table and run this before the mojo system is initialized.
-
-#include "base/files/file.h"
-#include "base/i18n/icu_util.h"
-#include "base/rand_util.h"
-#include "base/sys_info.h"
-#include "mojo/public/c/system/types.h"
-#include "third_party/icu/source/i18n/unicode/timezone.h"
-
-extern "C" {
-#if defined(WIN32)
-__declspec(dllexport) void __cdecl
-#else
-void __attribute__((visibility("default")))
-#endif
-InitializeBase(const uint8* icu_data) {
- base::RandUint64();
- base::SysInfo::AmountOfPhysicalMemory();
- base::SysInfo::NumberOfProcessors();
-#if defined(OS_POSIX) && !defined(OS_MACOSX)
- base::SysInfo::MaxSharedMemorySize();
-#endif
-
- // Initialize core ICU. We must perform the full initialization before we
- // initialize icu::TimeZone subsystem because otherwise ICU gets in a state
- // where the timezone data is disconnected from the locale data which can
- // cause crashes.
- CHECK(base::i18n::InitializeICUFromRawMemory(icu_data));
-
- // ICU DateFormat class (used in base/time_format.cc) needs to get the
- // Olson timezone ID by accessing the zoneinfo files on disk. After
- // TimeZone::createDefault is called once here, the timezone ID is
- // cached and there's no more need to access the file system.
- scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
-}
-}
diff --git a/mojo/runner/BUILD.gn b/mojo/runner/BUILD.gn
index a8cb13e..3c1dec9 100644
--- a/mojo/runner/BUILD.gn
+++ b/mojo/runner/BUILD.gn
@@ -47,10 +47,7 @@ source_set("mojo_runner_lib") {
"register_local_aliases.cc",
"register_local_aliases.h",
]
- deps += [
- "//components/tracing:startup_tracing",
- "//third_party/icu:icudata",
- ]
+ deps += [ "//components/tracing:startup_tracing" ]
} else {
sources += [
"android/context_init.h",
@@ -103,7 +100,6 @@ source_set("init") {
deps = [
":switches",
"//base",
- "//base:i18n",
]
}
@@ -164,8 +160,6 @@ source_set("lib") {
public_deps = [
":init",
":switches",
- ":native_application_support",
- "//mojo/shell",
]
if (!is_component_build) {
diff --git a/mojo/runner/child_process.cc b/mojo/runner/child_process.cc
index ebce4db..33ac3cd 100644
--- a/mojo/runner/child_process.cc
+++ b/mojo/runner/child_process.cc
@@ -9,7 +9,6 @@
#include "base/callback_helpers.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
-#include "base/i18n/icu_util.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/macros.h"
@@ -25,7 +24,6 @@
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/system/core.h"
#include "mojo/runner/child/child_controller.mojom.h"
-#include "mojo/runner/init.h"
#include "mojo/runner/native_application_support.h"
#include "mojo/runner/switches.h"
#include "third_party/mojo/src/mojo/edk/embedder/embedder.h"
@@ -294,17 +292,22 @@ int ChildProcessMain() {
app_library = mojo::runner::LoadNativeApplication(
command_line.GetSwitchValuePath(switches::kChildProcess));
- base::i18n::InitializeICU();
- CallLibraryEarlyInitialization(app_library);
-
#if defined(OS_LINUX) && !defined(OS_ANDROID)
if (command_line.HasSwitch(switches::kEnableSandbox)) {
- // Warm parts of base in the copy of base in the mojo runner.
+ // Warm parts of base.
base::RandUint64();
base::SysInfo::AmountOfPhysicalMemory();
base::SysInfo::MaxSharedMemorySize();
base::SysInfo::NumberOfProcessors();
+ // Do whatever warming that the mojo application wants.
+ typedef void (*SandboxWarmFunction)();
+ SandboxWarmFunction sandbox_warm = reinterpret_cast<SandboxWarmFunction>(
+ base::GetFunctionPointerFromNativeLibrary(app_library,
+ "MojoSandboxWarm"));
+ if (sandbox_warm)
+ sandbox_warm();
+
// TODO(erg,jln): Allowing access to all of /dev/shm/ makes it easy to
// spy on other shared memory using processes. This is a temporary hack
// so that we have some sandbox until we have proper shared memory
diff --git a/mojo/runner/context.cc b/mojo/runner/context.cc
index 355dcbd..87e4157 100644
--- a/mojo/runner/context.cc
+++ b/mojo/runner/context.cc
@@ -9,7 +9,6 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
-#include "base/i18n/icu_util.h"
#include "base/lazy_instance.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
@@ -193,10 +192,6 @@ bool Context::Init() {
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
- // ICU data is a thing every part of the system needs. This here warms
- // up the copy of ICU in the mojo runner.
- base::i18n::InitializeICU();
-
EnsureEmbedderIsInitialized();
task_runners_.reset(
new TaskRunners(base::MessageLoop::current()->task_runner()));
diff --git a/mojo/runner/in_process_native_runner.cc b/mojo/runner/in_process_native_runner.cc
index 8170fe0..b5a8b27 100644
--- a/mojo/runner/in_process_native_runner.cc
+++ b/mojo/runner/in_process_native_runner.cc
@@ -9,7 +9,6 @@
#include "base/location.h"
#include "base/thread_task_runner_handle.h"
#include "base/threading/platform_thread.h"
-#include "mojo/runner/init.h"
#include "mojo/runner/native_application_support.h"
#include "mojo/runner/out_of_process_native_runner.h"
@@ -58,7 +57,6 @@ void InProcessNativeRunner::Run() {
// TODO(vtl): ScopedNativeLibrary doesn't have a .get() method!
base::NativeLibrary app_library = LoadNativeApplication(app_path_);
app_library_.Reset(app_library);
- CallLibraryEarlyInitialization(app_library);
RunNativeApplication(app_library, application_request_.Pass());
app_completed_callback_runner_.Run();
app_completed_callback_runner_.Reset();
diff --git a/mojo/runner/init.cc b/mojo/runner/init.cc
index 133182b..2c7d289 100644
--- a/mojo/runner/init.cc
+++ b/mojo/runner/init.cc
@@ -8,7 +8,6 @@
#include "base/command_line.h"
#include "base/debug/debugger.h"
#include "base/files/file_path.h"
-#include "base/i18n/icu_util.h"
#include "base/logging.h"
#include "base/stl_util.h"
#include "base/strings/string_split.h"
@@ -61,23 +60,5 @@ void WaitForDebuggerIfNecessary() {
}
}
-void CallLibraryEarlyInitialization(base::NativeLibrary app_library) {
- // Do whatever warming that the mojo application wants.
- typedef void (*LibraryEarlyInitFunction)(const uint8*);
- LibraryEarlyInitFunction init_function =
- reinterpret_cast<LibraryEarlyInitFunction>(
- base::GetFunctionPointerFromNativeLibrary(app_library,
- "InitializeBase"));
- if (init_function) {
- // Get the ICU data that we prewarmed in the runner and then pass it to
- // the copy of icu in the mojo binary that we're running.
- const uint8* icu_data = base::i18n::GetRawIcuMemory();
- init_function(icu_data);
- }
-
- // TODO(erg): All chromium binaries load base. We might want to make a
- // general system for other people.
-}
-
} // namespace runner
} // namespace mojo
diff --git a/mojo/runner/init.h b/mojo/runner/init.h
index 879886c..c4e8abd 100644
--- a/mojo/runner/init.h
+++ b/mojo/runner/init.h
@@ -5,8 +5,6 @@
#ifndef MOJO_RUNNER_INIT_H_
#define MOJO_RUNNER_INIT_H_
-#include "base/native_library.h"
-
namespace mojo {
namespace runner {
@@ -15,10 +13,6 @@ void InitializeLogging();
void WaitForDebuggerIfNecessary();
-// Calls "LibraryEarlyInitialization" in |app_library| if it exists. We do
-// common initialization there now.
-void CallLibraryEarlyInitialization(base::NativeLibrary app_library);
-
} // namespace runner
} // namespace mojo