Back out 4e03f2bc5a99 (bug 1114647) for widespread Windows test carnage, a=backout on a CLOSED TREE
authorPhil Ringnalda <philringnalda@gmail.com>
Mon, 06 Jun 2016 20:20:34 -0700
changeset 341605 e70892847544db94d801f80543fe8a7f6d836f90
parent 341604 691f37458b8cd5e51c894bfcf04afe423459aee1
child 341606 3a4cd59e97b5100b2b14185a068271531b80c68d
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1114647
milestone49.0a2
backs out4e03f2bc5a99f4d19785cf04e4f3ed4a22f65aa4
Back out 4e03f2bc5a99 (bug 1114647) for widespread Windows test carnage, a=backout on a CLOSED TREE
browser/app/nsBrowserApp.cpp
ipc/app/moz.build
ipc/contentproc/plugin-container.cpp
ipc/glue/GeckoChildProcessHost.cpp
ipc/glue/GeckoChildProcessHost.h
toolkit/xre/nsAppRunner.cpp
xpcom/build/nsXULAppAPI.h
--- a/browser/app/nsBrowserApp.cpp
+++ b/browser/app/nsBrowserApp.cpp
@@ -25,43 +25,39 @@
 #include <stdarg.h>
 #include <time.h>
 
 #include "nsCOMPtr.h"
 #include "nsIFile.h"
 #include "nsStringGlue.h"
 
 #ifdef XP_WIN
+// we want a wmain entry point
 #ifdef MOZ_ASAN
 // ASAN requires firefox.exe to be built with -MD, and it's OK if we don't
 // support Windows XP SP2 in ASAN builds.
 #define XRE_DONT_SUPPORT_XPSP2
 #endif
 #define XRE_WANT_ENVIRON
+#include "nsWindowsWMain.cpp"
 #if defined(_MSC_VER) && (_MSC_VER < 1900)
 #define snprintf _snprintf
 #endif
 #define strcasecmp _stricmp
 #ifdef MOZ_SANDBOX
 #include "mozilla/sandboxing/SandboxInitialization.h"
 #endif
 #endif
 #include "BinaryPath.h"
 
 #include "nsXPCOMPrivate.h" // for MAXPATHLEN and XPCOM_DLL
 
 #include "mozilla/Telemetry.h"
 #include "mozilla/WindowsDllBlocklist.h"
 
-#if !defined(MOZ_WIDGET_COCOA) && !defined(MOZ_WIDGET_ANDROID) \
-  && !(defined(XP_LINUX) && defined(MOZ_SANDBOX))
-#define MOZ_BROWSER_CAN_BE_CONTENTPROC
-#include "../../ipc/contentproc/plugin-container.cpp"
-#endif
-
 using namespace mozilla;
 
 #ifdef XP_MACOSX
 #define kOSXResourcesFolder "Resources"
 #endif
 #define kDesktopFolder "browser"
 
 static void Output(const char *fmt, ... )
@@ -127,34 +123,26 @@ static bool IsArg(const char* arg, const
 XRE_GetFileFromPathType XRE_GetFileFromPath;
 XRE_CreateAppDataType XRE_CreateAppData;
 XRE_FreeAppDataType XRE_FreeAppData;
 XRE_TelemetryAccumulateType XRE_TelemetryAccumulate;
 XRE_StartupTimelineRecordType XRE_StartupTimelineRecord;
 XRE_mainType XRE_main;
 XRE_StopLateWriteChecksType XRE_StopLateWriteChecks;
 XRE_XPCShellMainType XRE_XPCShellMain;
-XRE_GetProcessTypeType XRE_GetProcessType;
-XRE_SetProcessTypeType XRE_SetProcessType;
-XRE_InitChildProcessType XRE_InitChildProcess;
-XRE_EnableSameExecutableForContentProcType XRE_EnableSameExecutableForContentProc;
 
 static const nsDynamicFunctionLoad kXULFuncs[] = {
     { "XRE_GetFileFromPath", (NSFuncPtr*) &XRE_GetFileFromPath },
     { "XRE_CreateAppData", (NSFuncPtr*) &XRE_CreateAppData },
     { "XRE_FreeAppData", (NSFuncPtr*) &XRE_FreeAppData },
     { "XRE_TelemetryAccumulate", (NSFuncPtr*) &XRE_TelemetryAccumulate },
     { "XRE_StartupTimelineRecord", (NSFuncPtr*) &XRE_StartupTimelineRecord },
     { "XRE_main", (NSFuncPtr*) &XRE_main },
     { "XRE_StopLateWriteChecks", (NSFuncPtr*) &XRE_StopLateWriteChecks },
     { "XRE_XPCShellMain", (NSFuncPtr*) &XRE_XPCShellMain },
-    { "XRE_GetProcessType", (NSFuncPtr*) &XRE_GetProcessType },
-    { "XRE_SetProcessType", (NSFuncPtr*) &XRE_SetProcessType },
-    { "XRE_InitChildProcess", (NSFuncPtr*) &XRE_InitChildProcess },
-    { "XRE_EnableSameExecutableForContentProc", (NSFuncPtr*) &XRE_EnableSameExecutableForContentProc },
     { nullptr, nullptr }
 };
 
 static int do_main(int argc, char* argv[], char* envp[], nsIFile *xreDirectory)
 {
   nsCOMPtr<nsIFile> appini;
   nsresult rv;
   uint32_t mainFlags = 0;
@@ -303,64 +291,35 @@ sizeof(XPCOM_DLL) - 1))
   if (NS_FAILED(rv)) {
     Output("Couldn't load XRE functions.\n");
     return rv;
   }
 
   // This will set this thread as the main thread.
   NS_LogInit();
 
