summaryrefslogtreecommitdiffstats
path: root/content/app/content_main_runner.cc
diff options
context:
space:
mode:
authorrmcilroy <rmcilroy@chromium.org>2015-02-24 05:33:04 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-24 13:33:46 +0000
commit3fb072718b5ff38aa9c34d8d5160404aa2ad50a5 (patch)
tree238c1b3a81696ee2882c5b4c99c26c31e9f6ed7b /content/app/content_main_runner.cc
parent4d52e5186219fa2161b1c042b49c7052c8e607fd (diff)
downloadchromium_src-3fb072718b5ff38aa9c34d8d5160404aa2ad50a5.zip
chromium_src-3fb072718b5ff38aa9c34d8d5160404aa2ad50a5.tar.gz
chromium_src-3fb072718b5ff38aa9c34d8d5160404aa2ad50a5.tar.bz2
Transfer v8 snapshot files as file descriptors to child processes on Posix.
An update on Chrome could replace the V8 snapshot files with newer version. For zygoted processes this is OK because the zygote will have already mapped the V8 snapshot and thus child processes will use the correct version of the snapshot. However, for processes which don't use the zygote (such as unsandboxed plugin processes) base::LaunchProcess will launch the old version of he Chrome binary (via /proc/self/exe on Linux), but the child will read the new version of the V8 snapshot, thus causing a crash due to a version mismatch. The fix is to load V8 snapshot file in the browser and pass a file descriptor to the child processes (much like Android already did, but for different reasons). This ensures that the child process always sees the correct version of the snapshot file. BUG=457656,461057 Review URL: https://codereview.chromium.org/944913002 Cr-Commit-Position: refs/heads/master@{#317790}
Diffstat (limited to 'content/app/content_main_runner.cc')
-rw-r--r--content/app/content_main_runner.cc57
1 files changed, 31 insertions, 26 deletions
diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc
index 3163a45..8229e3c 100644
--- a/content/app/content_main_runner.cc
+++ b/content/app/content_main_runner.cc
@@ -53,10 +53,6 @@
#include "gin/public/isolate_holder.h"
#endif
-#if defined(OS_ANDROID)
-#include "content/public/common/content_descriptors.h"
-#endif
-
#if defined(USE_TCMALLOC)
#include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h"
#if defined(TYPE_PROFILING)
@@ -98,6 +94,7 @@
#include "content/public/common/content_descriptors.h"
#if !defined(OS_MACOSX)
+#include "content/public/common/content_descriptors.h"
#include "content/public/common/zygote_fork_delegate_linux.h"
#endif
#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
@@ -498,6 +495,10 @@ class ContentMainRunnerImpl : public ContentMainRunner {
}
#endif // !OS_MACOSX && USE_TCMALLOC
+#if !defined(OS_IOS)
+ base::GlobalDescriptors* g_fds = base::GlobalDescriptors::GetInstance();
+#endif
+
// On Android,
// - setlocale() is not supported.
// - We do not override the signal handlers so that we can get
@@ -510,8 +511,6 @@ class ContentMainRunnerImpl : public ContentMainRunner {
setlocale(LC_ALL, "");
SetupSignalHandlers();
-
- base::GlobalDescriptors* g_fds = base::GlobalDescriptors::GetInstance();
g_fds->Set(kPrimaryIPCChannel,
kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor);
#endif // !OS_ANDROID && !OS_IOS
@@ -519,7 +518,8 @@ class ContentMainRunnerImpl : public ContentMainRunner {
#if defined(OS_LINUX) || defined(OS_OPENBSD)
g_fds->Set(kCrashDumpSignal,
kCrashDumpSignal + base::GlobalDescriptors::kBaseDescriptor);
-#endif
+#endif // OS_LINUX || OS_OPENBSD
+
#endif // !OS_WIN
@@ -679,43 +679,48 @@ class ContentMainRunnerImpl : public ContentMainRunner {
RegisterContentSchemes(true);
#if defined(OS_ANDROID)
- int icudata_fd = base::GlobalDescriptors::GetInstance()->MaybeGet(
- kAndroidICUDataDescriptor);
+ int icudata_fd = g_fds->MaybeGet(kAndroidICUDataDescriptor);
if (icudata_fd != -1) {
- auto icudata_region = base::GlobalDescriptors::GetInstance()->GetRegion(
- kAndroidICUDataDescriptor);
+ auto icudata_region = g_fds->GetRegion(kAndroidICUDataDescriptor);
CHECK(base::i18n::InitializeICUWithFileDescriptor(icudata_fd,
icudata_region));
} else {
CHECK(base::i18n::InitializeICU());
}
+#else
+ CHECK(base::i18n::InitializeICU());
+#endif // OS_ANDROID
#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
- int v8_natives_fd = base::GlobalDescriptors::GetInstance()->MaybeGet(
- kV8NativesDataDescriptor);
- int v8_snapshot_fd = base::GlobalDescriptors::GetInstance()->MaybeGet(
- kV8SnapshotDataDescriptor);
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
+#if !defined(OS_ANDROID)
+ // kV8NativesDataDescriptor and kV8SnapshotDataDescriptor are shared with
+ // child processes. On Android they are set in
+ // ChildProcessService::InternalInitChildProcess, otherwise set them here.
+ if (!process_type.empty() && process_type != switches::kZygoteProcess) {
+ g_fds->Set(
+ kV8NativesDataDescriptor,
+ kV8NativesDataDescriptor + base::GlobalDescriptors::kBaseDescriptor);
+ g_fds->Set(
+ kV8SnapshotDataDescriptor,
+ kV8SnapshotDataDescriptor + base::GlobalDescriptors::kBaseDescriptor);
+ }
+#endif // !OS_ANDROID
+ int v8_natives_fd = g_fds->MaybeGet(kV8NativesDataDescriptor);
+ int v8_snapshot_fd = g_fds->MaybeGet(kV8SnapshotDataDescriptor);
if (v8_natives_fd != -1 && v8_snapshot_fd != -1) {
- auto v8_natives_region =
- base::GlobalDescriptors::GetInstance()->GetRegion(
- kV8NativesDataDescriptor);
- auto v8_snapshot_region =
- base::GlobalDescriptors::GetInstance()->GetRegion(
- kV8SnapshotDataDescriptor);
+ auto v8_natives_region = g_fds->GetRegion(kV8NativesDataDescriptor);
+ auto v8_snapshot_region = g_fds->GetRegion(kV8SnapshotDataDescriptor);
CHECK(gin::IsolateHolder::LoadV8SnapshotFd(
v8_natives_fd, v8_natives_region.offset, v8_natives_region.size,
v8_snapshot_fd, v8_snapshot_region.offset, v8_snapshot_region.size));
} else {
CHECK(gin::IsolateHolder::LoadV8Snapshot());
}
-#endif // V8_USE_EXTERNAL_STARTUP_DATA
-
#else
- CHECK(base::i18n::InitializeICU());
-#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
CHECK(gin::IsolateHolder::LoadV8Snapshot());
+#endif // OS_POSIX && !OS_MACOSX
#endif // V8_USE_EXTERNAL_STARTUP_DATA
-#endif // OS_ANDROID
if (delegate_)
delegate_->PreSandboxStartup();