Commit b695e836 authored by Gabriele Svelto's avatar Gabriele Svelto
Browse files

Bug 1872920 - Change how we notify the main process when we intercept a crash via WER a=diannaS

This patch makes several fundamental changes to the logic we use to inform
the main process whenever the WER runtime exception module intercepts a child
process crash:

* We no longer read the process type or any other data from the child process;
  the process type is passed as the runtime exception module's context
* We no longer read the address of the memory area used to communicate with the
  main process from the child process arguments. Instead we allocate memory
  directly into the main process and store the required information there
* We don't read anything from the main process either, the pointer to the
  function used to notify the main process is now found by looking out its
  dedicated section in the parent process' xul.dll mapping
* We no longer read the OOM crash annotation from a child process, this
  functionality will be restored by making the module use the mozannotation
  crates to fetch all the annotations

Original Revision: https://phabricator.services.mozilla.com/D201589

Differential Revision: https://phabricator.services.mozilla.com/D202916
parent bce95d65
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3454,6 +3454,7 @@ version = "0.1.0"
dependencies = [
 "libc",
 "mozilla-central-workspace-hack",
 "process_reader",
 "rust-ini",
 "serde",
 "serde_json",
+1 −10
Original line number Diff line number Diff line
@@ -263,8 +263,7 @@ class WindowsProcessLauncher : public BaseProcessLauncher {
  WindowsProcessLauncher(GeckoChildProcessHost* aHost,
                         std::vector<std::string>&& aExtraOpts)
      : BaseProcessLauncher(aHost, std::move(aExtraOpts)),
        mCachedNtdllThunk(GetCachedNtDllThunk()),
        mWerDataPointer(&(aHost->mWerData)) {}
        mCachedNtdllThunk(GetCachedNtDllThunk()) {}

 protected:
  bool SetChannel(IPC::Channel*) override { return true; }
@@ -276,7 +275,6 @@ class WindowsProcessLauncher : public BaseProcessLauncher {
  bool mUseSandbox = false;

  const Buffer<IMAGE_THUNK_DATA>* mCachedNtdllThunk;
  CrashReporter::WindowsErrorReportingData const* mWerDataPointer;
};
typedef WindowsProcessLauncher ProcessLauncher;
#endif  // XP_WIN
@@ -399,9 +397,6 @@ GeckoChildProcessHost::GeckoChildProcessHost(GeckoProcessType aProcessType,
      mProcessState(CREATING_CHANNEL),
#ifdef XP_WIN
      mGroupId(u"-"),
      mWerData{.mWerNotifyProc = CrashReporter::WerNotifyProc,
               .mChildPid = 0,
               .mMinidumpFile = {}},
#endif
#if defined(MOZ_SANDBOX) && defined(XP_WIN)
      mEnableSandboxLogging(false),
@@ -1587,10 +1582,6 @@ Result<Ok, LaunchError> WindowsProcessLauncher::DoSetup() {
    mLaunchOptions->handles_to_inherit.push_back(reinterpret_cast<HANDLE>(h));
    std::string hStr = std::to_string(h);
    mCmdLine->AppendLooseValue(UTF8ToWide(hStr));

    char werDataAddress[17] = {};
    SprintfLiteral(werDataAddress, "%p", mWerDataPointer);
    mCmdLine->AppendLooseValue(UTF8ToWide(werDataAddress));
  }

  // Process type
+0 −1
Original line number Diff line number Diff line
@@ -258,7 +258,6 @@ class GeckoChildProcessHost : public ChildProcessHost,
#ifdef XP_WIN
  void InitWindowsGroupID();
  nsString mGroupId;
  CrashReporter::WindowsErrorReportingData mWerData;
#  ifdef MOZ_SANDBOX
  RefPtr<AbstractSandboxBroker> mSandboxBroker;
  std::vector<std::wstring> mAllowedFilesRead;
+5 −13
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@
#  include <werapi.h>  // For WerRegisterRuntimeExceptionModule()
#  include <stdlib.h>

#  include "mozilla/mozalloc_oom.h"
#  include "mozilla/Unused.h"

using mozilla::Unused;
@@ -31,12 +30,6 @@ namespace CrashReporter {

#ifdef XP_WIN

struct InProcessWindowsErrorReportingData {
  uint32_t mProcessType;
  size_t* mOOMAllocationSizePtr;
};

static InProcessWindowsErrorReportingData gInProcessWerData;
const static size_t kModulePathLength = MAX_PATH + 1;
static wchar_t sModulePath[kModulePathLength];

@@ -86,10 +79,9 @@ void RegisterRuntimeExceptionModule() {
    return;
  }

  gInProcessWerData.mProcessType = mozilla::GetGeckoProcessType();
  gInProcessWerData.mOOMAllocationSizePtr = &gOOMAllocationSize;
  if (FAILED(::WerRegisterRuntimeExceptionModule(sModulePath,
                                                 &gInProcessWerData))) {
  if (FAILED(::WerRegisterRuntimeExceptionModule(
          sModulePath,
          reinterpret_cast<PVOID>(mozilla::GetGeckoProcessType())))) {
    // The registration failed null out sModulePath to record this.
    *sModulePath = L'\0';
    return;
@@ -101,8 +93,8 @@ void UnregisterRuntimeExceptionModule() {
#ifdef XP_WIN
  // If sModulePath is set then we have registered the module.
  if (*sModulePath) {
    Unused << ::WerUnregisterRuntimeExceptionModule(sModulePath,
                                                    &gInProcessWerData);
    Unused << ::WerUnregisterRuntimeExceptionModule(
        sModulePath, reinterpret_cast<PVOID>(mozilla::GetGeckoProcessType()));
    *sModulePath = L'\0';
  }
#endif  // XP_WIN
+1 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ license = "MPL-2.0"
[dependencies]
libc = "0.2.0"
mozilla-central-workspace-hack = { path = "../../../build/workspace-hack" }
process_reader = { path = "../process_reader/" }
rust-ini = "0.10"
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0" }
Loading