-  if (xreDirectory) {
-    // chop XPCOM_DLL off exePath
-    *lastSlash = '\0';
+  // chop XPCOM_DLL off exePath
+  *lastSlash = '\0';
 #ifdef XP_MACOSX
-    lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]);
-    strcpy(lastSlash + 1, kOSXResourcesFolder);
+  lastSlash = strrchr(exePath, XPCOM_FILE_PATH_SEPARATOR[0]);
+  strcpy(lastSlash + 1, kOSXResourcesFolder);
 #endif
 #ifdef XP_WIN
-    rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(exePath), false,
-                         xreDirectory);
+  rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(exePath), false,
+                       xreDirectory);
 #else
-    rv = NS_NewNativeLocalFile(nsDependentCString(exePath), false,
-                               xreDirectory);
+  rv = NS_NewNativeLocalFile(nsDependentCString(exePath), false,
+                             xreDirectory);
 #endif
-  }
 
   return rv;
 }
 
 int main(int argc, char* argv[], char* envp[])
 {
-#ifdef MOZ_BROWSER_CAN_BE_CONTENTPROC
-  // We are launching as a content process, delegate to the appropriate
-  // main
-  if (argc > 1 && IsArg(argv[1], "contentproc")) {
-#if defined(XP_WIN) && defined(MOZ_SANDBOX)
-    // We need to initialize the sandbox TargetServices before InitXPCOMGlue
-    // because we might need the sandbox broker to give access to some files.
-    if (!sandboxing::GetInitializedTargetServices()) {
-      Output("Failed to initialize the sandbox target services.");
-      return 255;
-    }
-#endif
-
-    nsresult rv = InitXPCOMGlue(argv[0], nullptr);
-    if (NS_FAILED(rv)) {
-      return 255;
-    }
-
-    int result = content_process_main(argc, argv);
-
-    // InitXPCOMGlue calls NS_LogInit, so we need to balance it here.
-    NS_LogTerm();
-
-    return result;
-  }
-#endif
-
   mozilla::TimeStamp start = mozilla::TimeStamp::Now();
 
 #ifdef XP_MACOSX
   TriggerQuirks();
 #endif
 
   int gotCounters;
 #if defined(XP_UNIX)
@@ -415,20 +374,16 @@ int main(int argc, char* argv[], char* e
       XRE_TelemetryAccumulate(mozilla::Telemetry::GLUESTARTUP_HARD_FAULTS,
                               int(newRUsage.ru_majflt - initialRUsage.ru_majflt));
     }
 #else
   #error "Unknown platform"  // having this here keeps cppcheck happy
 #endif
   }
 
-#ifdef MOZ_BROWSER_CAN_BE_CONTENTPROC
-  XRE_EnableSameExecutableForContentProc();
-#endif
-
   int result = do_main(argc, argv, envp, xreDirectory);
 
   NS_LogTerm();
 
 #ifdef XP_MACOSX
   // Allow writes again. While we would like to catch writes from static
   // destructors to allow early exits to use _exit, we know that there is
   // at least one such write that we don't control (see bug 826029). For
--- a/ipc/app/moz.build
+++ b/ipc/app/moz.build
@@ -87,13 +87,8 @@ LDFLAGS += CONFIG['MOZ_ALLOW_HEAP_EXECUT
 if CONFIG['OS_ARCH'] == 'WINNT' and not CONFIG['GNU_CC']:
     LDFLAGS += ['/HEAP:0x40000']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
     OS_LIBS += [
         'binder',
         'utils',
     ]
-
-if CONFIG['GNU_CXX']:
-    CXXFLAGS += ['-Wshadow']
-
-DEFINES['MOZ_PLUGIN_CONTAINER'] = 1;
--- a/ipc/contentproc/plugin-container.cpp
+++ b/ipc/contentproc/plugin-container.cpp
@@ -3,26 +3,28 @@
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsXPCOM.h"
 #include "nsXULAppAPI.h"
 #include "nsAutoPtr.h"
 
+// FIXME/cjones testing
+#if !defined(OS_WIN)
+#include <unistd.h>
+#endif
+
 #ifdef XP_WIN
 #include <windows.h>
 // we want a wmain entry point
 // but we don't want its DLL load protection, because we'll handle it here
 #define XRE_DONT_PROTECT_DLL_LOAD
 #include "nsWindowsWMain.cpp"
 #include "nsSetDllDirectory.h"
-#else
-// FIXME/cjones testing
-#include <unistd.h>
 #endif
 
 #include "GMPLoader.h"
 
 #if defined(XP_WIN) && defined(MOZ_SANDBOX)
 #include "mozilla/sandboxing/SandboxInitialization.h"
 #include "mozilla/sandboxing/sandboxLogging.h"
 #endif
@@ -210,20 +212,20 @@ content_process_main(int argc, char* arg
 #endif
 
 #ifdef XP_WIN
     // For plugins, this is done in PluginProcessChild::Init, as we need to
     // avoid it for unsupported plugins.  See PluginProcessChild::Init for
     // the details.
     if (XRE_GetProcessType() != GeckoProcessType_Plugin) {
         mozilla::SanitizeEnvironmentVariables();
-        SetDllDirectoryW(L"");
+        SetDllDirectory(L"");
     }
 #endif
-#if !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_GONK) && defined(MOZ_PLUGIN_CONTAINER)
+#if !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_GONK)
     // On desktop, the GMPLoader lives in plugin-container, so that its
     // code can be covered by an EME/GMP vendor's voucher.
     nsAutoPtr<mozilla::gmp::SandboxStarter> starter(MakeSandboxStarter());
     if (XRE_GetProcessType() == GeckoProcessType_GMPlugin) {
         childData.gmpLoader = mozilla::gmp::CreateGMPLoader(starter);
     }
 #endif
     nsresult rv = XRE_InitChildProcess(argc, argv, &childData);
--- a/ipc/glue/GeckoChildProcessHost.cpp
+++ b/ipc/glue/GeckoChildProcessHost.cpp
@@ -134,43 +134,26 @@ GeckoChildProcessHost::~GeckoChildProces
 #if defined(MOZ_WIDGET_COCOA)
   if (mChildTask != MACH_PORT_NULL)
     mach_port_deallocate(mach_task_self(), mChildTask);
 #endif
 }
 
 //static
 void
-GeckoChildProcessHost::GetPathToBinary(FilePath& exePath, GeckoProcessType processType)
+GeckoChildProcessHost::GetPathToBinary(FilePath& exePath)
 {
-  if (sRunSelfAsContentProc &&
-      processType == GeckoProcessType_Content) {
-#if defined(OS_WIN)
-    wchar_t exePathBuf[MAXPATHLEN];
-    if (!::GetModuleFileNameW(nullptr, exePathBuf, MAXPATHLEN)) {
-      MOZ_CRASH("GetModuleFileNameW failed (FIXME)");
-    }
-    exePath = FilePath::FromWStringHack(exePathBuf);
-#elif defined(OS_POSIX)
-    exePath = FilePath(CommandLine::ForCurrentProcess()->argv()[0]);
-#else
-#  error Sorry; target OS not supported yet.
-#endif
-    return;
-  }
-
   if (ShouldHaveDirectoryService()) {
     MOZ_ASSERT(gGREBinPath);
 #ifdef OS_WIN
     exePath = FilePath(char16ptr_t(gGREBinPath));
 #elif MOZ_WIDGET_COCOA
     nsCOMPtr<nsIFile> childProcPath;
     NS_NewLocalFile(nsDependentString(gGREBinPath), false,
                     getter_AddRefs(childProcPath));
-
     // We need to use an App Bundle on OS X so that we can hide
     // the dock icon. See Bug 557225.
     childProcPath->AppendNative(NS_LITERAL_CSTRING("plugin-container.app"));
     childProcPath->AppendNative(NS_LITERAL_CSTRING("Contents"));
     childProcPath->AppendNative(NS_LITERAL_CSTRING("MacOS"));
     nsCString tempCPath;
     childProcPath->GetNativePath(tempCPath);
     exePath = FilePath(tempCPath.get());
@@ -271,17 +254,17 @@ uint32_t GeckoChildProcessHost::GetSuppo
 {
 #ifdef MOZ_WIDGET_COCOA
   if (type == GeckoProcessType_Plugin) {
 
     // Cache this, it shouldn't ever change.
     static uint32_t pluginContainerArchs = 0;
     if (pluginContainerArchs == 0) {
       FilePath exePath;
-      GetPathToBinary(exePath, type);
+      GetPathToBinary(exePath);
       nsresult rv = GetArchitecturesForBinary(exePath.value().c_str(), &pluginContainerArchs);
       NS_ASSERTION(NS_SUCCEEDED(rv) && pluginContainerArchs != 0, "Getting architecture of plugin container failed!");
       if (NS_FAILED(rv) || pluginContainerArchs == 0) {
         pluginContainerArchs = base::GetCurrentProcessArchitecture();
       }
     }
     return pluginContainerArchs;
   }
@@ -797,17 +780,17 @@ GeckoChildProcessHost::PerformAsyncLaunc
     interpose.Append(path.get());
     interpose.AppendLiteral("/libplugin_child_interpose.dylib");
     newEnvVars["DYLD_INSERT_LIBRARIES"] = interpose.get();
 # endif  // OS_LINUX
   }
 #endif  // OS_LINUX || OS_MACOSX
 
   FilePath exePath;
-  GetPathToBinary(exePath, mProcessType);
+  GetPathToBinary(exePath);
 
 #ifdef MOZ_WIDGET_ANDROID
   // The java wrapper unpacks this for us but can't make it executable
   chmod(exePath.value().c_str(), 0700);
 #endif  // MOZ_WIDGET_ANDROID
 
 #ifdef ANDROID
   // Remap the Android property workspace to a well-known int,
@@ -840,21 +823,16 @@ GeckoChildProcessHost::PerformAsyncLaunc
 
   // no need for kProcessChannelID, the child process inherits the
   // other end of the socketpair() from us
 
   std::vector<std::string> childArgv;
 
   childArgv.push_back(exePath.value());
 
-  if (sRunSelfAsContentProc &&
-      mProcessType == GeckoProcessType_Content) {
-    childArgv.push_back("-contentproc");
-  }
-
   childArgv.insert(childArgv.end(), aExtraOpts.begin(), aExtraOpts.end());
 
   if (Omnijar::IsInitialized()) {
     // Make sure that child processes can find the omnijar
     // See XRE_InitCommandLine in nsAppRunner.cpp
     nsAutoCString path;
     nsCOMPtr<nsIFile> file = Omnijar::GetPath(Omnijar::GRE);
     if (file && NS_SUCCEEDED(file->GetNativePath(path))) {
@@ -981,25 +959,19 @@ GeckoChildProcessHost::PerformAsyncLaunc
                                      parent_send_port_memory, parent_send_port_memory_ack, false);
 
 #endif
 
 //--------------------------------------------------
 #elif defined(OS_WIN)
 
   FilePath exePath;
-  GetPathToBinary(exePath, mProcessType);
+  GetPathToBinary(exePath);
 
   CommandLine cmdLine(exePath.ToWStringHack());
-
-  if (sRunSelfAsContentProc &&
-      mProcessType == GeckoProcessType_Content) {
-    cmdLine.AppendLooseValue(UTF8ToWide("-contentproc"));
-  }
-
   cmdLine.AppendSwitchWithValue(switches::kProcessChannelID, channel_id());
 
   for (std::vector<std::string>::iterator it = aExtraOpts.begin();
        it != aExtraOpts.end();
        ++it) {
       cmdLine.AppendLooseValue(UTF8ToWide(*it));
   }
 
@@ -1234,18 +1206,16 @@ void
 GeckoChildProcessHost::OnWaitableEventSignaled(base::WaitableEvent *event)
 {
   if (mDelegate) {
     mDelegate->OnWaitableEventSignaled(event);
   }
   ChildProcessHost::OnWaitableEventSignaled(event);
 }
 
-bool GeckoChildProcessHost::sRunSelfAsContentProc(false);
-
 #ifdef MOZ_NUWA_PROCESS
 
 using mozilla::ipc::GeckoExistingProcessHost;
 using mozilla::ipc::FileDescriptor;
 
 GeckoExistingProcessHost::
 GeckoExistingProcessHost(GeckoProcessType aProcessType,
                          base::ProcessHandle aProcess,
--- a/ipc/glue/GeckoChildProcessHost.h
+++ b/ipc/glue/GeckoChildProcessHost.h
@@ -131,18 +131,16 @@ public:
   // This associates an actor telling the process host to stay alive at least
   // until DissociateActor has been called.
   void AssociateActor() { mAssociatedActors++; }
 
   // This gets called when actors get destroyed and will schedule the object
   // for deletion when all actors have cleared their associations.
   void DissociateActor();
 
-  static void EnableSameExecutableForContentProc() { sRunSelfAsContentProc = true; }
-
 protected:
   GeckoProcessType mProcessType;
   ChildPrivileges mPrivileges;
   Monitor mMonitor;
   FilePath mProcessPath;
 
   // This value must be accessed while holding mMonitor.
   enum {
@@ -197,17 +195,17 @@ private:
 
   // Does the actual work for AsyncLaunch, on the IO thread.
   bool PerformAsyncLaunchInternal(std::vector<std::string>& aExtraOpts,
                                   base::ProcessArchitecture arch);
 
   bool RunPerformAsyncLaunch(StringVector aExtraOpts=StringVector(),
                              base::ProcessArchitecture aArch=base::GetCurrentProcessArchitecture());
 
-  static void GetPathToBinary(FilePath& exePath, GeckoProcessType processType);
+  static void GetPathToBinary(FilePath& exePath);
 
   // The buffer is passed to preserve its lifetime until we are done
   // with launching the sub-process.
   void SetChildLogName(const char* varName, const char* origLogName,
                        nsACString &buffer);
 
   // In between launching the subprocess and handing off its IPC
   // channel, there's a small window of time in which *we* might still
@@ -224,18 +222,16 @@ private:
 
   // Remember original env values so we can restore it (there is no other
   // simple way how to change environment of a child process than to modify
   // the current environment).
   nsCString mRestoreOrigNSPRLogName;
   nsCString mRestoreOrigMozLogName;
 
   static uint32_t sNextUniqueID;
-
-  static bool sRunSelfAsContentProc;
 };
 
 #ifdef MOZ_NUWA_PROCESS
 class GeckoExistingProcessHost final : public GeckoChildProcessHost
 {
 public:
   GeckoExistingProcessHost(GeckoProcessType aProcessType,
                            base::ProcessHandle aProcess,
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -6,17 +6,16 @@
 #if defined(MOZ_WIDGET_QT)
 #include <QGuiApplication>
 #include <QStringList>
 #include "nsQAppInstance.h"
 #endif // MOZ_WIDGET_QT
 
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/ContentChild.h"
-#include "mozilla/ipc/GeckoChildProcessHost.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/ChaosMode.h"
 #include "mozilla/IOInterposer.h"
 #include "mozilla/Likely.h"
 #include "mozilla/Poison.h"
 #include "mozilla/Preferences.h"
@@ -4958,13 +4957,8 @@ OverrideDefaultLocaleIfNeeded() {
   if (mozilla::Preferences::GetBool("javascript.use_us_english_locale", false)) {
     // Set the application-wide C-locale. Needed to resist fingerprinting
     // of Date.toLocaleFormat(). We use the locale to "C.UTF-8" if possible,
     // to avoid interfering with non-ASCII keyboard input on some Linux desktops.
     // Otherwise fall back to the "C" locale, which is available on all platforms.
     setlocale(LC_ALL, "C.UTF-8") || setlocale(LC_ALL, "C");
   }
 }
-
-void
-XRE_EnableSameExecutableForContentProc() {
-  mozilla::ipc::GeckoChildProcessHost::EnableSameExecutableForContentProc();
-}
--- a/xpcom/build/nsXULAppAPI.h
+++ b/xpcom/build/nsXULAppAPI.h
@@ -502,19 +502,16 @@ XRE_API(int,
 XRE_API(void,
         XRE_ProcLoaderClientInit, (pid_t, int,
                                    mozilla::Vector<int>& aReservedFds));
 XRE_API(void,
         XRE_ProcLoaderPreload, (const char* aProgramDir,
                                 const nsXREAppData* aAppData));
 #endif // MOZ_B2G_LOADER
 
-XRE_API(void,
-        XRE_EnableSameExecutableForContentProc, ())
-
 XRE_API(int,
         XRE_XPCShellMain, (int argc, char** argv, char** envp,
                            const XREShellData* aShellData))
 
 #if MOZ_WIDGET_GTK == 2
 XRE_API(void,
         XRE_GlibInit, ())
 #endif