author | arthur.iakab <aiakab@mozilla.com> |
Fri, 24 Nov 2017 12:00:30 +0200 | |
changeset 393559 | f2e36fbb90fad27c034105709a4cbbaef9bd58c8 |
parent 393558 | e91a098e6e994a1f3f33fdb71f7c4b633955776a (current diff) |
parent 393517 | c6f9187b0b2e9c42f5eeca898bf81640174573fe (diff) |
child 393560 | f9b391e62608afe47cb5d9269a4afee6472bb1d4 |
child 393570 | c15f17881cd5dec9d58c84551e9d0bfd2d1f4820 |
child 393584 | a6983de1f1547a6d4e45a61ef0da780a9847d37e |
push id | 97673 |
push user | aiakab@mozilla.com |
push date | Fri, 24 Nov 2017 10:08:32 +0000 |
treeherder | mozilla-inbound@f9b391e62608 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | merge, merge |
milestone | 59.0a1 |
first release with | nightly linux32
f2e36fbb90fa
/
59.0a1
/
20171124100500
/
files
nightly linux64
f2e36fbb90fa
/
59.0a1
/
20171124100500
/
files
nightly mac
f2e36fbb90fa
/
59.0a1
/
20171124100500
/
files
nightly win32
f2e36fbb90fa
/
59.0a1
/
20171124100500
/
files
nightly win64
f2e36fbb90fa
/
59.0a1
/
20171124100500
/
files
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
releases | nightly linux32
59.0a1
/
20171124100500
/
pushlog to previous
nightly linux64
59.0a1
/
20171124100500
/
pushlog to previous
nightly mac
59.0a1
/
20171124100500
/
pushlog to previous
nightly win32
59.0a1
/
20171124100500
/
pushlog to previous
nightly win64
59.0a1
/
20171124100500
/
pushlog to previous
|
--- a/accessible/base/nsAccessibilityService.cpp +++ b/accessible/base/nsAccessibilityService.cpp @@ -48,20 +48,17 @@ #include "HTMLWin32ObjectAccessible.h" #include "mozilla/StaticPtr.h" #endif #ifdef A11Y_LOG #include "Logging.h" #endif -#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" -#endif - #include "nsImageFrame.h" #include "nsINamed.h" #include "nsIObserverService.h" #include "nsLayoutUtils.h" #include "nsPluginFrame.h" #include "SVGGeometryFrame.h" #include "nsTreeBodyFrame.h" #include "nsTreeColumns.h" @@ -1369,21 +1366,19 @@ nsAccessibilityService::Init() #else gApplicationAccessible = new ApplicationAccessible(); #endif // defined(XP_WIN) } NS_ADDREF(gApplicationAccessible); // will release in Shutdown() gApplicationAccessible->Init(); -#ifdef MOZ_CRASHREPORTER CrashReporter:: AnnotateCrashReport(NS_LITERAL_CSTRING("Accessibility"), NS_LITERAL_CSTRING("Active")); -#endif #ifdef XP_WIN sPendingPlugins = new nsTArray<nsCOMPtr<nsIContent> >; sPluginTimers = new nsTArray<nsCOMPtr<nsITimer> >; #endif // Now its safe to start platform accessibility. if (XRE_IsParentProcess())
--- a/accessible/windows/msaa/Compatibility.cpp +++ b/accessible/windows/msaa/Compatibility.cpp @@ -2,20 +2,18 @@ /* vim: set ts=2 et sw=2 tw=80: */ /* 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 "Compatibility.h" #include "mozilla/WindowsVersion.h" -#if defined(MOZ_CRASHREPORTER) #include "nsExceptionHandler.h" #include "nsPrintfCString.h" -#endif // defined(MOZ_CRASHREPORTER) #include "nsUnicharUtils.h" #include "nsWindowsDllInterceptor.h" #include "nsWinUtils.h" #include "Statistics.h" #include "mozilla/Preferences.h" #include <shlobj.h> @@ -214,21 +212,19 @@ Compatibility::HasKnownNonUiaConsumer() } void Compatibility::Init() { // Note we collect some AT statistics/telemetry here for convenience. InitConsumers(); -#ifdef MOZ_CRASHREPORTER CrashReporter:: AnnotateCrashReport(NS_LITERAL_CSTRING("AccessibilityInProcClient"), nsPrintfCString("0x%X", sConsumers)); -#endif // Gather telemetry uint32_t temp = sConsumers; for (int i = 0; temp; i++) { if (temp & 0x1) statistics::A11yConsumers(i); temp >>= 1; @@ -406,23 +402,21 @@ UseIAccessibleProxyStub() return false; } // Otherwise we try the proxy/stub if (IsIAccessiblePSRegistered()) { return true; } -#if defined(MOZ_CRASHREPORTER) // If we reach this point then something is seriously wrong with the // IAccessible configuration in the computer's registry. Let's annotate this // so that we can easily determine this condition during crash analysis. CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IAccessibleConfig"), NS_LITERAL_CSTRING("NoSystemTypeLibOrPS")); -#endif // defined(MOZ_CRASHREPORTER) return false; } #endif // !defined(HAVE_64BIT_BUILD) uint16_t Compatibility::GetActCtxResourceId() {
--- a/accessible/windows/msaa/LazyInstantiator.cpp +++ b/accessible/windows/msaa/LazyInstantiator.cpp @@ -12,29 +12,26 @@ #include "mozilla/a11y/Platform.h" #include "mozilla/Assertions.h" #include "mozilla/mscom/MainThreadRuntime.h" #include "mozilla/mscom/Registration.h" #include "mozilla/UniquePtr.h" #include "nsAccessibilityService.h" #include "nsWindowsHelpers.h" #include "nsCOMPtr.h" +#include "nsExceptionHandler.h" #include "nsIFile.h" #include "nsXPCOM.h" #include "RootAccessibleWrap.h" #include "WinUtils.h" #if defined(MOZ_TELEMETRY_REPORTING) #include "mozilla/Telemetry.h" #endif // defined(MOZ_TELEMETRY_REPORTING) -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - #include <oaidl.h> #if !defined(STATE_SYSTEM_NORMAL) #define STATE_SYSTEM_NORMAL (0) #endif // !defined(STATE_SYSTEM_NORMAL) /** * Because our wrapped accessible is cycle-collected, we can't safely AddRef() @@ -300,35 +297,35 @@ LazyInstantiator::ShouldInstantiate(cons // Store full path to executable for support purposes. nsAutoString filePath; nsresult rv = clientExe->GetPath(filePath); if (NS_SUCCEEDED(rv)) { a11y::SetInstantiator(filePath); } -#if defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) +#if defined(MOZ_TELEMETRY_REPORTING) if (!mTelemetryThread) { // Call GatherTelemetry on a background thread because it does I/O on // the executable file to retrieve version information. nsCOMPtr<nsIRunnable> runnable( NewRunnableMethod<nsCOMPtr<nsIFile>, RefPtr<AccumulateRunnable>>( "LazyInstantiator::GatherTelemetry", this, &LazyInstantiator::GatherTelemetry, clientExe, new AccumulateRunnable(this))); NS_NewThread(getter_AddRefs(mTelemetryThread), runnable); } -#endif // defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) +#endif // defined(MOZ_TELEMETRY_REPORTING) return true; } -#if defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) +#if defined(MOZ_TELEMETRY_REPORTING) /** * Appends version information in the format "|a.b.c.d". * If there is no version information, we append nothing. */ void LazyInstantiator::AppendVersionInfo(nsIFile* aClientExe, nsAString& aStrToAppend) { @@ -401,29 +398,27 @@ LazyInstantiator::AccumulateTelemetry(co { MOZ_ASSERT(NS_IsMainThread()); if (!aValue.IsEmpty()) { #if defined(MOZ_TELEMETRY_REPORTING) Telemetry::ScalarSet(Telemetry::ScalarID::A11Y_INSTANTIATORS, aValue); #endif // defined(MOZ_TELEMETRY_REPORTING) -#if defined(MOZ_CRASHREPORTER) CrashReporter:: AnnotateCrashReport(NS_LITERAL_CSTRING("AccessibilityClient"), NS_ConvertUTF16toUTF8(aValue)); -#endif // defined(MOZ_CRASHREPORTER) } if (mTelemetryThread) { mTelemetryThread->Shutdown(); mTelemetryThread = nullptr; } } -#endif // defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) +#endif // defined(MOZ_TELEMETRY_REPORTING) RootAccessibleWrap* LazyInstantiator::ResolveRootAccWrap() { Accessible* acc = widget::WinUtils::GetRootAccessibleForHWND(mHwnd); if (!acc || !acc->IsRoot()) { return nullptr; }
--- a/accessible/windows/msaa/LazyInstantiator.h +++ b/accessible/windows/msaa/LazyInstantiator.h @@ -82,17 +82,17 @@ public: private: explicit LazyInstantiator(HWND aHwnd); ~LazyInstantiator(); bool IsBlockedInjection(); bool ShouldInstantiate(const DWORD aClientTid); bool GetClientExecutableName(const DWORD aClientTid, nsIFile** aOutClientExe); -#if defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) +#if defined(MOZ_TELEMETRY_REPORTING) class AccumulateRunnable final : public Runnable { public: explicit AccumulateRunnable(LazyInstantiator* aObj) : Runnable("mozilla::a11y::LazyInstantiator::AccumulateRunnable") , mObj(aObj) { MOZ_ASSERT(NS_IsMainThread()); @@ -115,17 +115,17 @@ private: nsString mData; }; friend class AccumulateRunnable; void AppendVersionInfo(nsIFile* aClientExe, nsAString& aStrToAppend); void GatherTelemetry(nsIFile* aClientExe, AccumulateRunnable* aRunnable); void AccumulateTelemetry(const nsString& aValue); -#endif // defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) +#endif // defined(MOZ_TELEMETRY_REPORTING) /** * @return S_OK if we have a valid mRealRoot to invoke methods on */ HRESULT MaybeResolveRoot(); /** * @return S_OK if we have a valid mWeakDispatch to invoke methods on @@ -147,18 +147,18 @@ private: * are interfaces that come from objects that we aggregate. Aggregated object * interfaces share refcount methods with ours, so if we were to hold strong * references to them, we would be holding strong references to ourselves, * creating a cycle. */ RootAccessibleWrap* mWeakRootAccWrap; IAccessible* mWeakAccessible; IDispatch* mWeakDispatch; -#if defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) +#if defined(MOZ_TELEMETRY_REPORTING) nsCOMPtr<nsIThread> mTelemetryThread; -#endif // defined(MOZ_TELEMETRY_REPORTING) || defined(MOZ_CRASHREPORTER) +#endif // defined(MOZ_TELEMETRY_REPORTING) }; } // namespace a11y } // namespace mozilla #endif // mozilla_a11y_LazyInstantiator_h
--- a/browser/base/content/test/general/browser_restore_isAppTab.js +++ b/browser/base/content/test/general/browser_restore_isAppTab.js @@ -81,18 +81,19 @@ add_task(async function navigate() { loadFrameScript(browser); isAppTab = await isBrowserAppTab(browser); ok(isAppTab, "Docshell should think it is an app tab"); gBrowser.removeCurrentTab(); }); add_task(async function crash() { - if (!gMultiProcessBrowser || !("nsICrashReporter" in Ci)) + if (!gMultiProcessBrowser || !AppConstants.MOZ_CRASHREPORTER) { return; + } let tab = BrowserTestUtils.addTab(gBrowser, DUMMY); let browser = tab.linkedBrowser; gBrowser.selectedTab = tab; await BrowserTestUtils.browserStopped(gBrowser); loadFrameScript(browser); let isAppTab = await isBrowserAppTab(browser); ok(!isAppTab, "Docshell shouldn't think it is an app tab");
--- a/devtools/client/inspector/rules/models/element-style.js +++ b/devtools/client/inspector/rules/models/element-style.js @@ -383,30 +383,30 @@ UserProperties.prototype = { return value; }, /** * Set a named property for a given CSSStyleDeclaration. * * @param {CSSStyleDeclaration} style * The CSSStyleDeclaration against which the property is to be mapped. - * @param {String} bame + * @param {String} name * The name of the property to set. * @param {String} userValue * The value of the property to set. */ - setProperty: function (style, bame, userValue) { - let key = this.getKey(style, bame); + setProperty: function (style, name, userValue) { + let key = this.getKey(style, name); let entry = this.map.get(key, null); if (entry) { - entry[bame] = userValue; + entry[name] = userValue; } else { let props = {}; - props[bame] = userValue; + props[name] = userValue; this.map.set(key, props); } }, /** * Check whether a named property for a given CSSStyleDeclaration is stored. * * @param {CSSStyleDeclaration} style
--- a/devtools/client/inspector/rules/models/rule.js +++ b/devtools/client/inspector/rules/models/rule.js @@ -4,18 +4,17 @@ * 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/. */ "use strict"; const promise = require("promise"); const CssLogic = require("devtools/shared/inspector/css-logic"); const {ELEMENT_STYLE} = require("devtools/shared/specs/styles"); -const {TextProperty} = - require("devtools/client/inspector/rules/models/text-property"); +const TextProperty = require("devtools/client/inspector/rules/models/text-property"); const {promiseWarn} = require("devtools/client/inspector/shared/utils"); const {parseNamedDeclarations} = require("devtools/shared/css/parsing-utils"); const Services = require("Services"); const STYLE_INSPECTOR_PROPERTIES = "devtools/shared/locales/styleinspector.properties"; const {LocalizationHelper} = require("devtools/shared/l10n"); const STYLE_INSPECTOR_L10N = new LocalizationHelper(STYLE_INSPECTOR_PROPERTIES);
--- a/devtools/client/inspector/rules/models/text-property.js +++ b/devtools/client/inspector/rules/models/text-property.js @@ -207,9 +207,9 @@ TextProperty.prototype = { if (!this.rule.domRule.declarations[selfIndex]) { return true; } return this.rule.domRule.declarations[selfIndex].isValid; } }; -exports.TextProperty = TextProperty; +module.exports = TextProperty;
--- a/devtools/client/inspector/rules/views/rule-editor.js +++ b/devtools/client/inspector/rules/views/rule-editor.js @@ -2,20 +2,23 @@ * 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/. */ "use strict"; const {l10n} = require("devtools/shared/inspector/css-logic"); const {ELEMENT_STYLE} = require("devtools/shared/specs/styles"); const Rule = require("devtools/client/inspector/rules/models/rule"); -const {InplaceEditor, editableField, editableItem} = - require("devtools/client/shared/inplace-editor"); -const {TextPropertyEditor} = - require("devtools/client/inspector/rules/views/text-property-editor"); +const { + InplaceEditor, + editableField, + editableItem +} = require("devtools/client/shared/inplace-editor"); +const TextPropertyEditor = + require("devtools/client/inspector/rules/views/text-property-editor"); const { createChild, blurOnMultipleProperties, promiseWarn } = require("devtools/client/inspector/shared/utils"); const { parseNamedDeclarations, parsePseudoClassesAndAttributes,
--- a/devtools/client/inspector/rules/views/text-property-editor.js +++ b/devtools/client/inspector/rules/views/text-property-editor.js @@ -1035,9 +1035,9 @@ TextPropertyEditor.prototype = { highlighters.shapesHighlighterShown) { return; } node.classList.toggle("active", active); }, }; -exports.TextPropertyEditor = TextPropertyEditor; +module.exports = TextPropertyEditor;
--- a/devtools/server/tests/mochitest/chrome.ini +++ b/devtools/server/tests/mochitest/chrome.ini @@ -102,9 +102,9 @@ support-files = [test_styles-svg.html] [test_unsafeDereference.html] [test_webconsole-node-grip.html] [test_webextension-addon-debugging-connect.html] skip-if = !e10s # test is designed to work on e10s only [test_webextension-addon-debugging-reload.html] skip-if = !e10s # test is designed to work on e10s only [test_websocket-server.html] -skip-if = false +skip-if = os == 'mac' # bug 1294873 intermittent leaks
--- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -2419,22 +2419,20 @@ nsDocShell::GetUseRemoteTabs(bool* aUseR *aUseRemoteTabs = mUseRemoteTabs; return NS_OK; } NS_IMETHODIMP nsDocShell::SetRemoteTabs(bool aUseRemoteTabs) { -#ifdef MOZ_CRASHREPORTER if (aUseRemoteTabs) { CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("DOMIPCEnabled"), NS_LITERAL_CSTRING("1")); } -#endif mUseRemoteTabs = aUseRemoteTabs; return NS_OK; } NS_IMETHODIMP nsDocShell::SetAffectPrivateSessionLifetime(bool aAffectLifetime) {
--- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -7924,17 +7924,17 @@ StyleDataTypesWithNode(nsINode* aNode) static void CheckCrossStyleBackendAdoption(nsIDocument* aOldDoc, nsIDocument* aNewDoc, nsINode* aAdoptedNode) { EnumSet<StyleDataType> styleDataTypes = StyleDataTypesWithNode(aAdoptedNode); if (styleDataTypes.isEmpty()) { return; } -#ifdef MOZ_CRASHREPORTER + // We are adopting node with pre-existing style data across style // backend. We want some more information to help diagnose when that // can happen. nsAutoCString note; nsIDocument* geckoDoc; if (aOldDoc->GetStyleBackendType() == StyleBackendType::Servo) { note.AppendLiteral("Servo -> Gecko"); geckoDoc = aNewDoc; @@ -7989,17 +7989,17 @@ CheckCrossStyleBackendAdoption(nsIDocume nsAutoCString scheme; geckoURI->GetScheme(scheme); note.Append(scheme); note.AppendLiteral(": (omitted)"); } } note.Append('\n'); CrashReporter::AppendAppNotesToCrashReport(note); -#endif // MOZ_CRASHREPORTER + MOZ_CRASH("Must not adopt a node with pre-existing style data " "into a document with different style backend"); } nsINode* nsIDocument::AdoptNode(nsINode& aAdoptedNode, ErrorResult& rv) { nsINode* adoptedNode = &aAdoptedNode;
--- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -209,33 +209,31 @@ #include "ClearOnShutdown.h" #include "ProcessUtils.h" #include "URIUtils.h" #include "nsContentUtils.h" #include "nsIPrincipal.h" #include "DomainPolicy.h" #include "mozilla/dom/ipc/StructuredCloneData.h" #include "mozilla/dom/time/DateCacheCleaner.h" +#include "mozilla/ipc/CrashReporterClient.h" #include "mozilla/net/NeckoMessageUtils.h" #include "mozilla/widget/PuppetBidiKeyboard.h" #include "mozilla/RemoteSpellCheckEngineChild.h" #include "GMPServiceChild.h" #include "GfxInfoBase.h" #include "gfxPlatform.h" #include "nscore.h" // for NS_FREE_PERMANENT_DATA #include "VRManagerChild.h" #include "private/pprio.h" #include "nsString.h" #ifdef MOZ_WIDGET_GTK #include "nsAppRunner.h" #endif -#ifdef MOZ_CRASHREPORTER -#include "mozilla/ipc/CrashReporterClient.h" -#endif #ifdef MOZ_CODE_COVERAGE #include "mozilla/CodeCoverageHandler.h" #endif using namespace mozilla; using namespace mozilla::docshell; using namespace mozilla::dom::ipc; @@ -644,19 +642,17 @@ ContentChild::Init(MessageLoop* aIOLoop, if (!gfxPlatform::IsHeadless()) { // Send the parent our X socket to act as a proxy reference for our X // resources. int xSocketFd = ConnectionNumber(DefaultXDisplay()); SendBackUpXResources(FileDescriptor(xSocketFd)); } #endif -#ifdef MOZ_CRASHREPORTER CrashReporterClient::InitSingleton(this); -#endif mID = aChildID; mIsForBrowser = aIsForBrowser; #ifdef NS_PRINTING // Force the creation of the nsPrintingProxy so that it's IPC counterpart, // PrintingParent, is always available for printing initiated from the parent. RefPtr<nsPrintingProxy> printingProxy = nsPrintingProxy::GetInstance(); @@ -1696,30 +1692,28 @@ ContentChild::RecvSetProcessSandbox(cons syscallWhitelist); } #elif defined(XP_WIN) mozilla::SandboxTarget::Instance()->StartSandbox(); #elif defined(XP_MACOSX) sandboxEnabled = StartMacOSContentSandbox(); #endif -#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("ContentSandboxEnabled"), sandboxEnabled? NS_LITERAL_CSTRING("1") : NS_LITERAL_CSTRING("0")); #if defined(XP_LINUX) && !defined(OS_ANDROID) nsAutoCString flagsString; flagsString.AppendInt(SandboxInfo::Get().AsInteger()); CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("ContentSandboxCapabilities"), flagsString); #endif /* XP_LINUX && !OS_ANDROID */ CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("RemoteType"), NS_ConvertUTF16toUTF8(GetRemoteType())); -#endif /* MOZ_CRASHREPORTER */ #endif /* MOZ_CONTENT_SANDBOX */ return IPC_OK(); } mozilla::ipc::IPCResult ContentChild::RecvBidiKeyboardNotify(const bool& aIsLangRTL, const bool& aHaveBidiKeyboards) @@ -2344,19 +2338,18 @@ ContentChild::ActorDestroy(ActorDestroyR nsCOMPtr<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID)); if (svc) { svc->UnregisterListener(mConsoleListener); mConsoleListener->mChild = nullptr; } mIsAlive = false; -# ifdef MOZ_CRASHREPORTER CrashReporterClient::DestroySingleton(); -# endif + XRE_ShutdownChildProcess(); #endif // NS_FREE_PERMANENT_DATA } void ContentChild::ProcessingError(Result aCode, const char* aReason) { switch (aCode) { @@ -2371,20 +2364,19 @@ ContentChild::ProcessingError(Result aCo case MsgRouteError: case MsgValueError: break; default: MOZ_CRASH("not reached"); } -#if defined(MOZ_CRASHREPORTER) nsDependentCString reason(aReason); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ipc_channel_error"), reason); -#endif + MOZ_CRASH("Content child abort due to IPC error"); } nsresult ContentChild::AddRemoteAlertObserver(const nsString& aData, nsIObserver* aObserver) { NS_ASSERTION(aObserver, "Adding a null observer?"); @@ -2955,20 +2947,19 @@ ContentChild::ForceKillTimerCallback(nsI mozilla::ipc::IPCResult ContentChild::RecvShutdown() { // If we receive the shutdown message from within a nested event loop, we want // to wait for that event loop to finish. Otherwise we could prematurely // terminate an "unload" or "pagehide" event handler (which might be doing a // sync XHR, for example). -#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCShutdownState"), NS_LITERAL_CSTRING("RecvShutdown")); -#endif + MOZ_ASSERT(NS_IsMainThread()); RefPtr<nsThread> mainThread = nsThreadManager::get().GetCurrentThread(); // Note that we only have to check the recursion count for the current // cooperative thread. Since the Shutdown message is not labeled with a // SchedulerGroup, there can be no other cooperative threads doing work while // we're running. if (mainThread && mainThread->RecursionDepth() > 1) { // We're in a nested event loop. Let's delay for an arbitrary period of @@ -3014,28 +3005,23 @@ ContentChild::RecvShutdown() } #endif // Start a timer that will insure we quickly exit after a reasonable // period of time. Prevents shutdown hangs after our connection to the // parent closes. StartForceKillTimer(); -#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCShutdownState"), NS_LITERAL_CSTRING("SendFinishShutdown (sending)")); bool sent = SendFinishShutdown(); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCShutdownState"), sent ? NS_LITERAL_CSTRING("SendFinishShutdown (sent)") : NS_LITERAL_CSTRING("SendFinishShutdown (failed)")); -#else - // Ignore errors here. If this fails, the parent will kill us after a - // timeout. - Unused << SendFinishShutdown(); -#endif + return IPC_OK(); } PBrowserOrId ContentChild::GetBrowserOrId(TabChild* aTabChild) { if (!aTabChild || this == aTabChild->Manager()) {
--- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -62,16 +62,17 @@ #include "mozilla/dom/URLClassifierParent.h" #include "mozilla/embedding/printingui/PrintingParent.h" #include "mozilla/extensions/StreamFilterParent.h" #include "mozilla/gfx/gfxVars.h" #include "mozilla/gfx/GPUProcessManager.h" #include "mozilla/hal_sandbox/PHalParent.h" #include "mozilla/ipc/BackgroundChild.h" #include "mozilla/ipc/BackgroundParent.h" +#include "mozilla/ipc/CrashReporterHost.h" #include "mozilla/ipc/FileDescriptorUtils.h" #include "mozilla/ipc/PChildToParentStreamParent.h" #include "mozilla/ipc/TestShellParent.h" #include "mozilla/ipc/IPCStreamUtils.h" #include "mozilla/intl/LocaleService.h" #include "mozilla/jsipc/CrossProcessObjectWrappers.h" #include "mozilla/layers/PAPZParent.h" #include "mozilla/layers/CompositorThread.h" @@ -145,16 +146,17 @@ #include "nsISupportsPrimitives.h" #include "nsITimer.h" #include "nsIURIFixup.h" #include "nsIDocShellTreeOwner.h" #include "nsIXULWindow.h" #include "nsIDOMChromeWindow.h" #include "nsIWindowWatcher.h" #include "nsPIWindowWatcher.h" +#include "nsThread.h" #include "nsWindowWatcher.h" #include "nsIXULRuntime.h" #include "mozilla/dom/nsMixedContentBlocker.h" #include "nsMemoryInfoDumper.h" #include "nsMemoryReporterManager.h" #include "nsServiceManagerUtils.h" #include "nsStyleSheetService.h" #include "nsThreadUtils.h" @@ -243,21 +245,16 @@ #include "nsIBrowserSearchService.h" #endif #ifdef XP_WIN #include "mozilla/audio/AudioNotificationSender.h" #include "mozilla/widget/AudioSession.h" #endif -#ifdef MOZ_CRASHREPORTER -#include "nsThread.h" -#include "mozilla/ipc/CrashReporterHost.h" -#endif - #ifdef ACCESSIBILITY #include "nsAccessibilityService.h" #endif #ifdef MOZ_GECKO_PROFILER #include "nsIProfiler.h" #include "ProfilerParent.h" #endif @@ -268,19 +265,17 @@ // For VP9Benchmark::sBenchmarkFpsPref #include "Benchmark.h" static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID); using base::KillProcess; -#ifdef MOZ_CRASHREPORTER using namespace CrashReporter; -#endif using namespace mozilla::dom::power; using namespace mozilla::media; using namespace mozilla::embedding; using namespace mozilla::gfx; using namespace mozilla::gmp; using namespace mozilla::hal; using namespace mozilla::ipc; using namespace mozilla::intl; @@ -1725,34 +1720,32 @@ ContentParent::ActorDestroy(ActorDestroy props->SetPropertyAsUint64(NS_LITERAL_STRING("childID"), mChildID); if (AbnormalShutdown == why) { Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT, NS_LITERAL_CSTRING("content"), 1); props->SetPropertyAsBool(NS_LITERAL_STRING("abnormal"), true); -#ifdef MOZ_CRASHREPORTER // There's a window in which child processes can crash // after IPC is established, but before a crash reporter // is created. if (mCrashReporter) { // if mCreatedPairedMinidumps is true, we've already generated // parent/child dumps for desktop crashes. if (!mCreatedPairedMinidumps) { mCrashReporter->GenerateCrashReport(OtherPid()); } nsAutoString dumpID; if (mCrashReporter->HasMinidump()) { dumpID = mCrashReporter->MinidumpID(); } props->SetPropertyAsAString(NS_LITERAL_STRING("dumpID"), dumpID); } -#endif } nsAutoString cpId; cpId.AppendInt(static_cast<uint64_t>(this->ChildID())); obs->NotifyObservers((nsIPropertyBag2*) props, "ipc:content-shutdown", cpId.get()); } // Remove any and all idle listeners. nsCOMPtr<nsIIdleService> idleService = @@ -3055,17 +3048,16 @@ ContentParent::KillHard(const char* aRea // process handle becomes invalid on the first call, causing a second call // to crash our process - more details in bug 890840. if (mCalledKillHard) { return; } mCalledKillHard = true; mForceKillTimer = nullptr; -#if defined(MOZ_CRASHREPORTER) // We're about to kill the child process associated with this content. // Something has gone wrong to get us here, so we generate a minidump // of the parent and child for submission to the crash server. if (mCrashReporter) { // GeneratePairedMinidump creates two minidumps for us - the main // one is for the content process we're about to kill, and the other // one is for the main browser process. That second one is the extra // minidump tagging along, so we have to tell the crash reporter that @@ -3088,29 +3080,27 @@ ContentParent::KillHard(const char* aRea // Generate the report and insert into the queue for submittal. mCrashReporter->GenerateMinidumpAndPair(Process(), nullptr, NS_LITERAL_CSTRING("browser"), Move(callback), true); return; } -#endif + OnGenerateMinidumpComplete(false); } void ContentParent::OnGenerateMinidumpComplete(bool aDumpResult) { -#if defined(MOZ_CRASHREPORTER) if (mCrashReporter && aDumpResult) { // CrashReporterHost::GenerateMinidumpAndPair() is successful. mCreatedPairedMinidumps = mCrashReporter->FinalizeCrashReport(); } -#endif Unused << aDumpResult; // Don't care about result if no minidump was requested. ProcessHandle otherProcessHandle; if (!base::OpenProcessHandle(OtherPid(), &otherProcessHandle)) { NS_ERROR("Failed to open child process when attempting kill."); return; } @@ -3141,22 +3131,21 @@ ContentParent::FriendlyName(nsAString& a } else { aName.AssignLiteral("???"); } } mozilla::ipc::IPCResult ContentParent::RecvInitCrashReporter(Shmem&& aShmem, const NativeThreadId& aThreadId) { -#ifdef MOZ_CRASHREPORTER mCrashReporter = MakeUnique<CrashReporterHost>( GeckoProcessType_Content, aShmem, aThreadId); -#endif + return IPC_OK(); } hal_sandbox::PHalParent* ContentParent::AllocPHalParent() { return hal_sandbox::CreateHalParent(); } @@ -4942,19 +4931,17 @@ ContentParent::RecvNotifyPushSubscriptio mozilla::ipc::IPCResult ContentParent::RecvNotifyLowMemory() { MarkAsTroubled(); Telemetry::ScalarAdd(Telemetry::ScalarID::DOM_CONTENTPROCESS_TROUBLED_DUE_TO_MEMORY, 1); -#ifdef MOZ_CRASHREPORTER nsThread::SaveMemoryReportNearOOM(nsThread::ShouldSaveMemoryReport::kForceReport); -#endif return IPC_OK(); } /* static */ void ContentParent::BroadcastBlobURLRegistration(const nsACString& aURI, BlobImpl* aBlobImpl, nsIPrincipal* aPrincipal,
--- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -1278,19 +1278,18 @@ private: // This hashtable is used to run GetFilesHelper objects in the parent process. // GetFilesHelper can be aborted by receiving RecvDeleteGetFilesRequest. nsRefPtrHashtable<nsIDHashKey, GetFilesHelper> mGetFilesPendingRequests; nsTHashtable<nsCStringHashKey> mActivePermissionKeys; nsTArray<nsCString> mBlobURLs; -#ifdef MOZ_CRASHREPORTER + UniquePtr<mozilla::ipc::CrashReporterHost> mCrashReporter; -#endif static uint64_t sNextTabParentId; static nsDataHashtable<nsUint64HashKey, TabParent*> sNextTabParents; }; } // namespace dom } // namespace mozilla
--- a/dom/ipc/ProcessHangMonitor.cpp +++ b/dom/ipc/ProcessHangMonitor.cpp @@ -18,24 +18,22 @@ #include "mozilla/dom/TabParent.h" #include "mozilla/ipc/TaskFactory.h" #include "mozilla/Monitor.h" #include "mozilla/plugins/PluginBridge.h" #include "mozilla/Preferences.h" #include "mozilla/Unused.h" #include "mozilla/WeakPtr.h" +#include "nsExceptionHandler.h" #include "nsIFrameLoader.h" #include "nsIHangReport.h" #include "nsITabParent.h" #include "nsPluginHost.h" #include "nsThreadUtils.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif #include "base/task.h" #include "base/thread.h" #ifdef XP_WIN // For IsDebuggerPresent() #include <windows.h> #endif @@ -605,26 +603,24 @@ HangMonitorParent::HangMonitorParent(Pro sInited = true; Preferences::AddBoolVarCache(&sShouldForcePaint, "browser.tabs.remote.force-paint", true); } } HangMonitorParent::~HangMonitorParent() { -#ifdef MOZ_CRASHREPORTER MutexAutoLock lock(mBrowserCrashDumpHashLock); for (auto iter = mBrowserCrashDumpIds.Iter(); !iter.Done(); iter.Next()) { nsString crashId = iter.UserData(); if (!crashId.IsEmpty()) { CrashReporter::DeleteMinidumpFilesForID(crashId); } } -#endif } void HangMonitorParent::Shutdown() { MOZ_RELEASE_ASSERT(NS_IsMainThread()); MonitorAutoLock lock(mMonitor); @@ -767,33 +763,31 @@ HangMonitorParent::ClearHangNotification // Take a minidump of the browser process if one wasn't already taken for the // plugin that caused the hang. Return false if a dump was already available or // true if new one has been taken. bool HangMonitorParent::TakeBrowserMinidump(const PluginHangData& aPhd, nsString& aCrashId) { -#ifdef MOZ_CRASHREPORTER MutexAutoLock lock(mBrowserCrashDumpHashLock); if (!mBrowserCrashDumpIds.Get(aPhd.pluginId(), &aCrashId)) { nsCOMPtr<nsIFile> browserDump; if (CrashReporter::TakeMinidump(getter_AddRefs(browserDump), true)) { if (!CrashReporter::GetIDFromMinidump(browserDump, aCrashId) || aCrashId.IsEmpty()) { browserDump->Remove(false); NS_WARNING("Failed to generate timely browser stack, " "this is bad for plugin hang analysis!"); } else { mBrowserCrashDumpIds.Put(aPhd.pluginId(), aCrashId); return true; } } } -#endif // MOZ_CRASHREPORTER return false; } mozilla::ipc::IPCResult HangMonitorParent::RecvHangEvidence(const HangData& aHangData) { // chrome process, background thread @@ -886,21 +880,20 @@ void HangMonitorParent::CleanupPluginHang(uint32_t aPluginId, bool aRemoveFiles) { MutexAutoLock lock(mBrowserCrashDumpHashLock); nsAutoString crashId; if (!mBrowserCrashDumpIds.Get(aPluginId, &crashId)) { return; } mBrowserCrashDumpIds.Remove(aPluginId); -#ifdef MOZ_CRASHREPORTER + if (aRemoveFiles && !crashId.IsEmpty()) { CrashReporter::DeleteMinidumpFilesForID(crashId); } -#endif } void HangMonitorParent::UpdateMinidump(uint32_t aPluginId, const nsString& aDumpId) { if (aDumpId.IsEmpty()) { return; }
--- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -54,19 +54,17 @@ #include "mozilla/TouchEvents.h" #include "mozilla/Unused.h" #include "nsContentUtils.h" #include "nsCSSFrameConstructor.h" #include "nsDocShell.h" #include "nsEmbedCID.h" #include "nsGlobalWindow.h" #include <algorithm> -#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" -#endif #include "nsFilePickerProxy.h" #include "mozilla/dom/Element.h" #include "nsGlobalWindow.h" #include "nsIBaseWindow.h" #include "nsIBrowserDOMWindow.h" #include "nsIDocumentInlines.h" #include "nsIDocShellTreeOwner.h" #include "nsIDOMChromeWindow.h" @@ -1189,19 +1187,17 @@ TabChild::RecvLoadURL(const nsCString& a WebNavigation()->LoadURI(NS_ConvertUTF8toUTF16(aURI).get(), nsIWebNavigation::LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP | nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL, nullptr, nullptr, nullptr, nsContentUtils::GetSystemPrincipal()); if (NS_FAILED(rv)) { NS_WARNING("WebNavigation()->LoadURI failed. Eating exception, what else can I do?"); } -#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("URL"), aURI); -#endif return IPC_OK(); } void TabChild::DoFakeShow(const TextureFactoryIdentifier& aTextureFactoryIdentifier, const uint64_t& aLayersId, const CompositorOptions& aCompositorOptions,
--- a/dom/ipc/TabMessageUtils.h +++ b/dom/ipc/TabMessageUtils.h @@ -3,41 +3,33 @@ /* 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/. */ #ifndef TABMESSAGE_UTILS_H #define TABMESSAGE_UTILS_H #include "ipc/IPCMessageUtils.h" +#include "nsExceptionHandler.h" #include "nsIDOMEvent.h" #include "nsPIDOMWindow.h" #include "nsCOMPtr.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - namespace mozilla { namespace dom { struct RemoteDOMEvent { // Make sure to set the owner after deserializing. nsCOMPtr<nsIDOMEvent> mEvent; }; bool ReadRemoteEvent(const IPC::Message* aMsg, PickleIterator* aIter, mozilla::dom::RemoteDOMEvent* aResult); -#ifdef MOZ_CRASHREPORTER typedef CrashReporter::ThreadId NativeThreadId; -#else -// unused in this case -typedef int32_t NativeThreadId; -#endif } // namespace dom } // namespace mozilla namespace IPC { template<> struct ParamTraits<mozilla::dom::RemoteDOMEvent>
--- a/dom/media/gmp/GMPChild.cpp +++ b/dom/media/gmp/GMPChild.cpp @@ -241,19 +241,17 @@ GMPChild::Init(const nsAString& aPluginP IPC::Channel* aChannel) { LOGD("%s pluginPath=%s", __FUNCTION__, NS_ConvertUTF16toUTF8(aPluginPath).get()); if (NS_WARN_IF(!Open(aChannel, aParentPid, aIOLoop))) { return false; } -#ifdef MOZ_CRASHREPORTER CrashReporterClient::InitSingleton(this); -#endif mPluginPath = aPluginPath; return true; } GMPErr GMPChild::GetAPI(const char* aAPIName, @@ -612,19 +610,18 @@ GMPChild::ActorDestroy(ActorDestroyReaso if (mGMPLoader) { mGMPLoader->Shutdown(); } if (AbnormalShutdown == aWhy) { NS_WARNING("Abnormal shutdown of GMP process!"); ProcessChild::QuickExit(); } -#ifdef MOZ_CRASHREPORTER CrashReporterClient::DestroySingleton(); -#endif + XRE_ShutdownChildProcess(); } void GMPChild::ProcessingError(Result aCode, const char* aReason) { switch (aCode) { case MsgDropped:
--- a/dom/media/gmp/GMPParent.cpp +++ b/dom/media/gmp/GMPParent.cpp @@ -2,43 +2,41 @@ /* 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 "GMPParent.h" #include "mozilla/Logging.h" #include "nsComponentManagerUtils.h" #include "nsComponentManagerUtils.h" +#include "nsPrintfCString.h" #include "nsThreadUtils.h" #include "nsIRunnable.h" #include "nsIWritablePropertyBag2.h" #include "mozIGeckoMediaPluginService.h" #include "mozilla/AbstractThread.h" +#include "mozilla/ipc/CrashReporterHost.h" #include "mozilla/ipc/GeckoChildProcessHost.h" #include "mozilla/SSE.h" #include "mozilla/SyncRunnable.h" #include "mozilla/Unused.h" #include "nsIObserverService.h" #include "GMPTimerParent.h" #include "runnable_utils.h" #if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX) #include "mozilla/SandboxInfo.h" #endif #include "GMPContentParent.h" #include "MediaPrefs.h" #include "VideoUtils.h" using mozilla::ipc::GeckoChildProcessHost; -#ifdef MOZ_CRASHREPORTER -#include "nsPrintfCString.h" -#include "mozilla/ipc/CrashReporterHost.h" using CrashReporter::AnnotationTable; using CrashReporter::GetIDFromMinidump; -#endif #include "mozilla/Telemetry.h" #ifdef XP_WIN #include "WMFDecoderModule.h" #endif #include "mozilla/dom/WidevineCDMManifestBinding.h" @@ -447,17 +445,16 @@ GMPParent::EnsureProcessLoaded() return false; } nsresult rv = LoadProcess(); return NS_SUCCEEDED(rv); } -#ifdef MOZ_CRASHREPORTER void GMPParent::WriteExtraDataForMinidump() { mCrashReporter->AddNote(NS_LITERAL_CSTRING("GMPPlugin"), NS_LITERAL_CSTRING("1")); mCrashReporter->AddNote(NS_LITERAL_CSTRING("PluginFilename"), NS_ConvertUTF16toUTF8(mName)); mCrashReporter->AddNote(NS_LITERAL_CSTRING("PluginName"), mDisplayName); mCrashReporter->AddNote(NS_LITERAL_CSTRING("PluginVersion"), mVersion); } @@ -492,39 +489,39 @@ GMPNotifyObservers(const uint32_t aPlugi } RefPtr<gmp::GeckoMediaPluginService> service = gmp::GeckoMediaPluginService::GetGeckoMediaPluginService(); if (service) { service->RunPluginCrashCallbacks(aPluginID, aPluginName); } } -#endif + void GMPParent::ActorDestroy(ActorDestroyReason aWhy) { LOGD("%s: (%d)", __FUNCTION__, (int)aWhy); -#ifdef MOZ_CRASHREPORTER + if (AbnormalShutdown == aWhy) { Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT, NS_LITERAL_CSTRING("gmplugin"), 1); nsString dumpID; if (!GetCrashID(dumpID)) { NS_WARNING("GMP crash without crash report"); dumpID = mName; dumpID += '-'; AppendUTF8toUTF16(mVersion, dumpID); } // NotifyObservers is mainthread-only nsCOMPtr<nsIRunnable> r = WrapRunnableNM( &GMPNotifyObservers, mPluginId, mDisplayName, dumpID); mMainThread->Dispatch(r.forget()); } -#endif + // warn us off trying to close again mState = GMPStateClosing; mAbnormalShutdownInProgress = true; CloseActive(false); // Normal Shutdown() will delete the process on unwind. if (AbnormalShutdown == aWhy) { RefPtr<GMPParent> self(this); @@ -535,22 +532,21 @@ GMPParent::ActorDestroy(ActorDestroyReas // Note: final destruction will be Dispatched to ourself mService->ReAddOnGMPThread(self); } } mozilla::ipc::IPCResult GMPParent::RecvInitCrashReporter(Shmem&& aShmem, const NativeThreadId& aThreadId) { -#ifdef MOZ_CRASHREPORTER mCrashReporter = MakeUnique<ipc::CrashReporterHost>( GeckoProcessType_GMPlugin, aShmem, aThreadId); -#endif + return IPC_OK(); } PGMPStorageParent* GMPParent::AllocPGMPStorageParent() { GMPStorageParent* p = new GMPStorageParent(mNodeId, this); mStorage.AppendElement(p); // Addrefs, released in DeallocPGMPStorageParent.
--- a/dom/media/gmp/GMPParent.h +++ b/dom/media/gmp/GMPParent.h @@ -148,20 +148,18 @@ private: ~GMPParent(); RefPtr<GeckoMediaPluginServiceParent> mService; bool EnsureProcessLoaded(); RefPtr<GenericPromise> ReadGMPMetaData(); RefPtr<GenericPromise> ReadGMPInfoFile(nsIFile* aFile); RefPtr<GenericPromise> ParseChromiumManifest(const nsAString& aJSON); // Main thread. RefPtr<GenericPromise> ReadChromiumManifestFile(nsIFile* aFile); // GMP thread. -#ifdef MOZ_CRASHREPORTER void WriteExtraDataForMinidump(); bool GetCrashID(nsString& aResult); -#endif void ActorDestroy(ActorDestroyReason aWhy) override; mozilla::ipc::IPCResult RecvInitCrashReporter(Shmem&& shmem, const NativeThreadId& aThreadId) override; mozilla::ipc::IPCResult RecvPGMPStorageConstructor(PGMPStorageParent* actor) override; PGMPStorageParent* AllocPGMPStorageParent() override; bool DeallocPGMPStorageParent(PGMPStorageParent* aActor) override; @@ -212,19 +210,17 @@ private: int mChildPid; // We hold a self reference to ourself while the child process is alive. // This ensures that if the GMPService tries to shut us down and drops // its reference to us, we stay alive long enough for the child process // to terminate gracefully. bool mHoldingSelfRef; -#ifdef MOZ_CRASHREPORTER UniquePtr<ipc::CrashReporterHost> mCrashReporter; -#endif const RefPtr<AbstractThread> mMainThread; }; } // namespace gmp } // namespace mozilla #endif // GMPParent_h_
--- a/dom/plugins/base/nsPluginHost.cpp +++ b/dom/plugins/base/nsPluginHost.cpp @@ -6,16 +6,17 @@ /* nsPluginHost.cpp - top-level plugin management code */ #include "nscore.h" #include "nsPluginHost.h" #include <cstdlib> #include <stdio.h> #include "prio.h" +#include "nsExceptionHandler.h" #include "nsNPAPIPlugin.h" #include "nsNPAPIPluginStreamListener.h" #include "nsNPAPIPluginInstance.h" #include "nsPluginInstanceOwner.h" #include "nsObjectLoadingContent.h" #include "nsIHTTPHeaderListener.h" #include "nsIHttpHeaderVisitor.h" #include "nsIObserverService.h" @@ -98,20 +99,16 @@ #if defined(XP_WIN) #include "nsIWindowMediator.h" #include "nsIBaseWindow.h" #include "windows.h" #include "winbase.h" #endif -#if MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - #include "npapi.h" using namespace mozilla; using mozilla::TimeStamp; using mozilla::plugins::FakePluginTag; using mozilla::plugins::PluginTag; using mozilla::dom::FakePluginTagInit; using mozilla::dom::FakePluginMimeEntry;
--- a/dom/plugins/base/nsPluginsDirDarwin.cpp +++ b/dom/plugins/base/nsPluginsDirDarwin.cpp @@ -21,19 +21,17 @@ #include "nsPluginsDir.h" #include "nsNPAPIPlugin.h" #include "nsPluginsDirUtils.h" #include "nsILocalFileMac.h" #include "mozilla/UniquePtr.h" #include "nsCocoaFeatures.h" -#if defined(MOZ_CRASHREPORTER) #include "nsExceptionHandler.h" -#endif #include <string.h> #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <Carbon/Carbon.h> #include <CoreServices/CoreServices.h> @@ -419,41 +417,40 @@ nsresult nsPluginFile::GetPluginInfo(nsP if (fileName.EqualsLiteral("fbplugin") || StringBeginsWith(fileName, NS_LITERAL_CSTRING("fbplugin_"))) { nsAutoCString msg; msg.AppendPrintf("Preventing load of %s (see bug 1086977)", fileName.get()); NS_WARNING(msg.get()); return NS_ERROR_FAILURE; } -#if defined(MOZ_CRASHREPORTER) + // The block above assumes that "fbplugin" is the filename of the plugin // to be blocked, or that the filename starts with "fbplugin_". But we // don't yet know for sure if this is always true. So for the time being // record extra information in our crash logs. CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Bug_1086977"), fileName); -#endif } // It's possible that our plugin has 2 entry points that'll give us mime type // info. Quicktime does this to get around the need of having admin rights to // change mime info in the resource fork. We need to use this info instead of // the resource. See bug 113464. // Sadly we have to load the library for this to work. rv = LoadPlugin(outLibrary); -#if defined(MOZ_CRASHREPORTER) + if (nsCocoaFeatures::OnYosemiteOrLater()) { // If we didn't crash in LoadPlugin(), change the previous annotation so we // don't sow confusion. CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Bug_1086977"), NS_LITERAL_CSTRING("Didn't crash, please ignore")); } -#endif + if (NS_FAILED(rv)) return rv; // Try to get data from NP_GetMIMEDescription if (pLibrary) { NP_GETMIMEDESCRIPTION pfnGetMimeDesc = (NP_GETMIMEDESCRIPTION)PR_FindFunctionSymbol(pLibrary, NP_GETMIMEDESCRIPTION_NAME); if (pfnGetMimeDesc) ParsePluginMimeDescription(pfnGetMimeDesc(), info);
--- a/dom/plugins/ipc/PluginMessageUtils.h +++ b/dom/plugins/ipc/PluginMessageUtils.h @@ -17,20 +17,19 @@ #include "gfxipc/ShadowLayerUtils.h" #include "npapi.h" #include "npruntime.h" #include "npfunctions.h" #include "nsString.h" #include "nsTArray.h" #include "mozilla/Logging.h" +#include "nsExceptionHandler.h" #include "nsHashKeys.h" -#ifdef MOZ_CRASHREPORTER -# include "nsExceptionHandler.h" -#endif + #ifdef XP_MACOSX #include "PluginInterposeOSX.h" #else namespace mac_plugin_interposing { class NSCursorInfo { }; } #endif using mac_plugin_interposing::NSCursorInfo; #ifdef XP_WIN #include "commdlg.h"
--- a/dom/plugins/ipc/PluginModuleChild.cpp +++ b/dom/plugins/ipc/PluginModuleChild.cpp @@ -22,16 +22,18 @@ #include "nsCOMPtr.h" #include "nsPluginsDir.h" #include "nsXULAppAPI.h" #ifdef MOZ_X11 # include "nsX11ErrorHandler.h" # include "mozilla/X11Util.h" #endif + +#include "mozilla/ipc/CrashReporterClient.h" #include "mozilla/ipc/ProcessChild.h" #include "mozilla/plugins/PluginInstanceChild.h" #include "mozilla/plugins/StreamNotifyChild.h" #include "mozilla/plugins/BrowserStreamChild.h" #include "mozilla/Sprintf.h" #include "mozilla/Unused.h" #include "nsNPAPIPlugin.h" @@ -43,20 +45,16 @@ #include <shlobj.h> #endif #ifdef MOZ_WIDGET_COCOA #include "PluginInterposeOSX.h" #include "PluginUtilsOSX.h" #endif -#ifdef MOZ_CRASHREPORTER -#include "mozilla/ipc/CrashReporterClient.h" -#endif - #ifdef MOZ_GECKO_PROFILER #include "ChildProfilerController.h" #endif using namespace mozilla; using namespace mozilla::ipc; using namespace mozilla::plugins; using namespace mozilla::widget; @@ -745,20 +743,19 @@ PluginModuleChild::RecvInitPluginModuleC } return IPC_OK(); } mozilla::ipc::IPCResult PluginModuleChild::AnswerInitCrashReporter(Shmem&& aShmem, mozilla::dom::NativeThreadId* aOutId) { -#ifdef MOZ_CRASHREPORTER CrashReporterClient::InitSingletonWithShmem(aShmem); *aOutId = CrashReporter::CurrentThreadId(); -#endif + return IPC_OK(); } void PluginModuleChild::ActorDestroy(ActorDestroyReason why) { #ifdef MOZ_GECKO_PROFILER if (mProfilerController) { @@ -787,19 +784,18 @@ PluginModuleChild::ActorDestroy(ActorDes if (!mHasShutdown) { MOZ_ASSERT(gChromeInstance == this); NP_Shutdown(); } // doesn't matter why we're being destroyed; it's up to us to // initiate (clean) shutdown -#ifdef MOZ_CRASHREPORTER CrashReporterClient::DestroySingleton(); -#endif + XRE_ShutdownChildProcess(); } void PluginModuleChild::CleanUp() { }
--- a/dom/plugins/ipc/PluginModuleParent.cpp +++ b/dom/plugins/ipc/PluginModuleParent.cpp @@ -5,16 +5,18 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/plugins/PluginModuleParent.h" #include "base/process_util.h" #include "mozilla/Attributes.h" #include "mozilla/dom/ContentParent.h" #include "mozilla/dom/ContentChild.h" +#include "mozilla/ipc/CrashReporterClient.h" +#include "mozilla/ipc/CrashReporterHost.h" #include "mozilla/ipc/GeckoChildProcessHost.h" #include "mozilla/ipc/MessageChannel.h" #include "mozilla/ipc/ProtocolUtils.h" #include "mozilla/plugins/BrowserStreamParent.h" #include "mozilla/plugins/PluginBridge.h" #include "mozilla/plugins/PluginInstanceParent.h" #include "mozilla/Preferences.h" #include "mozilla/ProcessHangMonitor.h" @@ -60,22 +62,17 @@ using base::KillProcess; using mozilla::PluginLibrary; using mozilla::ipc::MessageChannel; using mozilla::ipc::GeckoChildProcessHost; using namespace mozilla; using namespace mozilla::plugins; using namespace mozilla::plugins::parent; -#ifdef MOZ_CRASHREPORTER -#include "mozilla/ipc/CrashReporterClient.h" -#include "mozilla/ipc/CrashReporterHost.h" - using namespace CrashReporter; -#endif static const char kContentTimeoutPref[] = "dom.ipc.plugins.contentTimeoutSecs"; static const char kChildTimeoutPref[] = "dom.ipc.plugins.timeoutSecs"; static const char kParentTimeoutPref[] = "dom.ipc.plugins.parentTimeoutSecs"; static const char kLaunchTimeoutPref[] = "dom.ipc.plugins.processLaunchTimeoutSecs"; #ifdef XP_WIN static const char kHangUITimeoutPref[] = "dom.ipc.plugins.hangUITimeoutSecs"; static const char kHangUIMinDisplayPref[] = "dom.ipc.plugins.hangUIMinDisplaySecs"; @@ -520,25 +517,23 @@ PluginModuleChromeParent::OnProcessLaunc Preferences::RegisterCallback(TimeoutChanged, kParentTimeoutPref, this); #ifdef XP_WIN Preferences::RegisterCallback(TimeoutChanged, kHangUITimeoutPref, this); Preferences::RegisterCallback(TimeoutChanged, kHangUIMinDisplayPref, this); #endif RegisterSettingsCallbacks(); -#ifdef MOZ_CRASHREPORTER // If this fails, we're having IPC troubles, and we're doomed anyways. if (!InitCrashReporter()) { mShutdown = true; Close(); OnInitFailure(); return; } -#endif #if defined(XP_WIN) && defined(_X86_) // Protected mode only applies to Windows and only to x86. if (!mIsBlocklisted && mIsFlashPlugin && (Preferences::GetBool("dom.ipc.plugins.flash.disable-protected-mode", false) || mSandboxLevel >= 2)) { Unused << SendDisableFlashProtectedMode(); } @@ -547,17 +542,16 @@ PluginModuleChromeParent::OnProcessLaunc #ifdef MOZ_GECKO_PROFILER Unused << SendInitProfiler(ProfilerParent::CreateForProcess(OtherPid())); #endif } bool PluginModuleChromeParent::InitCrashReporter() { -#ifdef MOZ_CRASHREPORTER ipc::Shmem shmem; if (!ipc::CrashReporterClient::AllocShmem(this, &shmem)) { return false; } NativeThreadId threadId; if (!CallInitCrashReporter(shmem, &threadId)) { return false; @@ -565,17 +559,16 @@ PluginModuleChromeParent::InitCrashRepor { mozilla::MutexAutoLock lock(mCrashReporterMutex); mCrashReporter = MakeUnique<ipc::CrashReporterHost>( GeckoProcessType_Plugin, shmem, threadId); } -#endif return true; } PluginModuleParent::PluginModuleParent(bool aIsChrome) : mQuirks(QUIRKS_NOT_INITIALIZED) , mIsChrome(aIsChrome) , mShutdown(false) @@ -583,19 +576,17 @@ PluginModuleParent::PluginModuleParent(b , mClearSiteDataSupported(false) , mGetSitesWithDataSupported(false) , mNPNIface(nullptr) , mNPPIface(nullptr) , mPlugin(nullptr) , mTaskFactory(this) , mSandboxLevel(0) , mIsFlashPlugin(false) -#ifdef MOZ_CRASHREPORTER , mCrashReporterMutex("PluginModuleChromeParent::mCrashReporterMutex") -#endif { } PluginModuleParent::~PluginModuleParent() { if (!OkToCleanup()) { MOZ_CRASH("unsafe destruction"); } @@ -697,17 +688,16 @@ PluginModuleChromeParent::~PluginModuleC delete mHangUIParent; mHangUIParent = nullptr; } #endif mozilla::HangMonitor::UnregisterAnnotator(*this); } -#ifdef MOZ_CRASHREPORTER void PluginModuleChromeParent::WriteExtraDataForMinidump() { // mCrashReporterMutex is already held by the caller mCrashReporterMutex.AssertCurrentThreadOwns(); typedef nsDependentCString CS; @@ -739,17 +729,16 @@ PluginModuleChromeParent::WriteExtraData tempStr.AppendFloat(std::ceil(mPluginCpuUsageOnHang[i] * 100) / 100); mCrashReporter->AddNote(nsPrintfCString("CpuUsageFlashProcess%d", i), tempStr); } #endif } #endif } } -#endif // MOZ_CRASHREPORTER void PluginModuleParent::SetChildTimeout(const int32_t aChildTimeout) { int32_t timeoutMs = (aChildTimeout > 0) ? (1000 * aChildTimeout) : MessageChannel::kNoTimeout; SetReplyTimeoutMs(timeoutMs); } @@ -995,29 +984,27 @@ PluginModuleChromeParent::AnnotateHang(m true); } aAnnotations.AddAnnotation(NS_LITERAL_STRING("pluginName"), mPluginName); aAnnotations.AddAnnotation(NS_LITERAL_STRING("pluginVersion"), mPluginVersion); } } -#ifdef MOZ_CRASHREPORTER static bool CreatePluginMinidump(base::ProcessId processId, ThreadId childThread, nsIFile* parentMinidump, const nsACString& name) { mozilla::ipc::ScopedProcessHandle handle; if (processId == 0 || !base::OpenPrivilegedProcessHandle(processId, &handle.rwget())) { return false; } return CreateAdditionalChildMinidump(handle, 0, parentMinidump, name); } -#endif bool PluginModuleChromeParent::ShouldContinueFromReplyTimeout() { if (mIsFlashPlugin) { MessageLoop::current()->PostTask( mTaskFactory.NewRunnableMethod( &PluginModuleChromeParent::NotifyFlashHang)); @@ -1062,17 +1049,16 @@ PluginModuleContentParent::OnExitedSyncS } void PluginModuleChromeParent::TakeFullMinidump(base::ProcessId aContentPid, const nsAString& aBrowserDumpId, std::function<void(nsString)>&& aCallback, bool aAsync) { -#ifdef MOZ_CRASHREPORTER mozilla::MutexAutoLock lock(mCrashReporterMutex); if (!mCrashReporter || !mTakeFullMinidumpCallback.IsEmpty()) { aCallback(EmptyString()); return; } mTakeFullMinidumpCallback.Init(Move(aCallback), aAsync); @@ -1106,22 +1092,18 @@ PluginModuleChromeParent::TakeFullMinidu // We have a single browser report, generate a new plugin process parent // report and pair it up with the browser report handed in. mCrashReporter->GenerateMinidumpAndPair(Process(), mBrowserDumpFile, NS_LITERAL_CSTRING("browser"), Move(callback), aAsync); } else { TakeBrowserAndPluginMinidumps(false, aContentPid, browserDumpId, aAsync); } -#else // MOZ_CRASHREPORTER - aCallback(NS_LITERAL_STRING("")); -#endif } -#ifdef MOZ_CRASHREPORTER void PluginModuleChromeParent::RetainPluginRef() { if (!mPlugin) { return; } if (NS_IsMainThread()) { @@ -1230,33 +1212,30 @@ PluginModuleChromeParent::OnTakeFullMini mTakeFullMinidumpCallback.Invoke(mCrashReporter->MinidumpID()); } else { mTakeFullMinidumpCallback.Invoke(EmptyString()); NS_WARNING("failed to capture paired minidumps from hang"); } } -#endif // MOZ_CRASHREPORTER - void PluginModuleChromeParent::TerminateChildProcess(MessageLoop* aMsgLoop, base::ProcessId aContentPid, const nsCString& aMonitorDescription, const nsAString& aDumpId, std::function<void(bool)>&& aCallback, bool aAsync) { if (!mTerminateChildProcessCallback.IsEmpty()) { aCallback(false); return; } mTerminateChildProcessCallback.Init(Move(aCallback), aAsync); -#ifdef MOZ_CRASHREPORTER // Start by taking a full minidump if necessary, this is done early // because it also needs to lock the mCrashReporterMutex and Mutex doesn't // support recursive locking. if (aDumpId.IsEmpty()) { RetainPluginRef(); std::function<void(nsString)> callback = [this, aMsgLoop, aMonitorDescription, aAsync](nsString aResult) { @@ -1271,27 +1250,22 @@ PluginModuleChromeParent::TerminateChild this->ReleasePluginRef(); }; TakeFullMinidump(aContentPid, EmptyString(), Move(callback), aAsync); } else { TerminateChildProcessOnDumpComplete(aMsgLoop, aMonitorDescription); } - -#else - TerminateChildProcessOnDumpComplete(aMsgLoop, aMonitorDescription); -#endif } void PluginModuleChromeParent::TerminateChildProcessOnDumpComplete(MessageLoop* aMsgLoop, const nsCString& aMonitorDescription) { -#ifdef MOZ_CRASHREPORTER mCrashReporterMutex.AssertCurrentThreadOwns(); if (!mCrashReporter) { // If mCrashReporter is null then the hang has ended, the plugin module // is shutting down. There's nothing to do here. mTerminateChildProcessCallback.Invoke(true); return; } @@ -1305,17 +1279,16 @@ PluginModuleChromeParent::TerminateChild if (hangUIDuration) { nsPrintfCString strHangUIDuration("%u", hangUIDuration); mCrashReporter->AddNote( NS_LITERAL_CSTRING("PluginHangUIDuration"), strHangUIDuration); } } #endif // XP_WIN -#endif // MOZ_CRASHREPORTER mozilla::ipc::ScopedProcessHandle geckoChildProcess; bool childOpened = base::OpenProcessHandle(OtherPid(), &geckoChildProcess.rwget()); #ifdef XP_WIN // collect cpu usage for plugin processes @@ -1336,17 +1309,17 @@ PluginModuleChromeParent::TerminateChild base::OpenProcessHandle(mFlashProcess2, &flashSandboxProcess.rwget())) { processHandles.AppendElement(flashSandboxProcess); } #endif if (!GetProcessCpuUsage(processHandles, mPluginCpuUsageOnHang)) { mPluginCpuUsageOnHang.Clear(); } -#endif // MOZ_CRASHREPORTER +#endif // this must run before the error notification from the channel, // or not at all bool isFromHangUI = aMsgLoop != MessageLoop::current(); aMsgLoop->PostTask( mChromeTaskFactory.NewRunnableMethod( &PluginModuleChromeParent::CleanupFromTimeout, isFromHangUI)); @@ -1481,17 +1454,16 @@ PluginModuleChromeParent::FinishHangUI() void PluginModuleChromeParent::OnHangUIContinue() { mHangAnnotationFlags |= kHangUIContinued; } #endif // XP_WIN -#ifdef MOZ_CRASHREPORTER #ifdef MOZ_CRASHREPORTER_INJECTOR static void RemoveMinidump(nsIFile* minidump) { if (!minidump) return; minidump->Remove(false); @@ -1573,17 +1545,16 @@ PluginModuleChromeParent::ProcessFirstMi PLUGIN_LOG_DEBUG(("got child minidump: %s", NS_ConvertUTF16toUTF8(mCrashReporter->MinidumpID()).get())); if (!flashProcessType.IsEmpty()) { mCrashReporter->AddNote(NS_LITERAL_CSTRING("FlashProcessDump"), flashProcessType); } mCrashReporter->FinalizeCrashReport(); } -#endif void PluginModuleParent::ActorDestroy(ActorDestroyReason why) { switch (why) { case AbnormalShutdown: { mShutdown = true; // Defer the PluginCrashed method so that we don't re-enter @@ -1612,19 +1583,17 @@ PluginModuleParent::GetRunID(uint32_t* a *aRunID = mRunID; return NS_OK; } void PluginModuleChromeParent::ActorDestroy(ActorDestroyReason why) { if (why == AbnormalShutdown) { -#ifdef MOZ_CRASHREPORTER ProcessFirstMinidump(); -#endif Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT, NS_LITERAL_CSTRING("plugin"), 1); } // We can't broadcast settings changes anymore. UnregisterSettingsCallbacks(); PluginModuleParent::ActorDestroy(why); @@ -1651,21 +1620,21 @@ PluginModuleParent::NotifyPluginCrashed( } if (!mPlugin) { return; } nsString dumpID; nsString browserDumpID; -#ifdef MOZ_CRASHREPORTER + if (mCrashReporter && mCrashReporter->HasMinidump()) { dumpID = mCrashReporter->MinidumpID(); } -#endif + mPlugin->PluginCrashed(dumpID, browserDumpID); } PPluginInstanceParent* PluginModuleParent::AllocPPluginInstanceParent(const nsCString& aMimeType, const InfallibleTArray<nsCString>& aNames, const InfallibleTArray<nsCString>& aValues) {
--- a/dom/plugins/ipc/PluginModuleParent.h +++ b/dom/plugins/ipc/PluginModuleParent.h @@ -16,30 +16,27 @@ #include "mozilla/plugins/PPluginModuleParent.h" #include "mozilla/plugins/PluginMessageUtils.h" #include "mozilla/plugins/PluginTypes.h" #include "mozilla/ipc/TaskFactory.h" #include "mozilla/TimeStamp.h" #include "mozilla/Unused.h" #include "npapi.h" #include "npfunctions.h" +#include "nsExceptionHandler.h" #include "nsDataHashtable.h" #include "nsHashKeys.h" #include "nsIObserver.h" #ifdef XP_WIN #include "nsWindowsHelpers.h" #if defined(MOZ_SANDBOX) #include "sandboxPermissions.h" #endif #endif -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - class nsPluginTag; namespace mozilla { namespace layers { class TextureClientRecycleAllocator; } // namespace layers @@ -329,26 +326,24 @@ protected: bool GetPluginDetails(); uint32_t mRunID; RefPtr<layers::TextureClientRecycleAllocator> mTextureAllocatorForDirectBitmap; RefPtr<layers::TextureClientRecycleAllocator> mTextureAllocatorForDXGISurface; -#ifdef MOZ_CRASHREPORTER /** * This mutex protects the crash reporter when the Plugin Hang UI event * handler is executing off main thread. It is intended to protect both * the mCrashReporter variable in addition to the CrashReporterHost object * that mCrashReporter refers to. */ mozilla::Mutex mCrashReporterMutex; UniquePtr<ipc::CrashReporterHost> mCrashReporter; -#endif // MOZ_CRASHREPORTER }; class PluginModuleContentParent : public PluginModuleParent { public: explicit PluginModuleContentParent(); static PluginLibrary* LoadModule(uint32_t aPluginId, nsPluginTag* aPluginTag); @@ -453,28 +448,27 @@ class PluginModuleChromeParent */ template<typename T> static std::function<void(T)> DummyCallback() { return std::function<void(T)>([](T aResult) { }); } private: -#ifdef MOZ_CRASHREPORTER // The following methods are callbacks invoked after calling // TakeFullMinidump(). The methods are invoked in the following order: void TakeBrowserAndPluginMinidumps(bool aReportsReady, base::ProcessId aContentPid, const nsAString& aBrowserDumpId, bool aAsync); void OnTakeFullMinidumpComplete(bool aReportsReady, base::ProcessId aContentPid, const nsAString& aBrowserDumpId); -#endif + // The following method is the callback invoked after calling // TerminateChidlProcess(). void TerminateChildProcessOnDumpComplete(MessageLoop* aMsgLoop, const nsCString& aMonitorDescription); public: #ifdef XP_WIN /** @@ -513,22 +507,20 @@ private: mozilla::ipc::IProtocol* GetInvokingProtocol(); PluginInstanceParent* GetManagingInstance(mozilla::ipc::IProtocol* aProtocol); virtual void AnnotateHang(mozilla::HangMonitor::HangAnnotations& aAnnotations) override; virtual bool ShouldContinueFromReplyTimeout() override; -#ifdef MOZ_CRASHREPORTER void ProcessFirstMinidump(); void WriteExtraDataForMinidump(); void RetainPluginRef(); void ReleasePluginRef(); -#endif PluginProcessParent* Process() const { return mSubprocess; } base::ProcessHandle ChildProcessHandle() { return mSubprocess->GetChildProcessHandle(); } #if defined(XP_UNIX) && !defined(XP_MACOSX) virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error) override; #else virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) override; @@ -636,19 +628,18 @@ private: friend class LaunchedTask; nsCOMPtr<nsIObserver> mPluginOfflineObserver; bool mIsBlocklisted; #if defined(XP_WIN) && defined(MOZ_SANDBOX) mozilla::SandboxPermissions mSandboxPermissions; #endif -#ifdef MOZ_CRASHREPORTER nsCOMPtr<nsIFile> mBrowserDumpFile; TakeFullMinidumpCallback mTakeFullMinidumpCallback; -#endif + TerminateChildProcessCallback mTerminateChildProcessCallback; }; } // namespace plugins } // namespace mozilla #endif // mozilla_plugins_PluginModuleParent_h
--- a/dom/workers/ServiceWorkerEvents.cpp +++ b/dom/workers/ServiceWorkerEvents.cpp @@ -664,16 +664,23 @@ RespondWithHandler::ResolvedCallback(JSC nsCString responseURL; if (response->Type() == ResponseType::Opaque) { responseURL = ir->GetUnfilteredURL(); if (NS_WARN_IF(responseURL.IsEmpty())) { return; } } + Telemetry::ScalarAdd(Telemetry::ScalarID::SW_SYNTHESIZED_RES_COUNT, 1); + + if (mRequestMode == RequestMode::Same_origin && + response->Type() == ResponseType::Cors) { + Telemetry::ScalarAdd(Telemetry::ScalarID::SW_CORS_RES_FOR_SO_REQ_COUNT, 1); + } + UniquePtr<RespondWithClosure> closure(new RespondWithClosure(mInterceptedChannel, mRegistration, mRequestURL, mRespondWithScriptSpec, mRespondWithLineNumber, mRespondWithColumnNumber)); nsCOMPtr<nsIRunnable> startRunnable = new StartResponse(mInterceptedChannel,
--- a/gfx/gl/GLContextProviderEGL.cpp +++ b/gfx/gl/GLContextProviderEGL.cpp @@ -212,17 +212,20 @@ GLContextEGLFactory::Create(EGLNativeWin if (!gl) { gfxCriticalNote << "Failed to create EGLContext!"; mozilla::gl::DestroySurface(surface); return nullptr; } gl->MakeCurrent(); gl->SetIsDoubleBuffered(doubleBuffered); - + if (aWebRender && sEGLLibrary.IsANGLE()) { + MOZ_ASSERT(doubleBuffered); + sEGLLibrary.fSwapInterval(EGL_DISPLAY(), 0); + } return gl.forget(); } GLContextEGL::GLContextEGL(CreateContextFlags flags, const SurfaceCaps& caps, bool isOffscreen, EGLConfig config, EGLSurface surface, EGLContext context) : GLContext(flags, caps, nullptr, isOffscreen, sEGLLibrary.IsANGLE()) , mConfig(config)
--- a/gfx/gl/GLLibraryEGL.cpp +++ b/gfx/gl/GLLibraryEGL.cpp @@ -408,16 +408,17 @@ GLLibraryEGL::EnsureInitialized(bool for SYMBOL(WaitNative), SYMBOL(GetProcAddress), SYMBOL(SwapBuffers), SYMBOL(CopyBuffers), SYMBOL(QueryString), SYMBOL(QueryContext), SYMBOL(BindTexImage), SYMBOL(ReleaseTexImage), + SYMBOL(SwapInterval), SYMBOL(QuerySurface), END_OF_SYMBOLS }; if (!GLLibraryLoader::LoadSymbols(mEGLLibrary, earlySymbols)) { NS_WARNING("Couldn't find required entry points in EGL library (early init)"); *out_failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_EGL_SYM"); return false;
--- a/gfx/gl/GLLibraryEGL.h +++ b/gfx/gl/GLLibraryEGL.h @@ -251,16 +251,19 @@ public: WRAP( fQueryContext(dpy, ctx, attribute, value) ) EGLBoolean fBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) const WRAP( fBindTexImage(dpy, surface, buffer) ) EGLBoolean fReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) const WRAP( fReleaseTexImage(dpy, surface, buffer) ) + EGLBoolean fSwapInterval(EGLDisplay dpy, EGLint interval) const + WRAP( fSwapInterval(dpy, interval) ) + EGLImage fCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint* attrib_list) const WRAP( fCreateImageKHR(dpy, ctx, target, buffer, attrib_list) ) EGLBoolean fDestroyImage(EGLDisplay dpy, EGLImage image) const WRAP( fDestroyImageKHR(dpy, image) ) EGLBoolean fLockSurface(EGLDisplay dpy, EGLSurface surface, const EGLint* attrib_list) const WRAP( fLockSurfaceKHR(dpy, surface, attrib_list) ) @@ -428,16 +431,17 @@ private: EGLNativePixmapType target); const GLubyte* (GLAPIENTRY * fQueryString)(EGLDisplay, EGLint name); EGLBoolean (GLAPIENTRY * fQueryContext)(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint* value); EGLBoolean (GLAPIENTRY * fBindTexImage)(EGLDisplay, EGLSurface surface, EGLint buffer); EGLBoolean (GLAPIENTRY * fReleaseTexImage)(EGLDisplay, EGLSurface surface, EGLint buffer); + EGLBoolean (GLAPIENTRY * fSwapInterval)(EGLDisplay dpy, EGLint interval); EGLImage (GLAPIENTRY * fCreateImageKHR)(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint* attrib_list); EGLBoolean (GLAPIENTRY * fDestroyImageKHR)(EGLDisplay dpy, EGLImage image); // New extension which allow us to lock texture and get raw image pointer EGLBoolean (GLAPIENTRY * fLockSurfaceKHR)(EGLDisplay dpy, EGLSurface surface, const EGLint* attrib_list); EGLBoolean (GLAPIENTRY * fUnlockSurfaceKHR)(EGLDisplay dpy, EGLSurface surface);
--- a/gfx/gl/GfxTexturesReporter.cpp +++ b/gfx/gl/GfxTexturesReporter.cpp @@ -1,23 +1,20 @@ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* vim: set ts=8 sts=4 et sw=4 tw=80: */ /* 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 <string> #include <sstream> +#include "nsExceptionHandler.h" #include "GfxTexturesReporter.h" #include "gfxPrefs.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - using namespace mozilla; using namespace mozilla::gl; NS_IMPL_ISUPPORTS(GfxTexturesReporter, nsIMemoryReporter) Atomic<size_t> GfxTexturesReporter::sAmount(0); Atomic<size_t> GfxTexturesReporter::sPeakAmount(0); Atomic<size_t> GfxTexturesReporter::sTileWasteAmount(0); @@ -71,12 +68,10 @@ GfxTexturesReporter::UpdateAmount(Memory if (sAmount > sPeakAmount) { sPeakAmount.exchange(sAmount); if (gfxPrefs::GfxLoggingPeakTextureUsageEnabled()) { printf_stderr("Peak texture usage: %s\n", FormatBytes(sPeakAmount).c_str()); } } } -#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateTexturesSize(sAmount); -#endif }
--- a/gfx/ipc/GPUChild.cpp +++ b/gfx/ipc/GPUChild.cpp @@ -139,22 +139,21 @@ GPUChild::RecvGraphicsError(const nsCStr lf->UpdateStringsVector(message.str()); } return IPC_OK(); } mozilla::ipc::IPCResult GPUChild::RecvInitCrashReporter(Shmem&& aShmem, const NativeThreadId& aThreadId) { -#ifdef MOZ_CRASHREPORTER mCrashReporter = MakeUnique<ipc::CrashReporterHost>( GeckoProcessType_GPU, aShmem, aThreadId); -#endif + return IPC_OK(); } mozilla::ipc::IPCResult GPUChild::RecvNotifyUiObservers(const nsCString& aTopic) { nsCOMPtr<nsIObserverService> obsSvc = mozilla::services::GetObserverService(); MOZ_ASSERT(obsSvc); @@ -247,22 +246,20 @@ GPUChild::RecvFinishMemoryReport(const u } return IPC_OK(); } void GPUChild::ActorDestroy(ActorDestroyReason aWhy) { if (aWhy == AbnormalShutdown) { -#ifdef MOZ_CRASHREPORTER if (mCrashReporter) { mCrashReporter->GenerateCrashReport(OtherPid()); mCrashReporter = nullptr; } -#endif Telemetry::Accumulate(Telemetry::SUBPROCESS_ABNORMAL_ABORT, nsDependentCString(XRE_ChildProcessTypeToString(GeckoProcessType_GPU)), 1); // Notify the Telemetry environment so that we can refresh and do a subsession split if (nsCOMPtr<nsIObserverService> obsvc = services::GetObserverService()) { obsvc->NotifyObservers(nullptr, "compositor:process-aborted", nullptr); }
--- a/gfx/ipc/GPUParent.cpp +++ b/gfx/ipc/GPUParent.cpp @@ -95,20 +95,18 @@ GPUParent::Init(base::ProcessId aParentP nsDebugImpl::SetMultiprocessMode("GPU"); // This must be sent before any IPDL message, which may hit sentinel // errors due to parent and content processes having different // versions. GetIPCChannel()->SendBuildID(); -#ifdef MOZ_CRASHREPORTER // Init crash reporter support. CrashReporterClient::InitSingleton(this); -#endif // Ensure gfxPrefs are initialized. gfxPrefs::GetSingleton(); gfxConfig::Init(); gfxVars::Initialize(); gfxPlatform::InitNullMetadata(); // Ensure our Factory is initialised, mainly for gfx logging to work. gfxPlatform::InitMoz2DLogging(); @@ -466,16 +464,14 @@ GPUParent::ActorDestroy(ActorDestroyReas Factory::ShutDown(); #if defined(XP_WIN) DeviceManagerDx::Shutdown(); #endif LayerTreeOwnerTracker::Shutdown(); gfxVars::Shutdown(); gfxConfig::Shutdown(); gfxPrefs::DestroySingleton(); -#ifdef MOZ_CRASHREPORTER CrashReporterClient::DestroySingleton(); -#endif XRE_ShutdownChildProcess(); } } // namespace gfx } // namespace mozilla
--- a/gfx/ipc/GPUProcessManager.cpp +++ b/gfx/ipc/GPUProcessManager.cpp @@ -34,22 +34,19 @@ #include "VRManagerChild.h" #include "VRManagerParent.h" #include "VsyncBridgeChild.h" #include "VsyncIOThreadHolder.h" #include "VsyncSource.h" #include "mozilla/dom/VideoDecoderManagerChild.h" #include "mozilla/dom/VideoDecoderManagerParent.h" #include "MediaPrefs.h" +#include "nsExceptionHandler.h" #include "nsPrintfCString.h" -#ifdef MOZ_CRASHREPORTER -# include "nsExceptionHandler.h" -#endif - #if defined(MOZ_WIDGET_ANDROID) #include "mozilla/widget/AndroidUiThread.h" #include "mozilla/layers/UiCompositorControllerChild.h" #endif // defined(MOZ_WIDGET_ANDROID) namespace mozilla { namespace gfx { @@ -363,25 +360,23 @@ GPUProcessManager::OnProcessLaunchComple if (NS_FAILED(rv)) { DisableGPUProcess("Failed to create PVsyncBridge endpoints"); return; } mVsyncBridge = VsyncBridgeChild::Create(mVsyncIOThread, mProcessToken, Move(vsyncChild)); mGPUChild->SendInitVsyncBridge(Move(vsyncParent)); -#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("GPUProcessStatus"), NS_LITERAL_CSTRING("Running")); CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("GPUProcessLaunchCount"), nsPrintfCString("%d", mNumProcessAttempts)); -#endif } static bool ShouldLimitDeviceResets(uint32_t count, int32_t deltaMilliseconds) { // We decide to limit by comparing the amount of resets that have happened // and time since the last reset to two prefs. int32_t timeLimit = gfxPrefs::DeviceResetThresholdMilliseconds(); @@ -712,21 +707,19 @@ GPUProcessManager::DestroyProcess() mProcessToken = 0; mProcess = nullptr; mGPUChild = nullptr; if (mVsyncBridge) { mVsyncBridge->Close(); mVsyncBridge = nullptr; } -#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("GPUProcessStatus"), NS_LITERAL_CSTRING("Destroyed")); -#endif } already_AddRefed<CompositorSession> GPUProcessManager::CreateTopLevelCompositor(nsBaseWidget* aWidget, LayerManager* aLayerManager, CSSToLayoutDeviceScale aScale, const CompositorOptions& aOptions, bool aUseExternalSurfaceSize,
--- a/gfx/src/DriverCrashGuard.cpp +++ b/gfx/src/DriverCrashGuard.cpp @@ -4,19 +4,17 @@ * 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 "DriverCrashGuard.h" #include "gfxEnv.h" #include "gfxPrefs.h" #include "gfxConfig.h" #include "nsAppDirectoryServiceDefs.h" #include "nsDirectoryServiceUtils.h" -#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" -#endif #include "nsServiceManagerUtils.h" #include "nsString.h" #include "nsXULAppAPI.h" #include "mozilla/Preferences.h" #include "mozilla/Telemetry.h" #include "mozilla/Services.h" #include "mozilla/gfx/Logging.h" #include "mozilla/dom/ContentChild.h" @@ -162,21 +160,19 @@ DriverCrashGuard::~DriverCrashGuard() // proceed to mark the status as okay. if (GetStatus() != DriverInitStatus::Crashed) { SetStatus(DriverInitStatus::Okay); } } else { dom::ContentChild::GetSingleton()->SendEndDriverCrashGuard(uint32_t(mType)); } -#ifdef MOZ_CRASHREPORTER // Remove the crash report annotation. CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("GraphicsStartupTest"), NS_LITERAL_CSTRING("")); -#endif } bool DriverCrashGuard::Crashed() { InitializeIfNeeded(); // Note, we read mCrashDetected instead of GetStatus(), since in child @@ -205,25 +201,23 @@ DriverCrashGuard::GetGuardFile() return file; } void DriverCrashGuard::ActivateGuard() { mGuardActivated = true; -#ifdef MOZ_CRASHREPORTER // Anotate crash reports only if we're a real guard. Otherwise, we could // attribute a random parent process crash to a graphics problem in a child // process. if (mMode != Mode::Proxy) { CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("GraphicsStartupTest"), NS_LITERAL_CSTRING("1")); } -#endif // If we're in the content process, the rest of the guarding is handled // in the parent. if (XRE_IsContentProcess()) { return; } SetStatus(DriverInitStatus::Attempting);
--- a/gfx/src/gfxCrashReporterUtils.cpp +++ b/gfx/src/gfxCrashReporterUtils.cpp @@ -1,22 +1,15 @@ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 "gfxCrashReporterUtils.h" - -#if defined(MOZ_CRASHREPORTER) -#define MOZ_GFXFEATUREREPORTER 1 -#endif - -#ifdef MOZ_GFXFEATUREREPORTER -#include "gfxCrashReporterUtils.h" #include <string.h> // for strcmp #include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2 #include "mozilla/Services.h" // for GetObserverService #include "mozilla/StaticMutex.h" #include "mozilla/SystemGroup.h" // for SystemGroup #include "mozilla/mozalloc.h" // for operator new, etc #include "mozilla/RefPtr.h" // for RefPtr #include "MainThreadUtils.h" // for NS_IsMainThread @@ -132,18 +125,8 @@ ScopedGfxFeatureReporter::AppNote(const CrashReporter::AppendAppNotesToCrashReport(aMessage); } else { nsCOMPtr<nsIRunnable> r = new AppendAppNotesRunnable(aMessage); SystemGroup::Dispatch(TaskCategory::Other, r.forget()); } } } // end namespace mozilla - -#else - -namespace mozilla { -void ScopedGfxFeatureReporter::WriteAppNote(char) {} -void ScopedGfxFeatureReporter::AppNote(const nsACString&) {} - -} // namespace mozilla - -#endif
--- a/gfx/tests/gtest/TestGfxPrefs.cpp +++ b/gfx/tests/gtest/TestGfxPrefs.cpp @@ -76,17 +76,16 @@ TEST(GfxPrefs, Set) { // Once float, default -1 ASSERT_TRUE(gfxPrefs::APZMaxVelocity() == -1.0f); gfxPrefs::SetAPZMaxVelocity(1.75f); ASSERT_TRUE(gfxPrefs::APZMaxVelocity() == 1.75f); gfxPrefs::SetAPZMaxVelocity(-1.0f); ASSERT_TRUE(gfxPrefs::APZMaxVelocity() == -1.0f); } -#ifdef MOZ_CRASHREPORTER // Randomly test the function we use in nsExceptionHandler.cpp here: extern bool SimpleNoCLibDtoA(double aValue, char* aBuffer, int aBufferLength); TEST(GfxPrefs, StringUtility) { char testBuffer[64]; double testVal[] = {13.4, 3324243.42, 0.332424342, @@ -99,9 +98,8 @@ TEST(GfxPrefs, StringUtility) } // We do not like negative numbers (random limitation) ASSERT_FALSE(SimpleNoCLibDtoA(-864.0, testBuffer, sizeof(testBuffer))); // It won't fit into 32: ASSERT_FALSE(SimpleNoCLibDtoA(testVal[4], testBuffer, sizeof(testBuffer)/2)); } -#endif
--- a/gfx/thebes/DeviceManagerDx.cpp +++ b/gfx/thebes/DeviceManagerDx.cpp @@ -16,26 +16,23 @@ #include "mozilla/gfx/GraphicsMessages.h" #include "mozilla/gfx/Logging.h" #include "mozilla/gfx/gfxVars.h" #include "mozilla/layers/CompositorBridgeChild.h" #include "mozilla/layers/CompositorThread.h" #include "mozilla/layers/DeviceAttachmentsD3D11.h" #include "mozilla/layers/MLGDeviceD3D11.h" #include "mozilla/layers/PaintThread.h" +#include "nsExceptionHandler.h" #include "nsIGfxInfo.h" +#include "nsPrintfCString.h" #include "nsString.h" #include <d3d11.h> #include <ddraw.h> -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#include "nsPrintfCString.h" -#endif - namespace mozilla { namespace gfx { using namespace mozilla::widget; using namespace mozilla::layers; StaticAutoPtr<DeviceManagerDx> DeviceManagerDx::sInstance; @@ -767,22 +764,20 @@ DeviceManagerDx::MaybeResetAndReacquireD if (!HasDeviceReset(&resetReason)) { return false; } if (resetReason != DeviceResetReason::FORCED_RESET) { Telemetry::Accumulate(Telemetry::DEVICE_RESET_REASON, uint32_t(resetReason)); } -#ifdef MOZ_CRASHREPORTER nsPrintfCString reasonString("%d", int(resetReason)); CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("DeviceResetReason"), reasonString); -#endif bool createCompositorDevice = !!mCompositorDevice; bool createContentDevice = !!mContentDevice; ResetDevices(); if (createCompositorDevice && !CreateCompositorDevices()) { // Just stop, don't try anything more
--- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -65,26 +65,24 @@ #include "gfxImageSurface.h" #include "nsUnicodeProperties.h" #include "harfbuzz/hb.h" #include "gfxGraphiteShaper.h" #include "gfx2DGlue.h" #include "gfxGradientCache.h" #include "gfxUtils.h" // for NextPowerOfTwo +#include "nsExceptionHandler.h" #include "nsUnicodeRange.h" #include "nsServiceManagerUtils.h" #include "nsTArray.h" #include "nsIObserverService.h" #include "nsIScreenManager.h" #include "FrameMetrics.h" #include "MainThreadUtils.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif #include "nsWeakReference.h" #include "cairo.h" #include "qcms.h" #include "imgITools.h" @@ -293,22 +291,19 @@ void CrashStatsLogForwarder::UpdateCrash logAnnotation = "|[X"; break; } for (auto& it : mBuffer) { message << logAnnotation << Get<0>(it) << "]" << Get<1>(it) << " (t=" << Get<2>(it) << ") "; } -#ifdef MOZ_CRASHREPORTER nsCString reportString(message.str().c_str()); nsresult annotated = CrashReporter::AnnotateCrashReport(mCrashCriticalKey, reportString); -#else - nsresult annotated = NS_ERROR_NOT_IMPLEMENTED; -#endif + if (annotated != NS_OK) { printf("Crash Annotation %s: %s", mCrashCriticalKey.get(), message.str().c_str()); } } class LogForwarderEvent : public Runnable {
--- a/image/VectorImage.cpp +++ b/image/VectorImage.cpp @@ -949,16 +949,23 @@ VectorImage::Draw(gfxContext* aContext, if (!mIsFullyLoaded) { return DrawResult::NOT_READY; } if (mAnimationConsumers == 0) { SendOnUnlockedDraw(aFlags); } + // We should always bypass the cache when using DrawTargetRecording because + // we prefer the drawing commands in general to the rasterized surface. This + // allows blob images to avoid rasterized SVGs with WebRender. + if (aContext->GetDrawTarget()->GetBackendType() == BackendType::RECORDING) { + aFlags |= FLAG_BYPASS_SURFACE_CACHE; + } + MOZ_ASSERT(!(aFlags & FLAG_FORCE_PRESERVEASPECTRATIO_NONE) || (aSVGContext && aSVGContext->GetViewportSize()), "Viewport size is required when using " "FLAG_FORCE_PRESERVEASPECTRATIO_NONE"); float animTime = (aWhichFrame == FRAME_FIRST) ? 0.0f : mSVGDocumentWrapper->GetCurrentTime();
--- a/ipc/glue/CrashReporterClient.cpp +++ b/ipc/glue/CrashReporterClient.cpp @@ -3,17 +3,16 @@ /* 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 "CrashReporterClient.h" #include "CrashReporterMetadataShmem.h" #include "nsISupportsImpl.h" -#ifdef MOZ_CRASHREPORTER namespace mozilla { namespace ipc { StaticMutex CrashReporterClient::sLock; StaticRefPtr<CrashReporterClient> CrashReporterClient::sClientSingleton; CrashReporterClient::CrashReporterClient(const Shmem& aShmem) : mMetadata(new CrashReporterMetadataShmem(aShmem)) @@ -60,9 +59,8 @@ CrashReporterClient::DestroySingleton() CrashReporterClient::GetSingleton() { StaticMutexAutoLock lock(sLock); return sClientSingleton; } } // namespace ipc } // namespace mozilla -#endif // MOZ_CRASHREPORTER
--- a/ipc/glue/CrashReporterClient.h +++ b/ipc/glue/CrashReporterClient.h @@ -7,17 +7,16 @@ #ifndef mozilla_ipc_CrashReporterClient_h #define mozilla_ipc_CrashReporterClient_h #include "mozilla/StaticMutex.h" #include "mozilla/StaticPtr.h" #include "mozilla/Unused.h" #include "mozilla/ipc/Shmem.h" -#ifdef MOZ_CRASHREPORTER namespace mozilla { namespace ipc { class CrashReporterMetadataShmem; class CrashReporterClient { public: @@ -73,12 +72,11 @@ private: static StaticRefPtr<CrashReporterClient> sClientSingleton; private: UniquePtr<CrashReporterMetadataShmem> mMetadata; }; } // namespace ipc } // namespace mozilla -#endif // MOZ_CRASHREPORTER #endif // mozilla_ipc_CrashReporterClient_h
--- a/ipc/glue/CrashReporterHost.cpp +++ b/ipc/glue/CrashReporterHost.cpp @@ -5,37 +5,34 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "CrashReporterHost.h" #include "CrashReporterMetadataShmem.h" #include "mozilla/ipc/GeckoChildProcessHost.h" #include "mozilla/Sprintf.h" #include "mozilla/SyncRunnable.h" #include "mozilla/Telemetry.h" -#ifdef MOZ_CRASHREPORTER -# include "nsExceptionHandler.h" -# include "nsIAsyncShutdown.h" -# include "nsICrashService.h" -#endif +#include "nsExceptionHandler.h" +#include "nsIAsyncShutdown.h" +#include "nsICrashService.h" namespace mozilla { namespace ipc { CrashReporterHost::CrashReporterHost(GeckoProcessType aProcessType, const Shmem& aShmem, ThreadId aThreadId) : mProcessType(aProcessType), mShmem(aShmem), mThreadId(aThreadId), mStartTime(::time(nullptr)), mFinalized(false) { } -#ifdef MOZ_CRASHREPORTER bool CrashReporterHost::GenerateCrashReport(base::ProcessId aPid) { if (!TakeCrashedChildMinidump(aPid, nullptr)) { return false; } return FinalizeCrashReport(); } @@ -283,12 +280,11 @@ CrashReporterHost::NotifyCrashService(Ge Telemetry::Accumulate(Telemetry::SUBPROCESS_CRASHES_WITH_DUMP, telemetryKey, 1); } void CrashReporterHost::AddNote(const nsCString& aKey, const nsCString& aValue) { mExtraNotes.Put(aKey, aValue); } -#endif } // namespace ipc } // namespace mozilla
--- a/ipc/glue/CrashReporterHost.h +++ b/ipc/glue/CrashReporterHost.h @@ -7,41 +7,34 @@ #ifndef mozilla_ipc_CrashReporterHost_h #define mozilla_ipc_CrashReporterHost_h #include <functional> #include "mozilla/UniquePtr.h" #include "mozilla/ipc/Shmem.h" #include "base/process.h" -#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" -#endif #include "nsThreadUtils.h" namespace mozilla { namespace ipc { class GeckoChildProcessHost; // This is the newer replacement for CrashReporterParent. It is created in // response to a InitCrashReporter message on a top-level actor, and simply // holds the metadata shmem alive until the process ends. When the process // terminates abnormally, the top-level should call GenerateCrashReport to // automatically integrate metadata. class CrashReporterHost { typedef mozilla::ipc::Shmem Shmem; -#ifdef MOZ_CRASHREPORTER typedef CrashReporter::AnnotationTable AnnotationTable; typedef CrashReporter::ThreadId ThreadId; -#else - // unused in this case - typedef int32_t ThreadId; -#endif public: template <typename T> class CallbackWrapper { public: void Init(std::function<void(T)>&& aCallback, bool aAsync) { @@ -94,17 +87,16 @@ public: std::function<void(T)> mCallback; nsCOMPtr<nsIThread> mTargetThread; }; CrashReporterHost(GeckoProcessType aProcessType, const Shmem& aShmem, ThreadId aThreadId); -#ifdef MOZ_CRASHREPORTER // Helper function for generating a crash report for a process that probably // crashed (i.e., had an AbnormalShutdown in ActorDestroy). Returns true if // the process has a minidump attached and we were able to generate a report. bool GenerateCrashReport(base::ProcessId aPid); // Given an existing minidump for a crashed child process, take ownership of // it from IPDL. After this, FinalizeCrashReport may be called. RefPtr<nsIFile> TakeCrashedChildMinidump(base::ProcessId aPid, uint32_t* aOutSequence); @@ -144,31 +136,28 @@ public: bool HasMinidump() const { return !mDumpID.IsEmpty(); } const nsString& MinidumpID() const { MOZ_ASSERT(HasMinidump()); return mDumpID; } -#endif private: static void AsyncAddCrash(int32_t aProcessType, int32_t aCrashType, const nsString& aChildDumpID); private: CallbackWrapper<bool> mCreateMinidumpCallback; GeckoProcessType mProcessType; Shmem mShmem; ThreadId mThreadId; time_t mStartTime; -#ifdef MOZ_CRASHREPORTER AnnotationTable mExtraNotes; -#endif nsString mDumpID; bool mFinalized; nsCOMPtr<nsIFile> mTargetDump; }; } // namespace ipc } // namespace mozilla
--- a/ipc/glue/CrashReporterMetadataShmem.cpp +++ b/ipc/glue/CrashReporterMetadataShmem.cpp @@ -203,17 +203,16 @@ private: } private: const uint8_t* mCursor; const uint8_t* mEnd; EntryType mEntryType; }; -#ifdef MOZ_CRASHREPORTER void CrashReporterMetadataShmem::ReadAppNotes(const Shmem& aShmem, CrashReporter::AnnotationTable* aNotes) { for (MetadataShmemReader reader(aShmem); !reader.Done(); reader.Next()) { switch (reader.Type()) { case EntryType::Annotation: { nsCString key, value; if (!reader.Read(key) || !reader.Read(value)) { @@ -224,12 +223,11 @@ CrashReporterMetadataShmem::ReadAppNotes break; } default: NS_ASSERTION(false, "Unknown metadata entry type"); break; } } } -#endif } // namespace ipc } // namespace mozilla
--- a/ipc/glue/CrashReporterMetadataShmem.h +++ b/ipc/glue/CrashReporterMetadataShmem.h @@ -23,19 +23,17 @@ class CrashReporterMetadataShmem public: explicit CrashReporterMetadataShmem(const Shmem& aShmem); ~CrashReporterMetadataShmem(); // Metadata writers. These must only be called in child processes. void AnnotateCrashReport(const nsCString& aKey, const nsCString& aData); void AppendAppNotes(const nsCString& aData); -#ifdef MOZ_CRASHREPORTER static void ReadAppNotes(const Shmem& aShmem, CrashReporter::AnnotationTable* aNotes); -#endif private: void SyncNotesToShmem(); private: Shmem mShmem; AnnotationTable mNotes;
--- a/ipc/glue/GeckoChildProcessHost.cpp +++ b/ipc/glue/GeckoChildProcessHost.cpp @@ -219,21 +219,19 @@ uint32_t GeckoChildProcessHost::GetUniqueID() { return sNextUniqueID++; } void GeckoChildProcessHost::PrepareLaunch() { -#ifdef MOZ_CRASHREPORTER if (CrashReporter::GetEnabled()) { CrashReporter::OOPInit(); } -#endif #if defined(XP_LINUX) && defined(MOZ_SANDBOX) SandboxLaunchPrepare(mProcessType, mLaunchOptions.get()); #endif #ifdef XP_WIN if (mProcessType == GeckoProcessType_Plugin) { InitWindowsGroupID(); @@ -750,48 +748,47 @@ GeckoChildProcessHost::PerformAsyncLaunc // Add the application directory path (-appdir path) AddAppDirToCommandLine(childArgv); // Tmp dir that the GPU process should use for crash reports. This arg is // always populated (but possibly with an empty value) for a GPU child process. if (mProcessType == GeckoProcessType_GPU) { nsCOMPtr<nsIFile> file; -# ifdef MOZ_CRASHREPORTER CrashReporter::GetChildProcessTmpDir(getter_AddRefs(file)); -# endif // MOZ_CRASHREPORTER nsAutoCString path; if (file) { file->GetNativePath(path); } childArgv.push_back(path.get()); } childArgv.push_back(pidstring); -# if defined(MOZ_CRASHREPORTER) -# if defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS) - int childCrashFd, childCrashRemapFd; - if (!CrashReporter::CreateNotificationPipeForChild( - &childCrashFd, &childCrashRemapFd)) - return false; - if (0 <= childCrashFd) { - mLaunchOptions->fds_to_remap - .push_back(std::pair<int,int>(childCrashFd, childCrashRemapFd)); - // "true" == crash reporting enabled - childArgv.push_back("true"); + if (!CrashReporter::IsDummy()) { +#if defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS) + int childCrashFd, childCrashRemapFd; + if (!CrashReporter::CreateNotificationPipeForChild(&childCrashFd, + &childCrashRemapFd)) { + return false; + } + + if (0 <= childCrashFd) { + mLaunchOptions->fds_to_remap + .push_back(std::pair<int,int>(childCrashFd, childCrashRemapFd)); + // "true" == crash reporting enabled + childArgv.push_back("true"); + } else { + // "false" == crash reporting disabled + childArgv.push_back("false"); + } +#elif defined(MOZ_WIDGET_COCOA) // defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS) + childArgv.push_back(CrashReporter::GetChildNotificationPipe()); +#endif // defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS) } - else { - // "false" == crash reporting disabled - childArgv.push_back("false"); - } -# elif defined(MOZ_WIDGET_COCOA) // defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS) - childArgv.push_back(CrashReporter::GetChildNotificationPipe()); -# endif // defined(OS_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS) -# endif // defined(MOZ_CRASHREPORTER) # ifdef MOZ_WIDGET_COCOA // Add a mach port to the command line so the child can communicate its // 'task_t' back to the parent. // // Put a random number into the channel name, so that a compromised renderer // can't pretend being the child that's forked off. std::string mach_connection_name = StringPrintf("org.mozilla.machname.%d", @@ -995,34 +992,30 @@ GeckoChildProcessHost::PerformAsyncLaunc // Win app model id cmdLine.AppendLooseValue(mGroupId.get()); // Tmp dir that the GPU process should use for crash reports. This arg is // always populated (but possibly with an empty value) for a GPU child process. if (mProcessType == GeckoProcessType_GPU) { nsCOMPtr<nsIFile> file; -# ifdef MOZ_CRASHREPORTER CrashReporter::GetChildProcessTmpDir(getter_AddRefs(file)); -# endif // MOZ_CRASHREPORTER nsString path; if (file) { MOZ_ALWAYS_SUCCEEDS(file->GetPath(path)); } std::wstring wpath(path.get()); cmdLine.AppendLooseValue(wpath); } // Process id cmdLine.AppendLooseValue(UTF8ToWide(pidstring)); -# if defined(MOZ_CRASHREPORTER) cmdLine.AppendLooseValue( UTF8ToWide(CrashReporter::GetChildNotificationPipe())); -# endif // defined(MOZ_CRASHREPORTER) // Process type cmdLine.AppendLooseValue(UTF8ToWide(childProcessType)); # if defined(XP_WIN) && defined(MOZ_SANDBOX) if (shouldSandboxCurrentProcess) { if (mSandboxBroker.LaunchApp(cmdLine.program().c_str(), cmdLine.command_line_string().c_str(),
--- a/ipc/glue/IPCMessageUtils.h +++ b/ipc/glue/IPCMessageUtils.h @@ -20,19 +20,17 @@ #ifdef XP_WIN #include "mozilla/TimeStamp_windows.h" #endif #include "mozilla/TypeTraits.h" #include "mozilla/IntegerTypeTraits.h" #include <stdint.h> -#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" -#endif #include "nsID.h" #include "nsIWidget.h" #include "nsMemory.h" #include "nsString.h" #include "nsTArray.h" #include "js/StructuredClone.h" #include "nsCSSPropertyID.h" @@ -122,26 +120,22 @@ struct EnumSerializer { static void Write(Message* aMsg, const paramType& aValue) { MOZ_RELEASE_ASSERT(EnumValidator::IsLegalValue(aValue)); WriteParam(aMsg, uintParamType(aValue)); } static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { uintParamType value; if (!ReadParam(aMsg, aIter, &value)) { -#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCReadErrorReason"), NS_LITERAL_CSTRING("Bad iter")); -#endif return false; } else if (!EnumValidator::IsLegalValue(paramType(value))) { -#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCReadErrorReason"), NS_LITERAL_CSTRING("Illegal value")); -#endif return false; } *aResult = paramType(value); return true; } }; template <typename E,
--- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -669,20 +669,18 @@ MessageChannel::CanSend() const MonitorAutoLock lock(*mMonitor); return Connected(); } void MessageChannel::WillDestroyCurrentMessageLoop() { #if defined(DEBUG) -#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ProtocolName"), nsDependentCString(mName)); -#endif MOZ_CRASH("MessageLoop destroyed before MessageChannel that's bound to it"); #endif // Clear mWorkerThread to avoid posting to it in the future. MonitorAutoLock lock(*mMonitor); mWorkerLoop = nullptr; } @@ -696,20 +694,18 @@ MessageChannel::Clear() // through this channel after it's Clear()'ed can cause this process to // crash. // // In practice, mListener owns the channel, so the channel gets deleted // before mListener. But just to be safe, mListener is a weak pointer. #if !defined(ANDROID) if (!Unsound_IsClosed()) { -#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ProtocolName"), nsDependentCString(mName)); -#endif MOZ_CRASH("MessageChannel destroyed without being closed"); } #endif if (gParentProcessBlocker == this) { gParentProcessBlocker = nullptr; }
--- a/ipc/glue/MessageLink.cpp +++ b/ipc/glue/MessageLink.cpp @@ -9,19 +9,17 @@ #include "mozilla/ipc/MessageChannel.h" #include "mozilla/ipc/BrowserProcessSubThread.h" #include "mozilla/ipc/ProtocolUtils.h" #include "chrome/common/ipc_channel.h" #include "mozilla/Assertions.h" #include "mozilla/DebugOnly.h" #include "nsDebug.h" -#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" -#endif #include "nsISupportsImpl.h" #include "nsPrintfCString.h" #include "nsXULAppAPI.h" using namespace mozilla; using namespace std; // We rely on invariants about the lifetime of the transport: @@ -156,20 +154,18 @@ ProcessLink::EchoMessage(Message *msg) msg)); // OnEchoMessage takes ownership of |msg| } void ProcessLink::SendMessage(Message *msg) { if (msg->size() > IPC::Channel::kMaximumMessageSize) { -#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCMessageName"), nsDependentCString(msg->name())); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCMessageSize"), nsPrintfCString("%d", msg->size())); -#endif MOZ_CRASH("IPC message size is too large"); } if (!mChan->mIsPostponingSends) { mChan->AssertWorkerThread(); } mChan->mMonitor->AssertCurrentThreadOwns();
--- a/ipc/glue/ProtocolUtils.cpp +++ b/ipc/glue/ProtocolUtils.cpp @@ -23,34 +23,34 @@ #include "mozilla/Unused.h" #include "nsPrintfCString.h" #if defined(MOZ_SANDBOX) && defined(XP_WIN) #define TARGET_SANDBOX_EXPORTS #include "mozilla/sandboxTarget.h" #endif -#if defined(MOZ_CRASHREPORTER) && defined(XP_WIN) +#if defined(XP_WIN) #include "aclapi.h" #include "sddl.h" #include "mozilla/TypeTraits.h" #endif #include "nsAutoPtr.h" using namespace IPC; using base::GetCurrentProcId; using base::ProcessHandle; using base::ProcessId; namespace mozilla { -#if defined(MOZ_CRASHREPORTER) && defined(XP_WIN) +#if defined(XP_WIN) // Generate RAII classes for LPTSTR and PSECURITY_DESCRIPTOR. MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedLPTStr, \ RemovePointer<LPTSTR>::Type, \ ::LocalFree) MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPSecurityDescriptor, \ RemovePointer<PSECURITY_DESCRIPTOR>::Type, \ ::LocalFree) #endif @@ -204,49 +204,45 @@ bool DuplicateHandle(HANDLE aSourceHandl } #endif // Finally, see if we already have access to the process. ScopedProcessHandle targetProcess(OpenProcess(PROCESS_DUP_HANDLE, FALSE, aTargetProcessId)); if (!targetProcess) { -#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("IPCTransportFailureReason"), NS_LITERAL_CSTRING("Failed to open target process.")); -#endif return false; } return !!::DuplicateHandle(::GetCurrentProcess(), aSourceHandle, targetProcess, aTargetHandle, aDesiredAccess, FALSE, aOptions); } #endif -#ifdef MOZ_CRASHREPORTER void AnnotateSystemError() { int64_t error = 0; #if defined(XP_WIN) error = ::GetLastError(); #elif defined(OS_POSIX) error = errno; #endif if (error) { CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("IPCSystemError"), nsPrintfCString("%" PRId64, error)); } } -#endif -#if defined(MOZ_CRASHREPORTER) && defined(XP_MACOSX) +#if defined(XP_MACOSX) void AnnotateCrashReportWithErrno(const char* tag, int error) { CrashReporter::AnnotateCrashReport( nsCString(tag), nsPrintfCString("%d", error)); } #endif @@ -283,28 +279,26 @@ FatalError(const char* aProtocolName, co { ProtocolErrorBreakpoint(aMsg); nsAutoCString formattedMessage("IPDL error ["); formattedMessage.AppendASCII(aProtocolName); formattedMessage.AppendLiteral("]: \""); formattedMessage.AppendASCII(aMsg); if (aIsParent) { -#ifdef MOZ_CRASHREPORTER // We're going to crash the parent process because at this time // there's no other really nice way of getting a minidump out of // this process if we're off the main thread. formattedMessage.AppendLiteral("\". Intentionally crashing."); NS_ERROR(formattedMessage.get()); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCFatalErrorProtocol"), nsDependentCString(aProtocolName)); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("IPCFatalErrorMsg"), nsDependentCString(aMsg)); AnnotateSystemError(); -#endif MOZ_CRASH("IPC FatalError in the parent process!"); } else { formattedMessage.AppendLiteral("\". abort()ing as a result."); MOZ_CRASH_UNSAFE_OOL(formattedMessage.get()); } } void @@ -612,21 +606,17 @@ IToplevelProtocol::SetOtherProcessId(bas { mOtherPid = aOtherPid; } bool IToplevelProtocol::TakeMinidump(nsIFile** aDump, uint32_t* aSequence) { MOZ_RELEASE_ASSERT(GetSide() == ParentSide); -#ifdef MOZ_CRASHREPORTER return XRE_TakeMinidumpForChild(OtherPid(), aDump, aSequence); -#else - return false; -#endif } bool IToplevelProtocol::Open(mozilla::ipc::Transport* aTransport, base::ProcessId aOtherPid, MessageLoop* aThread, mozilla::ipc::Side aSide) {
--- a/ipc/glue/ProtocolUtils.h +++ b/ipc/glue/ProtocolUtils.h @@ -568,21 +568,17 @@ DuplicateHandle(HANDLE aSourceHandle, DWORD aDesiredAccess, DWORD aOptions); #endif /** * Annotate the crash reporter with the error code from the most recent system * call. Returns the system error. */ -#ifdef MOZ_CRASHREPORTER void AnnotateSystemError(); -#else -#define AnnotateSystemError() do { } while (0) -#endif /** * An endpoint represents one end of a partially initialized IPDL channel. To * set up a new top-level protocol: * * Endpoint<PFooParent> parentEp; * Endpoint<PFooChild> childEp; * nsresult rv; @@ -691,17 +687,17 @@ private: Endpoint& operator=(const Endpoint&) = delete; bool mValid; mozilla::ipc::Transport::Mode mMode; TransportDescriptor mTransport; ProcessId mMyPid, mOtherPid; }; -#if defined(MOZ_CRASHREPORTER) && defined(XP_MACOSX) +#if defined(XP_MACOSX) void AnnotateCrashReportWithErrno(const char* tag, int error); #else static inline void AnnotateCrashReportWithErrno(const char* tag, int error) {} #endif // This function is used internally to create a pair of Endpoints. See the // comment above Endpoint for a description of how it might be used.
--- a/ipc/ipdl/ipdl/lower.py +++ b/ipc/ipdl/ipdl/lower.py @@ -2561,23 +2561,16 @@ class _GenerateProtocolActorCode(ipdl.as cf.addthings([ _DISCLAIMER, Whitespace.NL, CppDirective( 'include', '"'+ _protocolHeaderName(self.protocol, self.side) +'.h"') ] + setToIncludes(self.externalIncludes)) - if self.protocol.decl.type.isToplevel(): - cf.addthings([ - CppDirective('ifdef', 'MOZ_CRASHREPORTER'), - CppDirective(' include', '"nsXULAppAPI.h"'), - CppDirective('endif') - ]) - cppheaders = [CppDirective('include', '"%s"' % filename) for filename in ipdl.builtin.CppIncludes] cf.addthings(( [ Whitespace.NL ] + [ CppDirective( 'include', '"%s.h"' % (inc)) for inc in self.protocolCxxIncludes ]
--- a/ipc/mscom/COMPtrHolder.h +++ b/ipc/mscom/COMPtrHolder.h @@ -11,19 +11,17 @@ #include "mozilla/Attributes.h" #include "mozilla/DebugOnly.h" #include "mozilla/Move.h" #include "mozilla/mscom/ProxyStream.h" #include "mozilla/mscom/Ptr.h" #if defined(MOZ_CONTENT_SANDBOX) #include "mozilla/SandboxSettings.h" #endif // defined(MOZ_CONTENT_SANDBOX) -#if defined(MOZ_CRASHREPORTER) #include "nsExceptionHandler.h" -#endif // defined(MOZ_CRASHREPORTER) namespace mozilla { namespace mscom { template<typename Interface, const IID& _IID> class COMPtrHolder { public: @@ -207,20 +205,18 @@ struct ParamTraits<mozilla::mscom::COMPt return false; } } paramType::EnvType env; mozilla::mscom::ProxyStream proxyStream(_IID, buf.get(), length, &env); if (!proxyStream.IsValid()) { -#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ProxyStreamValid"), NS_LITERAL_CSTRING("false")); -#endif // defined(MOZ_CRASHREPORTER) return false; } typename paramType::COMPtrType ptr; if (!proxyStream.GetInterface(mozilla::mscom::getter_AddRefs(ptr))) { return false; }
--- a/ipc/mscom/Interceptor.cpp +++ b/ipc/mscom/Interceptor.cpp @@ -17,43 +17,31 @@ #include "mozilla/mscom/Registration.h" #include "mozilla/mscom/Utils.h" #include "mozilla/ThreadLocal.h" #include "MainThreadUtils.h" #include "mozilla/Assertions.h" #include "mozilla/DebugOnly.h" #include "nsDirectoryServiceDefs.h" #include "nsDirectoryServiceUtils.h" +#include "nsExceptionHandler.h" +#include "nsPrintfCString.h" #include "nsRefPtrHashtable.h" #include "nsThreadUtils.h" #include "nsXULAppAPI.h" -#if defined(MOZ_CRASHREPORTER) - -#include "nsExceptionHandler.h" -#include "nsPrintfCString.h" - #define ENSURE_HR_SUCCEEDED(hr) \ if (FAILED((HRESULT)hr)) { \ nsPrintfCString location("ENSURE_HR_SUCCEEDED \"%s\": %u", __FILE__, __LINE__); \ nsPrintfCString hrAsStr("0x%08X", (HRESULT)hr); \ CrashReporter::AnnotateCrashReport(location, hrAsStr); \ MOZ_DIAGNOSTIC_ASSERT(SUCCEEDED((HRESULT)hr)); \ return hr; \ } -#else - -#define ENSURE_HR_SUCCEEDED(hr) \ - if (FAILED((HRESULT)hr)) { \ - return hr; \ - } - -#endif // defined(MOZ_CRASHREPORTER) - namespace mozilla { namespace mscom { namespace detail { class LiveSet final { public: LiveSet()
--- a/ipc/mscom/MainThreadRuntime.cpp +++ b/ipc/mscom/MainThreadRuntime.cpp @@ -8,19 +8,19 @@ #if defined(ACCESSIBILITY) #include "mozilla/a11y/Compatibility.h" #endif #include "mozilla/ArrayUtils.h" #include "mozilla/Assertions.h" #include "mozilla/RefPtr.h" #include "mozilla/UniquePtr.h" -#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) +#if defined(ACCESSIBILITY) #include "nsExceptionHandler.h" -#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) +#endif // defined(ACCESSIBILITY) #include "nsWindowsHelpers.h" #include "nsXULAppAPI.h" #include <accctrl.h> #include <aclapi.h> #include <objbase.h> #include <objidl.h> @@ -45,32 +45,32 @@ namespace mscom { MainThreadRuntime* MainThreadRuntime::sInstance = nullptr; MainThreadRuntime::MainThreadRuntime() : mInitResult(E_UNEXPECTED) #if defined(ACCESSIBILITY) , mActCtxRgn(a11y::Compatibility::GetActCtxResourceId()) #endif // defined(ACCESSIBILITY) { -#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) +#if defined(ACCESSIBILITY) GeckoProcessType procType = XRE_GetProcessType(); if (procType == GeckoProcessType_Default || procType == GeckoProcessType_Content) { auto actctx = ActivationContext::GetCurrent(); nsAutoCString strActCtx; if (actctx.isOk()) { strActCtx.AppendPrintf("0x%p", actctx.unwrap()); } else { strActCtx.AppendPrintf("HRESULT 0x%08X", actctx.unwrapErr()); } CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AssemblyManifestCtx"), strActCtx); } -#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) +#endif // defined(ACCESSIBILITY) // We must be the outermost COM initialization on this thread. The COM runtime // cannot be configured once we start manipulating objects MOZ_ASSERT(mStaRegion.IsValidOutermost()); if (NS_WARN_IF(!mStaRegion.IsValidOutermost())) { return; }
--- a/ipc/mscom/ProxyStream.cpp +++ b/ipc/mscom/ProxyStream.cpp @@ -1,31 +1,29 @@ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 "mozilla/Move.h" -#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) +#if defined(ACCESSIBILITY) #include "HandlerData.h" #include "mozilla/a11y/Platform.h" #include "mozilla/mscom/ActivationContext.h" -#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) +#endif // defined(ACCESSIBILITY) #include "mozilla/mscom/EnsureMTA.h" #include "mozilla/mscom/ProxyStream.h" #include "mozilla/mscom/Utils.h" #include "mozilla/ScopeExit.h" -#if defined(MOZ_CRASHREPORTER) #include "mozilla/mscom/Objref.h" #include "nsExceptionHandler.h" #include "nsPrintfCString.h" #include "RegistrationAnnotator.h" -#endif #include <windows.h> #include <objbase.h> #include <shlwapi.h> namespace mozilla { namespace mscom { @@ -41,68 +39,60 @@ ProxyStream::ProxyStream() // reconstructing the stream from a buffer anyway. ProxyStream::ProxyStream(REFIID aIID, const BYTE* aInitBuf, const int aInitBufSize, Environment* aEnv) : mGlobalLockedBuf(nullptr) , mHGlobal(nullptr) , mBufSize(aInitBufSize) , mPreserveStream(false) { -#if defined(MOZ_CRASHREPORTER) NS_NAMED_LITERAL_CSTRING(kCrashReportKey, "ProxyStreamUnmarshalStatus"); -#endif if (!aInitBufSize) { -#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(kCrashReportKey, NS_LITERAL_CSTRING("!aInitBufSize")); -#endif // defined(MOZ_CRASHREPORTER) // We marshaled a nullptr. Nothing else to do here. return; } HRESULT createStreamResult = CreateStream(aInitBuf, aInitBufSize, getter_AddRefs(mStream)); if (FAILED(createStreamResult)) { -#if defined(MOZ_CRASHREPORTER) nsPrintfCString hrAsStr("0x%08X", createStreamResult); CrashReporter::AnnotateCrashReport(kCrashReportKey, hrAsStr); -#endif // defined(MOZ_CRASHREPORTER) return; } // NB: We can't check for a null mStream until after we have checked for // the zero aInitBufSize above. This is because InitStream will also fail // in that case, even though marshaling a nullptr is allowable. MOZ_ASSERT(mStream); if (!mStream) { -#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(kCrashReportKey, NS_LITERAL_CSTRING("!mStream")); -#endif // defined(MOZ_CRASHREPORTER) return; } -#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) +#if defined(ACCESSIBILITY) const uint32_t expectedStreamLen = GetOBJREFSize(WrapNotNull(mStream)); nsAutoCString strActCtx; nsAutoString manifestPath; -#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) +#endif // defined(ACCESSIBILITY) HRESULT unmarshalResult = S_OK; // We need to convert to an interface here otherwise we mess up const // correctness with IPDL. We'll request an IUnknown and then QI the // actual interface later. -#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) +#if defined(ACCESSIBILITY) auto marshalFn = [this, &strActCtx, &manifestPath, &unmarshalResult, &aIID, aEnv]() -> void #else auto marshalFn = [this, &unmarshalResult, &aIID, aEnv]() -> void -#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) +#endif // defined(ACCESSIBILITY) { if (aEnv) { bool pushOk = aEnv->Push(); MOZ_DIAGNOSTIC_ASSERT(pushOk); if (!pushOk) { return; } } @@ -111,26 +101,26 @@ ProxyStream::ProxyStream(REFIID aIID, co if (!aEnv) { return; } bool popOk = aEnv->Pop(); MOZ_DIAGNOSTIC_ASSERT(popOk); }); -#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) +#if defined(ACCESSIBILITY) auto curActCtx = ActivationContext::GetCurrent(); if (curActCtx.isOk()) { strActCtx.AppendPrintf("0x%p", curActCtx.unwrap()); } else { strActCtx.AppendPrintf("HRESULT 0x%08X", curActCtx.unwrapErr()); } ActivationContext::GetCurrentManifestPath(manifestPath); -#endif // defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) +#endif // defined(ACCESSIBILITY) unmarshalResult = ::CoUnmarshalInterface(mStream, aIID, getter_AddRefs(mUnmarshaledProxy)); MOZ_ASSERT(SUCCEEDED(unmarshalResult)); }; if (XRE_IsParentProcess()) { // We'll marshal this stuff directly using the current thread, therefore its @@ -138,17 +128,16 @@ ProxyStream::ProxyStream(REFIID aIID, co marshalFn(); } else { // When marshaling in child processes, we want to force the MTA. EnsureMTA mta(marshalFn); } mStream = nullptr; -#if defined(MOZ_CRASHREPORTER) if (FAILED(unmarshalResult) || !mUnmarshaledProxy) { nsPrintfCString hrAsStr("0x%08X", unmarshalResult); CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("CoUnmarshalInterfaceResult"), hrAsStr); AnnotateInterfaceRegistration(aIID); if (!mUnmarshaledProxy) { CrashReporter::AnnotateCrashReport(kCrashReportKey, NS_LITERAL_CSTRING("!mUnmarshaledProxy")); @@ -171,17 +160,16 @@ ProxyStream::ProxyStream(REFIID aIID, co strExpectedStreamLen); nsAutoCString actualStreamLen; actualStreamLen.AppendInt(aInitBufSize); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ActualStreamLen"), actualStreamLen); #endif // defined(ACCESSIBILITY) } -#endif // defined(MOZ_CRASHREPORTER) } ProxyStream::ProxyStream(ProxyStream&& aOther) : mGlobalLockedBuf(nullptr) , mHGlobal(nullptr) , mBufSize(0) , mPreserveStream(false) { @@ -303,27 +291,21 @@ ProxyStream::ProxyStream(REFIID aIID, IU int streamSize = 0; DWORD mshlFlags = mPreserveStream ? MSHLFLAGS_TABLESTRONG : MSHLFLAGS_NORMAL; HRESULT createStreamResult = S_OK; HRESULT marshalResult = S_OK; HRESULT statResult = S_OK; HRESULT getHGlobalResult = S_OK; -#if defined(MOZ_CRASHREPORTER) nsAutoString manifestPath; auto marshalFn = [this, &aIID, aObject, mshlFlags, &stream, &streamSize, &hglobal, &createStreamResult, &marshalResult, &statResult, &getHGlobalResult, aEnv, &manifestPath]() -> void -#else - auto marshalFn = [this, &aIID, aObject, mshlFlags, &stream, &streamSize, - &hglobal, &createStreamResult, &marshalResult, &statResult, - &getHGlobalResult, aEnv]() -> void -#endif // defined(MOZ_CRASHREPORTER) { if (aEnv) { bool pushOk = aEnv->Push(); MOZ_DIAGNOSTIC_ASSERT(pushOk); if (!pushOk) { return; } } @@ -338,19 +320,19 @@ ProxyStream::ProxyStream(REFIID aIID, IU }); createStreamResult = ::CreateStreamOnHGlobal(nullptr, TRUE, getter_AddRefs(stream)); if (FAILED(createStreamResult)) { return; } -#if defined(ACCESSIBILITY) && defined(MOZ_CRASHREPORTER) +#if defined(ACCESSIBILITY) ActivationContext::GetCurrentManifestPath(manifestPath); -#endif // defined(MOZ_CRASHREPORTER) +#endif // defined(ACCESSIBILITY) marshalResult = ::CoMarshalInterface(stream, aIID, aObject, MSHCTX_LOCAL, nullptr, mshlFlags); MOZ_DIAGNOSTIC_ASSERT(marshalResult != E_INVALIDARG); if (FAILED(marshalResult)) { return; } @@ -370,17 +352,16 @@ ProxyStream::ProxyStream(REFIID aIID, IU // We'll marshal this stuff directly using the current thread, therefore its // stub will reside in the same apartment as the current thread. marshalFn(); } else { // When marshaling in child processes, we want to force the MTA. EnsureMTA mta(marshalFn); } -#if defined(MOZ_CRASHREPORTER) if (FAILED(createStreamResult)) { nsPrintfCString hrAsStr("0x%08X", createStreamResult); CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("CreateStreamOnHGlobalFailure"), hrAsStr); } if (FAILED(marshalResult)) { @@ -400,50 +381,43 @@ ProxyStream::ProxyStream(REFIID aIID, IU } if (FAILED(getHGlobalResult)) { nsPrintfCString hrAsStr("0x%08X", getHGlobalResult); CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("GetHGlobalFromStreamFailure"), hrAsStr); } -#endif // defined(MOZ_CRASHREPORTER) mStream = mozilla::Move(stream); if (streamSize) { -#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ProxyStreamSizeFrom"), NS_LITERAL_CSTRING("IStream::Stat")); -#endif // defined(MOZ_CRASHREPORTER) mBufSize = streamSize; } if (!hglobal) { return; } mGlobalLockedBuf = reinterpret_cast<BYTE*>(::GlobalLock(hglobal)); mHGlobal = hglobal; // If we couldn't get the stream size directly from mStream, we may use // the size of the memory block allocated by the HGLOBAL, though it might // be larger than the actual stream size. if (!streamSize) { -#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ProxyStreamSizeFrom"), NS_LITERAL_CSTRING("GlobalSize")); -#endif // defined(MOZ_CRASHREPORTER) mBufSize = static_cast<int>(::GlobalSize(hglobal)); } -#if defined(MOZ_CRASHREPORTER) nsAutoCString strBufSize; strBufSize.AppendInt(mBufSize); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ProxyStreamSize"), strBufSize); -#endif // defined(MOZ_CRASHREPORTER) } } // namespace mscom } // namespace mozilla
--- a/ipc/mscom/RegistrationAnnotator.h +++ b/ipc/mscom/RegistrationAnnotator.h @@ -2,20 +2,16 @@ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */ #ifndef mozilla_mscom_RegistrationAnnotator_h #define mozilla_mscom_RegistrationAnnotator_h -#if !defined(MOZ_CRASHREPORTER) -#error "This header requires crash reporting to be enabled" -#endif - namespace mozilla { namespace mscom { void AnnotateInterfaceRegistration(REFIID aIid); void AnnotateClassRegistration(REFCLSID aClsid); } // namespace mscom } // namespace mozilla
--- a/ipc/mscom/moz.build +++ b/ipc/mscom/moz.build @@ -27,24 +27,20 @@ SOURCES += [ UNIFIED_SOURCES += [ 'AgileReference.cpp', 'EnsureMTA.cpp', 'MainThreadClientInfo.cpp', 'MainThreadRuntime.cpp', 'Objref.cpp', 'PassthruProxy.cpp', 'ProxyStream.cpp', + 'RegistrationAnnotator.cpp', 'Utils.cpp', ] -if CONFIG['MOZ_CRASHREPORTER']: - UNIFIED_SOURCES += [ - 'RegistrationAnnotator.cpp', - ] - if CONFIG['ACCESSIBILITY']: DIRS += [ 'oop', ] EXPORTS.mozilla.mscom += [ 'ActivationContext.h', 'DispatchForwarder.h',
--- a/js/src/frontend/FullParseHandler.h +++ b/js/src/frontend/FullParseHandler.h @@ -629,16 +629,22 @@ class FullParseHandler ParseNode* newFunctionExpression(const TokenPos& pos) { return new_<CodeNode>(PNK_FUNCTION, JSOP_LAMBDA, pos); } ParseNode* newArrowFunction(const TokenPos& pos) { return new_<CodeNode>(PNK_FUNCTION, JSOP_LAMBDA_ARROW, pos); } + bool isExpressionClosure(ParseNode* node) const { + return node->isKind(PNK_FUNCTION) && + node->pn_funbox->isExprBody() && + !node->pn_funbox->isArrow(); + } + void setFunctionFormalParametersAndBody(ParseNode* pn, ParseNode* kid) { MOZ_ASSERT_IF(kid, kid->isKind(PNK_PARAMSBODY)); pn->pn_body = kid; } void setFunctionBox(ParseNode* pn, FunctionBox* funbox) { MOZ_ASSERT(pn->isKind(PNK_FUNCTION)); pn->pn_funbox = funbox; funbox->functionNode = pn;
--- a/js/src/frontend/ParseNode.h +++ b/js/src/frontend/ParseNode.h @@ -1410,29 +1410,52 @@ AccessorTypeToJSOp(AccessorType atype) return JSOP_INITPROP_SETTER; default: MOZ_CRASH("unexpected accessor type"); } } enum FunctionSyntaxKind { - Expression, + // A non-arrow function expression that is a PrimaryExpression and *also* a + // complete AssignmentExpression. For example, in + // + // var x = (function y() {}); + // + // |y| is such a function expression. + AssignmentExpression, + + // A non-arrow function expression that is a PrimaryExpression but *not* a + // complete AssignmentExpression. For example, in + // + // var x = (1 + function y() {}); + // + // |y| is such a function expression. + PrimaryExpression, + + // A named function appearing as a Statement. Statement, + Arrow, Method, ClassConstructor, DerivedClassConstructor, Getter, GetterNoExpressionClosure, Setter, SetterNoExpressionClosure }; static inline bool +IsFunctionExpression(FunctionSyntaxKind kind) +{ + return kind == AssignmentExpression || kind == PrimaryExpression; +} + +static inline bool IsConstructorKind(FunctionSyntaxKind kind) { return kind == ClassConstructor || kind == DerivedClassConstructor; } static inline bool IsGetterKind(FunctionSyntaxKind kind) {
--- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -2783,17 +2783,18 @@ ParserBase::newFunction(HandleAtom atom, RootedFunction fun(context); gc::AllocKind allocKind = gc::AllocKind::FUNCTION; JSFunction::Flags flags; #ifdef DEBUG bool isGlobalSelfHostedBuiltin = false; #endif switch (kind) { - case Expression: + case AssignmentExpression: + case PrimaryExpression: flags = (generatorKind == GeneratorKind::NotGenerator && asyncKind == FunctionAsyncKind::SyncFunction ? JSFunction::INTERPRETED_LAMBDA : JSFunction::INTERPRETED_LAMBDA_GENERATOR_OR_ASYNC); break; case Arrow: flags = JSFunction::INTERPRETED_LAMBDA_ARROW; allocKind = gc::AllocKind::FUNCTION_EXTENDED; @@ -3342,19 +3343,18 @@ Parser<ParseHandler, CharT>::templateLit handler.addList(nodeList, pn); } while (tt == TOK_TEMPLATE_HEAD); return nodeList; } template <class ParseHandler, typename CharT> typename ParseHandler::Node Parser<ParseHandler, CharT>::functionDefinition(Node pn, uint32_t toStringStart, - InHandling inHandling, - YieldHandling yieldHandling, HandleAtom funName, - FunctionSyntaxKind kind, + InHandling inHandling, YieldHandling yieldHandling, + HandleAtom funName, FunctionSyntaxKind kind, GeneratorKind generatorKind, FunctionAsyncKind asyncKind, bool tryAnnexB /* = false */) { MOZ_ASSERT_IF(kind == Statement, funName); // When fully parsing a LazyScript, we do not fully reparse its inner // functions, which are also lazy. Instead, their free variables and @@ -3521,19 +3521,19 @@ Parser<SyntaxParseHandler, char16_t>::tr // This is already a syntax parser, so just parse the inner function. return innerFunction(pn, pc, fun, toStringStart, inHandling, yieldHandling, kind, generatorKind, asyncKind, tryAnnexB, inheritedDirectives, newDirectives); } template <class ParseHandler, typename CharT> bool Parser<ParseHandler, CharT>::innerFunction(Node pn, ParseContext* outerpc, FunctionBox* funbox, - uint32_t toStringStart, - InHandling inHandling, YieldHandling yieldHandling, - FunctionSyntaxKind kind, Directives inheritedDirectives, + uint32_t toStringStart, InHandling inHandling, + YieldHandling yieldHandling, FunctionSyntaxKind kind, + Directives inheritedDirectives, Directives* newDirectives) { // Note that it is possible for outerpc != this->pc, as we may be // attempting to syntax parse an inner function from an outer full // parser. In that case, outerpc is a SourceParseContext from the full parser // instead of the current top of the stack of the syntax parser. // Push a new ParseContext. @@ -3545,22 +3545,20 @@ Parser<ParseHandler, CharT>::innerFuncti return false; return leaveInnerFunction(outerpc); } template <class ParseHandler, typename CharT> bool Parser<ParseHandler, CharT>::innerFunction(Node pn, ParseContext* outerpc, HandleFunction fun, - uint32_t toStringStart, - InHandling inHandling, YieldHandling yieldHandling, - FunctionSyntaxKind kind, + uint32_t toStringStart, InHandling inHandling, + YieldHandling yieldHandling, FunctionSyntaxKind kind, GeneratorKind generatorKind, - FunctionAsyncKind asyncKind, - bool tryAnnexB, + FunctionAsyncKind asyncKind, bool tryAnnexB, Directives inheritedDirectives, Directives* newDirectives) { // Note that it is possible for outerpc != this->pc, as we may be // attempting to syntax parse an inner function from an outer full // parser. In that case, outerpc is a SourceParseContext from the full parser // instead of the current top of the stack of the syntax parser. @@ -3720,17 +3718,17 @@ Parser<ParseHandler, CharT>::functionFor TokenKind tt; if (!tokenStream.getToken(&tt, TokenStream::Operand)) return false; uint32_t openedPos = 0; if (tt != TOK_LC) { if (kind != Arrow) { if (funbox->isGenerator() || funbox->isAsync() || kind == Method || kind == GetterNoExpressionClosure || kind == SetterNoExpressionClosure || - IsConstructorKind(kind)) + IsConstructorKind(kind) || kind == PrimaryExpression) { error(JSMSG_CURLY_BEFORE_BODY); return false; } #if JS_HAS_EXPR_CLOSURES addTelemetry(DeprecatedLanguageExtension::ExpressionClosure); if (!warnOnceAboutExprClosure()) @@ -3761,25 +3759,27 @@ Parser<ParseHandler, CharT>::functionFor { AutoAwaitIsKeyword<Parser> awaitIsKeyword(this, bodyAwaitHandling); body = functionBody(inHandling, bodyYieldHandling, kind, bodyType); if (!body) return false; } // Revalidate the function name when we transitioned to strict mode. - if ((kind == Statement || kind == Expression) && fun->explicitName() - && !inheritedStrict && pc->sc()->strict()) + if ((kind == Statement || IsFunctionExpression(kind)) && + fun->explicitName() && + !inheritedStrict && + pc->sc()->strict()) { MOZ_ASSERT(pc->sc()->hasExplicitUseStrict(), "strict mode should only change when a 'use strict' directive is present"); PropertyName* propertyName = fun->explicitName()->asPropertyName(); YieldHandling nameYieldHandling; - if (kind == Expression) { + if (IsFunctionExpression(kind)) { // Named lambda has binding inside it. nameYieldHandling = bodyYieldHandling; } else { // Otherwise YieldHandling cannot be checked at this point // because of different context. // It should already be checked before this point. nameYieldHandling = YieldIsName; } @@ -3908,17 +3908,19 @@ Parser<ParseHandler, CharT>::functionStm YieldHandling newYieldHandling = GetYieldHandling(generatorKind); return functionDefinition(pn, toStringStart, InAllowed, newYieldHandling, name, Statement, generatorKind, asyncKind, tryAnnexB); } template <class ParseHandler, typename CharT> typename ParseHandler::Node -Parser<ParseHandler, CharT>::functionExpr(uint32_t toStringStart, InvokedPrediction invoked, +Parser<ParseHandler, CharT>::functionExpr(uint32_t toStringStart, + ExpressionClosure expressionClosureHandling, + InvokedPrediction invoked, FunctionAsyncKind asyncKind) { MOZ_ASSERT(tokenStream.isCurrentTokenType(TOK_FUNCTION)); AutoAwaitIsKeyword<Parser> awaitIsKeyword(this, GetAwaitHandling(asyncKind)); GeneratorKind generatorKind = GeneratorKind::NotGenerator; TokenKind tt; if (!tokenStream.getToken(&tt)) @@ -3943,17 +3945,21 @@ Parser<ParseHandler, CharT>::functionExp Node pn = handler.newFunctionExpression(pos()); if (!pn) return null(); if (invoked) pn = handler.setLikelyIIFE(pn); - return functionDefinition(pn, toStringStart, InAllowed, yieldHandling, name, Expression, + FunctionSyntaxKind kind = expressionClosureHandling == ExpressionClosure::Allowed + ? AssignmentExpression + : PrimaryExpression; + + return functionDefinition(pn, toStringStart, InAllowed, yieldHandling, name, kind, generatorKind, asyncKind); } /* * Return true if this node, known to be an unparenthesized string literal, * could be the string of a directive in a Directive Prologue. Directive * strings never contain escape sequences or line continuations. * isEscapeFreeStringLiteral, below, checks whether the node itself could be @@ -7088,17 +7094,18 @@ Parser<ParseHandler, CharT>::classDefini Node classHeritage = null(); bool hasHeritage; if (!tokenStream.matchToken(&hasHeritage, TOK_EXTENDS)) return null(); if (hasHeritage) { if (!tokenStream.getToken(&tt)) return null(); - classHeritage = memberExpr(yieldHandling, TripledotProhibited, tt); + classHeritage = memberExpr(yieldHandling, TripledotProhibited, + ExpressionClosure::Forbidden, tt); if (!classHeritage) return null(); } MUST_MATCH_TOKEN(TOK_LC, JSMSG_CURLY_BEFORE_CLASS); Node classMethods = handler.newClassMethodList(pos().begin); if (!classMethods) @@ -7835,33 +7842,40 @@ Precedence(ParseNodeKind pnk) { MOZ_ASSERT(pnk <= PNK_BINOP_LAST); return PrecedenceTable[pnk - PNK_BINOP_FIRST]; } template <class ParseHandler, typename CharT> MOZ_ALWAYS_INLINE typename ParseHandler::Node Parser<ParseHandler, CharT>::orExpr(InHandling inHandling, YieldHandling yieldHandling, TripledotHandling tripledotHandling, + ExpressionClosure expressionClosureHandling, PossibleError* possibleError, InvokedPrediction invoked /* = PredictUninvoked */) { // Shift-reduce parser for the binary operator part of the JS expression // syntax. // Conceptually there's just one stack, a stack of pairs (lhs, op). // It's implemented using two separate arrays, though. Node nodeStack[PRECEDENCE_CLASSES]; ParseNodeKind kindStack[PRECEDENCE_CLASSES]; int depth = 0; Node pn; for (;;) { - pn = unaryExpr(yieldHandling, tripledotHandling, possibleError, invoked); + pn = unaryExpr(yieldHandling, tripledotHandling, expressionClosureHandling, possibleError, + invoked); if (!pn) return null(); + if (handler.isExpressionClosure(pn)) + return pn; + + expressionClosureHandling = ExpressionClosure::Forbidden; + // If a binary operator follows, consume it and compute the // corresponding operator. TokenKind tok; if (!tokenStream.getToken(&tok)) return null(); ParseNodeKind pnk; if (tok == TOK_IN ? inHandling == InAllowed : TokenKindIsBinaryOp(tok)) { @@ -7916,23 +7930,28 @@ Parser<ParseHandler, CharT>::orExpr(InHa MOZ_ASSERT(depth == 0); return pn; } template <class ParseHandler, typename CharT> MOZ_ALWAYS_INLINE typename ParseHandler::Node Parser<ParseHandler, CharT>::condExpr(InHandling inHandling, YieldHandling yieldHandling, TripledotHandling tripledotHandling, + ExpressionClosure expressionClosureHandling, PossibleError* possibleError, InvokedPrediction invoked /* = PredictUninvoked */) { - Node condition = orExpr(inHandling, yieldHandling, tripledotHandling, possibleError, invoked); + Node condition = orExpr(inHandling, yieldHandling, tripledotHandling, + expressionClosureHandling, possibleError, invoked); if (!condition) return null(); + if (handler.isExpressionClosure(condition)) + return condition; + bool matched; if (!tokenStream.matchToken(&matched, TOK_HOOK)) return null(); if (!matched) return condition; Node thenExpr = assignExpr(InAllowed, yieldHandling, TripledotProhibited); if (!thenExpr) @@ -8047,17 +8066,18 @@ Parser<ParseHandler, CharT>::assignExpr( if (tokenAfterLHS != TOK_ARROW) { error(JSMSG_UNEXPECTED_TOKEN, "'=>' on the same line after an argument list", TokenKindToDesc(tokenAfterLHS)); return null(); } isArrow = true; } else { - lhs = condExpr(inHandling, yieldHandling, tripledotHandling, &possibleErrorInner, invoked); + lhs = condExpr(inHandling, yieldHandling, tripledotHandling, ExpressionClosure::Allowed, + &possibleErrorInner, invoked); if (!lhs) return null(); // Use Operand here because the ConditionalExpression parsed above // could be the entirety of this AssignmentExpression, and then ASI // permits this token to be a regular expression. if (!tokenStream.peekTokenSameLine(&tokenAfterLHS, TokenStream::Operand)) return null(); @@ -8091,18 +8111,18 @@ Parser<ParseHandler, CharT>::assignExpr( else tokenStream.ungetToken(); } Node pn = handler.newArrowFunction(pos()); if (!pn) return null(); - return functionDefinition(pn, toStringStart, inHandling, yieldHandling, nullptr, - Arrow, GeneratorKind::NotGenerator, asyncKind); + return functionDefinition(pn, toStringStart, inHandling, yieldHandling, nullptr, Arrow, + GeneratorKind::NotGenerator, asyncKind); } MOZ_ALWAYS_TRUE(tokenStream.getToken(&tokenAfterLHS, TokenStream::Operand)); ParseNodeKind kind; switch (tokenAfterLHS) { case TOK_ASSIGN: kind = PNK_ASSIGN; break; case TOK_ADDASSIGN: kind = PNK_ADDASSIGN; break; @@ -8242,26 +8262,27 @@ Parser<ParseHandler, CharT>::checkIncDec return true; } template <class ParseHandler, typename CharT> typename ParseHandler::Node Parser<ParseHandler, CharT>::unaryOpExpr(YieldHandling yieldHandling, ParseNodeKind kind, uint32_t begin) { - Node kid = unaryExpr(yieldHandling, TripledotProhibited); + Node kid = unaryExpr(yieldHandling, TripledotProhibited, ExpressionClosure::Forbidden); if (!kid) return null(); return handler.newUnary(kind, begin, kid); } template <class ParseHandler, typename CharT> typename ParseHandler::Node Parser<ParseHandler, CharT>::unaryExpr(YieldHandling yieldHandling, TripledotHandling tripledotHandling, + ExpressionClosure expressionClosureHandling, PossibleError* possibleError /* = nullptr */, InvokedPrediction invoked /* = PredictUninvoked */) { if (!CheckRecursionLimit(context)) return null(); TokenKind tt; if (!tokenStream.getToken(&tt, TokenStream::Operand)) @@ -8286,45 +8307,46 @@ Parser<ParseHandler, CharT>::unaryExpr(Y // // // Looks up the name, doesn't find it and so evaluates to // // "undefined". // assertEq(typeof nonExistentName, "undefined"); // // // Evaluates expression, triggering a runtime ReferenceError for // // the undefined name. // typeof (1, nonExistentName); - Node kid = unaryExpr(yieldHandling, TripledotProhibited); + Node kid = unaryExpr(yieldHandling, TripledotProhibited, ExpressionClosure::Forbidden); if (!kid) return null(); return handler.newTypeof(begin, kid); } case TOK_INC: case TOK_DEC: { TokenKind tt2; if (!tokenStream.getToken(&tt2, TokenStream::Operand)) return null(); uint32_t operandOffset = pos().begin; - Node operand = memberExpr(yieldHandling, TripledotProhibited, tt2); + Node operand = + memberExpr(yieldHandling, TripledotProhibited, ExpressionClosure::Forbidden, tt2); if (!operand || !checkIncDecOperand(operand, operandOffset)) return null(); return handler.newUpdate((tt == TOK_INC) ? PNK_PREINCREMENT : PNK_PREDECREMENT, begin, operand); } case TOK_DELETE: { uint32_t exprOffset; if (!tokenStream.peekOffset(&exprOffset, TokenStream::Operand)) return null(); - Node expr = unaryExpr(yieldHandling, TripledotProhibited); + Node expr = unaryExpr(yieldHandling, TripledotProhibited, ExpressionClosure::Forbidden); if (!expr) return null(); // Per spec, deleting any unary expression is valid -- it simply // returns true -- except for one case that is illegal in strict mode. if (handler.isName(expr)) { if (!strictModeErrorAt(exprOffset, JSMSG_DEPRECATED_DELETE_OPERAND)) return null(); @@ -8332,32 +8354,36 @@ Parser<ParseHandler, CharT>::unaryExpr(Y pc->sc()->setBindingsAccessedDynamically(); } return handler.newDelete(begin, expr); } case TOK_AWAIT: { if (pc->isAsync()) { - Node kid = unaryExpr(yieldHandling, tripledotHandling, possibleError, invoked); + Node kid = unaryExpr(yieldHandling, tripledotHandling, ExpressionClosure::Forbidden, + possibleError, invoked); if (!kid) return null(); pc->lastAwaitOffset = begin; return handler.newAwaitExpression(begin, kid); } } MOZ_FALLTHROUGH; default: { - Node expr = memberExpr(yieldHandling, tripledotHandling, tt, /* allowCallSyntax = */ true, - possibleError, invoked); + Node expr = memberExpr(yieldHandling, tripledotHandling, expressionClosureHandling, tt, + /* allowCallSyntax = */ true, possibleError, invoked); if (!expr) return null(); + if (handler.isExpressionClosure(expr)) + return expr; + /* Don't look across a newline boundary for a postfix incop. */ if (!tokenStream.peekTokenSameLine(&tt)) return null(); if (tt != TOK_INC && tt != TOK_DEC) return expr; tokenStream.consumeKnownToken(tt); @@ -8454,16 +8480,17 @@ Parser<ParseHandler, CharT>::checkAndMar pc->setSuperScopeNeedsHomeObject(); return true; } template <class ParseHandler, typename CharT> typename ParseHandler::Node Parser<ParseHandler, CharT>::memberExpr(YieldHandling yieldHandling, TripledotHandling tripledotHandling, + ExpressionClosure expressionClosureHandling, TokenKind tt, bool allowCallSyntax /* = true */, PossibleError* possibleError /* = nullptr */, InvokedPrediction invoked /* = PredictUninvoked */) { MOZ_ASSERT(tokenStream.isCurrentTokenType(tt)); Node lhs; @@ -8477,17 +8504,18 @@ Parser<ParseHandler, CharT>::memberExpr( Node newTarget; if (!tryNewTarget(newTarget)) return null(); if (newTarget) { lhs = newTarget; } else { // Gotten by tryNewTarget tt = tokenStream.currentToken().type; - Node ctorExpr = memberExpr(yieldHandling, TripledotProhibited, tt, + Node ctorExpr = memberExpr(yieldHandling, TripledotProhibited, + ExpressionClosure::Forbidden, tt, /* allowCallSyntax = */ false, /* possibleError = */ nullptr, PredictInvoked); if (!ctorExpr) return null(); lhs = handler.newNewExpression(newBegin, ctorExpr); if (!lhs) return null(); @@ -8506,19 +8534,23 @@ Parser<ParseHandler, CharT>::memberExpr( } else if (tt == TOK_SUPER) { Node thisName = newThisName(); if (!thisName) return null(); lhs = handler.newSuperBase(thisName, pos()); if (!lhs) return null(); } else { - lhs = primaryExpr(yieldHandling, tripledotHandling, tt, possibleError, invoked); + lhs = primaryExpr(yieldHandling, tripledotHandling, expressionClosureHandling, tt, + possibleError, invoked); if (!lhs) return null(); + + if (handler.isExpressionClosure(lhs)) + return lhs; } MOZ_ASSERT_IF(handler.isSuperBase(lhs), tokenStream.isCurrentTokenType(TOK_SUPER)); while (true) { if (!tokenStream.getToken(&tt)) return null(); if (tt == TOK_EOF) @@ -9685,27 +9717,29 @@ Parser<ParseHandler, CharT>::tryNewTarge newTarget = handler.newNewTarget(newHolder, targetHolder); return !!newTarget; } template <class ParseHandler, typename CharT> typename ParseHandler::Node Parser<ParseHandler, CharT>::primaryExpr(YieldHandling yieldHandling, - TripledotHandling tripledotHandling, TokenKind tt, + TripledotHandling tripledotHandling, + ExpressionClosure expressionClosureHandling, TokenKind tt, PossibleError* possibleError, InvokedPrediction invoked /* = PredictUninvoked */) { MOZ_ASSERT(tokenStream.isCurrentTokenType(tt)); if (!CheckRecursionLimit(context)) return null(); switch (tt) { case TOK_FUNCTION: - return functionExpr(pos().begin, invoked); + return functionExpr(pos().begin, expressionClosureHandling, invoked, + FunctionAsyncKind::SyncFunction); case TOK_CLASS: return classDefinition(yieldHandling, ClassExpression, NameRequired); case TOK_LB: return arrayInitializer(yieldHandling, possibleError); case TOK_LC: @@ -9760,17 +9794,17 @@ Parser<ParseHandler, CharT>::primaryExpr if (tt == TOK_ASYNC) { TokenKind nextSameLine = TOK_EOF; if (!tokenStream.peekTokenSameLine(&nextSameLine)) return null(); if (nextSameLine == TOK_FUNCTION) { uint32_t toStringStart = pos().begin; tokenStream.consumeKnownToken(TOK_FUNCTION); - return functionExpr(toStringStart, PredictUninvoked, + return functionExpr(toStringStart, expressionClosureHandling, PredictUninvoked, FunctionAsyncKind::AsyncFunction); } } Rooted<PropertyName*> name(context, identifierReference(yieldHandling)); if (!name) return null();
--- a/js/src/frontend/Parser.h +++ b/js/src/frontend/Parser.h @@ -300,16 +300,18 @@ ParseContext::Scope::Scope(JSContext* cx inline ParseContext::VarScope::VarScope(ParserBase* parser) : Scope(parser) { useAsVarScope(parser->pc); } +enum class ExpressionClosure { Allowed, Forbidden }; + template <class ParseHandler, typename CharT> class Parser final : public ParserBase, private JS::AutoGCRooter { private: using Node = typename ParseHandler::Node; /* * A class for temporarily stashing errors while parsing continues. @@ -552,18 +554,17 @@ class Parser final : public ParserBase, // Parse a function, given only its arguments and body. Used for lazily // parsed functions. Node standaloneLazyFunction(HandleFunction fun, uint32_t toStringStart, bool strict, GeneratorKind generatorKind, FunctionAsyncKind asyncKind); // Parse an inner function given an enclosing ParseContext and a // FunctionBox for the inner function. bool innerFunction(Node pn, ParseContext* outerpc, FunctionBox* funbox, uint32_t toStringStart, - InHandling inHandling, YieldHandling yieldHandling, - FunctionSyntaxKind kind, + InHandling inHandling, YieldHandling yieldHandling, FunctionSyntaxKind kind, Directives inheritedDirectives, Directives* newDirectives); // Parse a function's formal parameters and its body assuming its function // ParseContext is already on the stack. bool functionFormalParametersAndBody(InHandling inHandling, YieldHandling yieldHandling, Node pn, FunctionSyntaxKind kind, const mozilla::Maybe<uint32_t>& parameterListEnd = mozilla::Nothing(), bool isStandaloneFunction = false); @@ -588,18 +589,18 @@ class Parser final : public ParserBase, * unnecessary ungetting and regetting of tokens. * * Some parsers have two versions: an always-inlined version (with an 'i' * suffix) and a never-inlined version (with an 'n' suffix). */ Node functionStmt(uint32_t toStringStart, YieldHandling yieldHandling, DefaultHandling defaultHandling, FunctionAsyncKind asyncKind = FunctionAsyncKind::SyncFunction); - Node functionExpr(uint32_t toStringStart, InvokedPrediction invoked = PredictUninvoked, - FunctionAsyncKind asyncKind = FunctionAsyncKind::SyncFunction); + Node functionExpr(uint32_t toStringStart, ExpressionClosure expressionClosureHandling, + InvokedPrediction invoked, FunctionAsyncKind asyncKind); Node statementList(YieldHandling yieldHandling); Node statement(YieldHandling yieldHandling); bool maybeParseDirective(Node list, Node pn, bool* cont); Node blockStatement(YieldHandling yieldHandling, unsigned errorNumber = JSMSG_CURLY_IN_COMPOUND); Node doWhileStatement(YieldHandling yieldHandling); @@ -718,50 +719,50 @@ class Parser final : public ParserBase, TripledotHandling tripledotHandling, PossibleError* possibleError = nullptr, InvokedPrediction invoked = PredictUninvoked); Node assignExpr(InHandling inHandling, YieldHandling yieldHandling, TripledotHandling tripledotHandling, PossibleError* possibleError = nullptr, InvokedPrediction invoked = PredictUninvoked); Node assignExprWithoutYieldOrAwait(YieldHandling yieldHandling); Node yieldExpression(InHandling inHandling); Node condExpr(InHandling inHandling, YieldHandling yieldHandling, - TripledotHandling tripledotHandling, + TripledotHandling tripledotHandling, ExpressionClosure expressionClosureHandling, PossibleError* possibleError, InvokedPrediction invoked = PredictUninvoked); Node orExpr(InHandling inHandling, YieldHandling yieldHandling, - TripledotHandling tripledotHandling, + TripledotHandling tripledotHandling, ExpressionClosure expressionClosureHandling, PossibleError* possibleError, InvokedPrediction invoked = PredictUninvoked); Node unaryExpr(YieldHandling yieldHandling, TripledotHandling tripledotHandling, + ExpressionClosure expressionClosureHandling, PossibleError* possibleError = nullptr, InvokedPrediction invoked = PredictUninvoked); Node memberExpr(YieldHandling yieldHandling, TripledotHandling tripledotHandling, - TokenKind tt, bool allowCallSyntax = true, - PossibleError* possibleError = nullptr, + ExpressionClosure expressionClosureHandling, TokenKind tt, + bool allowCallSyntax = true, PossibleError* possibleError = nullptr, InvokedPrediction invoked = PredictUninvoked); Node primaryExpr(YieldHandling yieldHandling, TripledotHandling tripledotHandling, - TokenKind tt, PossibleError* possibleError, - InvokedPrediction invoked = PredictUninvoked); + ExpressionClosure expressionClosureHandling, TokenKind tt, + PossibleError* possibleError, InvokedPrediction invoked = PredictUninvoked); Node exprInParens(InHandling inHandling, YieldHandling yieldHandling, TripledotHandling tripledotHandling, PossibleError* possibleError = nullptr); bool tryNewTarget(Node& newTarget); bool checkAndMarkSuperScope(); Node methodDefinition(uint32_t toStringStart, PropertyType propType, HandleAtom funName); /* * Additional JS parsers. */ bool functionArguments(YieldHandling yieldHandling, FunctionSyntaxKind kind, Node funcpn); - Node functionDefinition(Node func, uint32_t toStringStart, - InHandling inHandling, YieldHandling yieldHandling, - HandleAtom name, FunctionSyntaxKind kind, + Node functionDefinition(Node func, uint32_t toStringStart, InHandling inHandling, + YieldHandling yieldHandling, HandleAtom name, FunctionSyntaxKind kind, GeneratorKind generatorKind, FunctionAsyncKind asyncKind, bool tryAnnexB = false); // Parse a function body. Pass StatementListBody if the body is a list of // statements; pass ExpressionBody if the body is a single expression. enum FunctionBodyType { StatementListBody, ExpressionBody }; Node functionBody(InHandling inHandling, YieldHandling yieldHandling, FunctionSyntaxKind kind, FunctionBodyType type); @@ -830,25 +831,23 @@ class Parser final : public ParserBase, Node newInternalDotName(HandlePropertyName name); Node newThisName(); Node newDotGeneratorName(); bool declareDotGeneratorName(); bool skipLazyInnerFunction(Node pn, uint32_t toStringStart, FunctionSyntaxKind kind, bool tryAnnexB); bool innerFunction(Node pn, ParseContext* outerpc, HandleFunction fun, uint32_t toStringStart, - InHandling inHandling, YieldHandling yieldHandling, - FunctionSyntaxKind kind, + InHandling inHandling, YieldHandling yieldHandling, FunctionSyntaxKind kind, GeneratorKind generatorKind, FunctionAsyncKind asyncKind, bool tryAnnexB, Directives inheritedDirectives, Directives* newDirectives); bool trySyntaxParseInnerFunction(Node pn, HandleFunction fun, uint32_t toStringStart, InHandling inHandling, YieldHandling yieldHandling, - FunctionSyntaxKind kind, - GeneratorKind generatorKind, FunctionAsyncKind asyncKind, - bool tryAnnexB, + FunctionSyntaxKind kind, GeneratorKind generatorKind, + FunctionAsyncKind asyncKind, bool tryAnnexB, Directives inheritedDirectives, Directives* newDirectives); bool finishFunctionScopes(bool isStandaloneFunction); bool finishFunction(bool isStandaloneFunction = false); bool leaveInnerFunction(ParseContext* outerpc); bool matchOrInsertSemicolon(); public:
--- a/js/src/frontend/SyntaxParseHandler.h +++ b/js/src/frontend/SyntaxParseHandler.h @@ -45,17 +45,26 @@ class SyntaxParseHandler NodeReturn, NodeBreak, NodeThrow, NodeEmptyStatement, NodeVarDeclaration, NodeLexicalDeclaration, - NodeFunctionDefinition, + // A non-arrow function expression with block body, from bog-standard + // ECMAScript. + NodeFunctionExpressionBlockBody, + + // A non-arrow function expression with AssignmentExpression body -- a + // proprietary SpiderMonkey extension. + NodeFunctionExpressionClosure, + + NodeFunctionArrow, + NodeFunctionStatement, // This is needed for proper assignment-target handling. ES6 formally // requires function calls *not* pass IsValidSimpleAssignmentTarget, // but at last check there were still sites with |f() = 5| and similar // in code not actually executed (or at least not executed enough to be // noticed). NodeFunctionCall, @@ -114,16 +123,20 @@ class SyntaxParseHandler // We want to reject |-2 ** 3|, but still need to allow |(-2) ** 3|. NodeUnparenthesizedUnary, // This node is necessary to determine if the LHS of a property access is // super related. NodeSuperBase }; + bool isNonArrowFunctionExpression(Node node) const { + return node == NodeFunctionExpressionBlockBody || node == NodeFunctionExpressionClosure; + } + bool isPropertyAccess(Node node) { return node == NodeDottedProperty || node == NodeElement; } bool isFunctionCall(Node node) { // Note: super() is a special form, *not* a function call. return node == NodeFunctionCall; } @@ -314,19 +327,30 @@ class SyntaxParseHandler MOZ_MUST_USE bool addCatchBlock(Node catchList, Node letBlock, Node catchName, Node catchGuard, Node catchBody) { return true; } MOZ_MUST_USE bool setLastFunctionFormalParameterDefault(Node funcpn, Node pn) { return true; } void checkAndSetIsDirectRHSAnonFunction(Node pn) {} - Node newFunctionStatement(const TokenPos& pos) { return NodeFunctionDefinition; } - Node newFunctionExpression(const TokenPos& pos) { return NodeFunctionDefinition; } - Node newArrowFunction(const TokenPos& pos) { return NodeFunctionDefinition; } + Node newFunctionStatement(const TokenPos& pos) { return NodeFunctionStatement; } + + Node newFunctionExpression(const TokenPos& pos) { + // All non-arrow function expressions are initially presumed to have + // block body. This will be overridden later *if* the function + // expression permissibly has an AssignmentExpression body. + return NodeFunctionExpressionBlockBody; + } + + Node newArrowFunction(const TokenPos& pos) { return NodeFunctionArrow; } + + bool isExpressionClosure(Node node) const { + return node == NodeFunctionExpressionClosure; + } void setFunctionFormalParametersAndBody(Node pn, Node kid) {} void setFunctionBody(Node pn, Node kid) {} void setFunctionBox(Node pn, FunctionBox* funbox) {} void addFunctionFormalParameter(Node pn, Node argpn) {} Node newForStatement(uint32_t begin, Node forHead, Node body, unsigned iflags) { return NodeGeneric; @@ -415,17 +439,18 @@ class SyntaxParseHandler return node == NodeUnparenthesizedUnary; } bool isReturnStatement(Node node) { return node == NodeReturn; } bool isStatementPermittedAfterReturnStatement(Node pn) { - return pn == NodeFunctionDefinition || pn == NodeVarDeclaration || + return pn == NodeFunctionStatement || isNonArrowFunctionExpression(pn) || + pn == NodeVarDeclaration || pn == NodeBreak || pn == NodeThrow || pn == NodeEmptyStatement; } bool isSuperBase(Node pn) { return pn == NodeSuperBase; }
--- a/js/src/jit-test/tests/parser/bug-1298809.js +++ b/js/src/jit-test/tests/parser/bug-1298809.js @@ -1,9 +1,12 @@ if (getBuildConfiguration().release_or_beta) { eval(` function f() { + // The expression closure is deliberate here, testing the semicolon after + // one when it appears as a FunctionDeclaration from B.3.4 + // FunctionDeclarations in IfStatement Statement Clauses. if (0) - function g() { x }; + function g() x; else; } f();`) }
new file mode 100644 --- /dev/null +++ b/js/src/tests/ecma_6/extensions/arrow-as-end-of-expression-closure.js @@ -0,0 +1,41 @@ +// |reftest| skip-if(!xulRuntime.shell) -- needs getBuildConfiguration +/* 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/. */ + +// ArrowFunctions with block bodies appearing at the end of the +// AssignmentExpression returned by SpiderMonkey-specific function expression +// closures, where subsequent token-examination must use the Operand modifier +// to avoid an assertion. + +if (getBuildConfiguration().release_or_beta) +{ + eval(` + var ec1 = function() 0 ? 1 : a => {}; + assertEq(typeof ec1, "function"); + assertEq(typeof ec1(), "function"); + assertEq(ec1()(), undefined); + + var ec2 = function() 0 ? 1 : a => {} // deliberately exercise ASI here + assertEq(typeof ec2, "function"); + assertEq(typeof ec2(), "function"); + assertEq(ec2()(), undefined); + + function ec3() 0 ? 1 : a => {} // exercise ASI here + assertEq(typeof ec3(), "function"); + + function ec4() 0 ? 1 : a => {}; + assertEq(typeof ec4(), "function"); + + var needle = "@"; + var x = 42; + var g = { test() { assertEq(true, false, "shouldn't be called"); } }; + + function ec5() 0 ? 1 : a => {} // ASI + /x/g.test((needle = "x")); + assertEq(needle, "x"); + `); +} + +if (typeof reportCompare === "function") + reportCompare(true, true);
new file mode 100644 --- /dev/null +++ b/js/src/tests/js1_8_5/extensions/expression-closure-syntax.js @@ -0,0 +1,64 @@ +// |reftest| skip-if(!xulRuntime.shell) -- needs getBuildConfiguration +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 1416337; +var summary = + "Expression closure syntax is only permitted for functions that constitute " + + "entire AssignmentExpressions, not PrimaryExpressions that are themselves " + + "components of larger binary expressions"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +if (getBuildConfiguration().release_or_beta) +{ + function assertThrowsSyntaxError(code) + { + function testOne(replacement) + { + var x, rv; + try + { + rv = eval(code.replace("@@@", replacement)); + } + catch (e) + { + assertEq(e instanceof SyntaxError, true, + "should have thrown a SyntaxError, instead got: " + e); + return; + } + + assertEq(true, false, "should have thrown, instead returned " + rv); + } + + testOne("function"); + testOne("async function"); + } + + assertThrowsSyntaxError("x = ++@@@() 1"); + assertThrowsSyntaxError("x = delete @@@() 1"); + assertThrowsSyntaxError("x = new @@@() 1"); + assertThrowsSyntaxError("x = void @@@() 1"); + assertThrowsSyntaxError("x = +@@@() 1"); + assertThrowsSyntaxError("x = 1 + @@@() 1"); + assertThrowsSyntaxError("x = null != @@@() 1"); + assertThrowsSyntaxError("x = null != @@@() 0 ? 1 : a => {}"); + assertThrowsSyntaxError("x = @@@() 0 ? 1 : a => {} !== null"); + assertThrowsSyntaxError("x = @@@() 0 ? 1 : a => {}.toString"); + assertThrowsSyntaxError("x = @@@() 0 ? 1 : a => {}['toString']"); + assertThrowsSyntaxError("x = @@@() 0 ? 1 : a => {}``"); + assertThrowsSyntaxError("x = @@@() 0 ? 1 : a => {}()"); + assertThrowsSyntaxError("x = @@@() 0 ? 1 : a => {}++"); + assertThrowsSyntaxError("x = @@@() 0 ? 1 : a => {} || 0"); + assertThrowsSyntaxError("x = 0 || @@@() 0 ? 1 : a => {}"); + assertThrowsSyntaxError("x = @@@() 0 ? 1 : a => {} && true"); + assertThrowsSyntaxError("x = true && @@@() 0 ? 1 : a => {}"); +} + +if (typeof reportCompare === "function") + reportCompare(true, true);
--- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -13,16 +13,17 @@ #include "xpcpublic.h" #include "XPCWrapper.h" #include "XPCJSMemoryReporter.h" #include "WrapperFactory.h" #include "mozJSComponentLoader.h" #include "nsAutoPtr.h" #include "nsNetUtil.h" +#include "nsExceptionHandler.h" #include "nsIMemoryInfoDumper.h" #include "nsIMemoryReporter.h" #include "nsIObserverService.h" #include "nsIDebug2.h" #include "nsIDocShell.h" #include "nsIRunnable.h" #include "amIAddonManager.h" #include "nsPIDOMWindow.h" @@ -55,20 +56,16 @@ #include "nsGlobalWindow.h" #include "nsAboutProtocolUtils.h" #include "GeckoProfiler.h" #include "nsIInputStream.h" #include "nsIXULRuntime.h" #include "nsJSPrincipals.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - #ifdef XP_WIN #include <windows.h> #endif using namespace mozilla; using namespace xpc; using namespace JS; using mozilla::dom::PerThreadAtomCache; @@ -747,19 +744,17 @@ xpc_UnmarkSkippableJSHolders() XPCJSRuntime::GCSliceCallback(JSContext* cx, JS::GCProgress progress, const JS::GCDescription& desc) { XPCJSRuntime* self = nsXPConnect::GetRuntimeInstance(); if (!self) return; -#ifdef MOZ_CRASHREPORTER CrashReporter::SetGarbageCollecting(progress == JS::GC_CYCLE_BEGIN); -#endif if (self->mPrevGCSliceCallback) (*self->mPrevGCSliceCallback)(cx, progress, desc); } /* static */ void XPCJSRuntime::DoCycleCollectionCallback(JSContext* cx) {
--- a/js/xpconnect/src/XPCShellImpl.cpp +++ b/js/xpconnect/src/XPCShellImpl.cpp @@ -8,16 +8,17 @@ #include "jsapi.h" #include "jsfriendapi.h" #include "jsprf.h" #include "mozilla/ChaosMode.h" #include "mozilla/dom/ScriptSettings.h" #include "mozilla/Preferences.h" #include "nsServiceManagerUtils.h" #include "nsComponentManagerUtils.h" +#include "nsExceptionHandler.h" #include "nsIServiceManager.h" #include "nsIFile.h" #include "nsString.h" #include "nsIDirectoryService.h" #include "nsDirectoryServiceDefs.h" #include "nsAppDirectoryServiceDefs.h" #include "nscore.h" #include "nsArrayEnumerator.h" @@ -56,21 +57,16 @@ #include <errno.h> #ifdef HAVE_IO_H #include <io.h> /* for isatty() */ #endif #ifdef HAVE_UNISTD_H #include <unistd.h> /* for isatty() */ #endif -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#include "nsICrashReporter.h" -#endif - #ifdef ENABLE_TESTS #include "xpctest_private.h" #endif using namespace mozilla; using namespace JS; using mozilla::dom::AutoJSAPI; using mozilla::dom::AutoEntryScript; @@ -1188,27 +1184,25 @@ XRE_XPCShellMain(int argc, char** argv, return 1; } XRE_AddManifestLocation(NS_APP_LOCATION, lf); argc -= 2; argv += 2; } -#ifdef MOZ_CRASHREPORTER const char* val = getenv("MOZ_CRASHREPORTER"); - if (val && *val) { + if (val && *val && !CrashReporter::IsDummy()) { rv = CrashReporter::SetExceptionHandler(greDir, true); if (NS_FAILED(rv)) { printf("CrashReporter::SetExceptionHandler failed!\n"); return 1; } MOZ_ASSERT(CrashReporter::GetEnabled()); } -#endif if (argc > 1 && !strcmp(argv[1], "--greomni")) { nsCOMPtr<nsIFile> greOmni; nsCOMPtr<nsIFile> appOmni; XRE_GetFileFromPath(argv[2], getter_AddRefs(greOmni)); if (argc > 3 && !strcmp(argv[3], "--appomni")) { XRE_GetFileFromPath(argv[4], getter_AddRefs(appOmni)); argc-=2; @@ -1390,21 +1384,20 @@ XRE_XPCShellMain(int argc, char** argv, if (!XRE_ShutdownTestShell()) NS_ERROR("problem shutting down testshell"); // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM rv = NS_ShutdownXPCOM( nullptr ); MOZ_ASSERT(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed"); -#ifdef MOZ_CRASHREPORTER // Shut down the crashreporter service to prevent leaking some strings it holds. - if (CrashReporter::GetEnabled()) + if (CrashReporter::GetEnabled()) { CrashReporter::UnsetExceptionHandler(); -#endif + } #ifdef MOZ_GECKO_PROFILER // This must precede NS_LogTerm(), otherwise xpcshell return non-zero // during some tests, which causes failures. profiler_shutdown(); #endif NS_LogTerm();
--- a/layout/reftests/css-invalid/select/reftest.list +++ b/layout/reftests/css-invalid/select/reftest.list @@ -2,11 +2,11 @@ needs-focus == select-valid.html select- fuzzy-if(skiaContent,1,3) needs-focus == select-invalid.html select-ref.html fuzzy-if(skiaContent,2,6) needs-focus == select-disabled.html select-disabled-ref.html fuzzy-if(skiaContent,2,6) needs-focus == select-dyn-disabled.html select-disabled-ref.html fuzzy-if(skiaContent,1,3) needs-focus == select-dyn-not-disabled.html select-ref.html needs-focus == select-required-invalid.html select-required-ref.html needs-focus == select-required-valid.html select-required-ref.html needs-focus == select-required-multiple-still-valid.html select-required-multiple-ref.html fuzzy-if(skiaContent,1,250) needs-focus == select-required-multiple-valid.html select-required-multiple-ref.html -fuzzy-if(skiaContent&&!Android,1,3) skip-if(Android) needs-focus == select-disabled-fieldset-1.html select-fieldset-ref.html -fuzzy-if(skiaContent&&!Android,2,3) skip-if(Android) needs-focus == select-disabled-fieldset-2.html select-fieldset-ref.html +fuzzy-if(skiaContent&&!Android,1,3) fuzzy-if(Android,8,1) needs-focus == select-disabled-fieldset-1.html select-fieldset-ref.html +fuzzy-if(skiaContent&&!Android,2,3) fuzzy-if(Android,8,1) needs-focus == select-disabled-fieldset-2.html select-fieldset-ref.html fuzzy-if(skiaContent,2,5) needs-focus == select-fieldset-legend.html select-fieldset-legend-ref.html
--- a/layout/style/ServoBindings.cpp +++ b/layout/style/ServoBindings.cpp @@ -20,16 +20,17 @@ #include "nsCSSParser.h" #include "nsCSSPseudoElements.h" #include "nsCSSRuleProcessor.h" #include "nsCSSRules.h" #include "nsContentUtils.h" #include "nsDOMTokenList.h" #include "nsDeviceContext.h" #include "nsIContentInlines.h" +#include "nsICrashReporter.h" #include "nsIDOMNode.h" #include "nsIDocumentInlines.h" #include "nsILoadContext.h" #include "nsIFrame.h" #include "nsIMemoryReporter.h" #include "nsINode.h" #include "nsIPresShell.h" #include "nsIPresShellInlines.h" @@ -70,20 +71,16 @@ #include "mozilla/dom/HTMLBodyElement.h" #include "mozilla/LookAndFeel.h" #include "mozilla/URLExtraData.h" #if defined(MOZ_MEMORY) # include "mozmemory.h" #endif -#ifdef MOZ_CRASHREPORTER -#include "nsICrashReporter.h" -#endif - using namespace mozilla; using namespace mozilla::css; using namespace mozilla::dom; #define SERVO_ARC_TYPE(name_, type_) \ already_AddRefed<type_> \ type_##Strong::Consume() { \ RefPtr<type_> result; \ @@ -2817,34 +2814,30 @@ Gecko_ReportUnexpectedCSSError(ErrorRepo nsDependentCSubstring sourceValue(source, sourceLen); reporter->OutputError(lineNumber, colNumber, sourceValue); } void Gecko_AddBufferToCrashReport(const void* addr, size_t len) { MOZ_ASSERT(NS_IsMainThread()); -#ifdef MOZ_CRASHREPORTER nsCOMPtr<nsICrashReporter> cr = do_GetService("@mozilla.org/toolkit/crash-reporter;1"); NS_ENSURE_TRUE_VOID(cr); cr->RegisterAppMemory((uint64_t) addr, len); -#endif } void Gecko_AnnotateCrashReport(const char* key_str, const char* value_str) { MOZ_ASSERT(NS_IsMainThread()); nsDependentCString key(key_str); nsDependentCString value(value_str); -#ifdef MOZ_CRASHREPORTER nsCOMPtr<nsICrashReporter> cr = do_GetService("@mozilla.org/toolkit/crash-reporter;1"); NS_ENSURE_TRUE_VOID(cr); cr->AnnotateCrashReport(key, value); -#endif } void Gecko_ContentList_AppendAll( nsSimpleContentList* aList, const Element** aElements, size_t aLength) {
--- a/layout/style/nsLayoutStylesheetCache.cpp +++ b/layout/style/nsLayoutStylesheetCache.cpp @@ -4,45 +4,42 @@ * 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 "nsLayoutStylesheetCache.h" #include "nsAppDirectoryServiceDefs.h" #include "mozilla/StyleSheetInlines.h" #include "mozilla/MemoryReporting.h" +#include "mozilla/Omnijar.h" #include "mozilla/Preferences.h" #include "mozilla/StyleSheet.h" #include "mozilla/StyleSheetInlines.h" #include "mozilla/css/Loader.h" #include "mozilla/dom/SRIMetadata.h" #include "MainThreadUtils.h" #include "nsColor.h" +#include "nsDirectoryServiceDefs.h" +#include "nsDirectoryService.h" +#include "nsExceptionHandler.h" +#include "nsIChromeRegistry.h" #include "nsIConsoleService.h" #include "nsIFile.h" +#include "nsIObserverService.h" +#include "nsISimpleEnumerator.h" +#include "nsISubstitutingProtocolHandler.h" +#include "nsIXULRuntime.h" #include "nsNetUtil.h" -#include "nsIObserverService.h" -#include "nsServiceManagerUtils.h" -#include "nsIXULRuntime.h" #include "nsPresContext.h" #include "nsPrintfCString.h" +#include "nsServiceManagerUtils.h" #include "nsXULAppAPI.h" +#include "nsZipArchive.h" -// Includes for the crash report annotation in ErrorLoadingSheet. -#ifdef MOZ_CRASHREPORTER -#include "mozilla/Omnijar.h" -#include "nsDirectoryService.h" -#include "nsDirectoryServiceDefs.h" -#include "nsExceptionHandler.h" -#include "nsIChromeRegistry.h" -#include "nsISimpleEnumerator.h" -#include "nsISubstitutingProtocolHandler.h" #include "zlib.h" -#include "nsZipArchive.h" -#endif using namespace mozilla; using namespace mozilla::css; static bool sNumberControlEnabled; #define NUMBER_CONTROL_PREF "dom.forms.number" @@ -472,17 +469,16 @@ nsLayoutStylesheetCache::LoadSheetFile(n if (!exists) return; nsCOMPtr<nsIURI> uri; NS_NewFileURI(getter_AddRefs(uri), aFile); LoadSheet(uri, aSheet, aParsingMode, aFailureAction); } -#ifdef MOZ_CRASHREPORTER static inline nsresult ComputeCRC32(nsIFile* aFile, uint32_t* aResult) { PRFileDesc* fd; nsresult rv = aFile->OpenNSPRFileDesc(PR_RDONLY, 0, &fd); NS_ENSURE_SUCCESS(rv, rv); uint32_t crc = crc32(0, nullptr, 0); @@ -749,36 +745,32 @@ AnnotateCrashReport(nsIURI* aURI) } } else { annotation.AppendLiteral("No GRE omnijar\n"); } CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("SheetLoadFailure"), NS_ConvertUTF16toUTF8(annotation)); } -#endif static void ErrorLoadingSheet(nsIURI* aURI, const char* aMsg, FailureAction aFailureAction) { nsPrintfCString errorMessage("%s loading built-in stylesheet '%s'", aMsg, aURI ? aURI->GetSpecOrDefault().get() : ""); if (aFailureAction == eLogToConsole) { nsCOMPtr<nsIConsoleService> cs = do_GetService(NS_CONSOLESERVICE_CONTRACTID); if (cs) { cs->LogStringMessage(NS_ConvertUTF8toUTF16(errorMessage).get()); return; } } -#ifdef MOZ_CRASHREPORTER AnnotateCrashReport(aURI); -#endif - MOZ_CRASH_UNSAFE_OOL(errorMessage.get()); } void nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI, RefPtr<StyleSheet>* aSheet, SheetParsingMode aParsingMode, FailureAction aFailureAction) @@ -795,19 +787,18 @@ nsLayoutStylesheetCache::LoadSheet(nsIUR if (!loader) { loader = new Loader(mBackendType, nullptr); if (!loader) { ErrorLoadingSheet(aURI, "no Loader", eCrash); return; } } -#ifdef MOZ_CRASHREPORTER nsZipArchive::sFileCorruptedReason = nullptr; -#endif + nsresult rv = loader->LoadSheetSync(aURI, aParsingMode, true, aSheet); if (NS_FAILED(rv)) { ErrorLoadingSheet(aURI, nsPrintfCString("LoadSheetSync failed with error %" PRIx32, static_cast<uint32_t>(rv)).get(), aFailureAction); } }
--- a/layout/xul/nsImageBoxFrame.cpp +++ b/layout/xul/nsImageBoxFrame.cpp @@ -567,30 +567,34 @@ nsDisplayXULImage::BuildLayer(nsDisplayL bool nsDisplayXULImage::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder, mozilla::wr::IpcResourceUpdateQueue& aResources, const StackingContextHelper& aSc, mozilla::layers::WebRenderLayerManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) { - ContainerLayerParameters parameter; - if (GetLayerState(aDisplayListBuilder, aManager, parameter) != LAYER_ACTIVE) { + nsImageBoxFrame* imageFrame = static_cast<nsImageBoxFrame*>(mFrame); + if (!imageFrame->CanOptimizeToImageLayer()) { + return false; + } + + if (!imageFrame->mImageRequest) { return false; } uint32_t flags = imgIContainer::FLAG_SYNC_DECODE_IF_FAST; if (aDisplayListBuilder->ShouldSyncDecodeImages()) { flags |= imgIContainer::FLAG_SYNC_DECODE; } if (aDisplayListBuilder->IsPaintingToWindow()) { flags |= imgIContainer::FLAG_HIGH_QUALITY_SCALING; } - DrawResult result = static_cast<nsImageBoxFrame*>(mFrame)-> + DrawResult result = imageFrame-> CreateWebRenderCommands(aBuilder, aResources, aSc, aManager, this, ToReferenceFrame(), flags); nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result); return true; } nsDisplayItemGeometry* nsDisplayXULImage::AllocateGeometry(nsDisplayListBuilder* aBuilder)
--- a/layout/xul/reftest/reftest.list +++ b/layout/xul/reftest/reftest.list @@ -1,6 +1,6 @@ fails-if(Android) == textbox-multiline-noresize.xul textbox-multiline-ref.xul # reference is blank on Android (due to no native theme support?) != textbox-multiline-resize.xul textbox-multiline-ref.xul == popup-explicit-size.xul popup-explicit-size-ref.xul -random-if(Android) fuzzy-if(webrender,128-128,324-540) == image-size.xul image-size-ref.xul +random-if(Android) fuzzy-if(webrender,128-128,168-168) == image-size.xul image-size-ref.xul == image-scaling-min-height-1.xul image-scaling-min-height-1-ref.xul == textbox-text-transform.xul textbox-text-transform-ref.xul
--- a/memory/gtest/TestJemalloc.cpp +++ b/memory/gtest/TestJemalloc.cpp @@ -3,43 +3,39 @@ /* 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 "mozilla/mozalloc.h" #include "mozilla/UniquePtr.h" #include "mozilla/Vector.h" #include "mozmemory.h" +#include "nsCOMPtr.h" +#include "nsICrashReporter.h" +#include "nsServiceManagerUtils.h" #include "Utils.h" #include "gtest/gtest.h" -#ifdef MOZ_CRASHREPORTER -#include "nsCOMPtr.h" -#include "nsICrashReporter.h" -#include "nsServiceManagerUtils.h" -#endif #ifdef NIGHTLY_BUILD #if defined(DEBUG) && !defined(XP_WIN) && !defined(ANDROID) #define HAS_GDB_SLEEP_DURATION 1 extern unsigned int _gdb_sleep_duration; #endif // Death tests are too slow on OSX because of the system crash reporter. #ifndef XP_DARWIN static void DisableCrashReporter() { -#ifdef MOZ_CRASHREPORTER nsCOMPtr<nsICrashReporter> crashreporter = do_GetService("@mozilla.org/toolkit/crash-reporter;1"); if (crashreporter) { crashreporter->SetEnabled(false); } -#endif } // Wrap ASSERT_DEATH_IF_SUPPORTED to disable the crash reporter // when entering the subprocess, so that the expected crashes don't // create a minidump that the gtest harness will interpret as an error. #define ASSERT_DEATH_WRAP(a, b) \ ASSERT_DEATH_IF_SUPPORTED({ DisableCrashReporter(); a; }, b) #else
--- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -1986,19 +1986,17 @@ var BrowserApp = { case "privacy.trackingprotection.state": { aSubject.setAsAString(this.getTrackingProtectionState()); break; } // Crash reporter submit pref must be fetched from nsICrashReporter // service. case "datareporting.crashreporter.submitEnabled": - let crashReporterBuilt = "nsICrashReporter" in Ci && - Services.appinfo instanceof Ci.nsICrashReporter; - if (crashReporterBuilt) { + if (AppConstants.MOZ_CRASHREPORTER) { aSubject.setAsBool(Services.appinfo.submitReports); } break; } break; } case "android-set-pref": { @@ -2041,19 +2039,17 @@ var BrowserApp = { break; } aSubject.setAsEmpty(); break; } // Crash reporter preference is in a service; set and return. case "datareporting.crashreporter.submitEnabled": - let crashReporterBuilt = "nsICrashReporter" in Ci && - Services.appinfo instanceof Ci.nsICrashReporter; - if (crashReporterBuilt) { + if (AppConstants.MOZ_CRASHREPORTER) { Services.appinfo.submitReports = value; aSubject.setAsEmpty(); } break; } break; }
--- a/mobile/android/components/SessionStore.js +++ b/mobile/android/components/SessionStore.js @@ -1234,18 +1234,17 @@ SessionStore.prototype = { aFileTemp.renameTo(null, aFile.leafName); log("_write() writing synchronously"); // Return a resolved promise to make the caller happy return Promise.resolve(); }, _updateCrashReportURL: function ss_updateCrashReportURL(aWindow) { - let crashReporterBuilt = "nsICrashReporter" in Ci && Services.appinfo instanceof Ci.nsICrashReporter; - if (!crashReporterBuilt) { + if (!AppConstants.MOZ_CRASHREPORTER) { return; } if (!aWindow.BrowserApp.selectedBrowser) { return; } try {
--- a/modules/libpref/Preferences.cpp +++ b/modules/libpref/Preferences.cpp @@ -76,20 +76,16 @@ #include "nsXPCOM.h" #include "nsXULAppAPI.h" #include "nsZipArchive.h" #include "plbase64.h" #include "PLDHashTable.h" #include "plstr.h" #include "prlink.h" -#ifdef MOZ_CRASHREPORTER -#include "nsICrashReporter.h" -#endif - #ifdef XP_WIN #include "windows.h" #endif using namespace mozilla; #ifdef DEBUG @@ -479,38 +475,49 @@ public: if (Type() == PrefType::String) { free(const_cast<char*>(mUserValue.mStringVal)); mUserValue.mStringVal = nullptr; } mHasUserValue = false; } - void SetValue(PrefType aType, - PrefValue aValue, - uint32_t aFlags, - bool* aValueChanged, - bool* aDirty) + nsresult SetValue(PrefType aType, + PrefValue aValue, + uint32_t aFlags, + bool* aValueChanged, + bool* aDirty) { if (aFlags & kPrefSetDefault) { + // Types must always match when setting the default value. + if (!IsType(aType)) { + return NS_ERROR_UNEXPECTED; + } + if (!IsLocked()) { // ?? change of semantics? if (!mHasDefaultValue || !mDefaultValue.Equals(aType, aValue)) { ReplaceValue(PrefValueKind::Default, aType, aValue); if (aFlags & kPrefSticky) { mIsSticky = true; } if (!mHasUserValue) { *aValueChanged = true; } } // What if we change the default to be the same as the user value? // Should we clear the user value? } } else { + // If we have a default value, types must match when setting the user + // value. + if (mHasDefaultValue && !IsType(aType)) { + return NS_ERROR_UNEXPECTED; + } + // If new value is same as the default value and it's not a "sticky" // pref, then un-set the user value. Otherwise, set the user value only // if it has changed. if (mHasDefaultValue && !mIsSticky && mDefaultValue.Equals(aType, aValue) && !(aFlags & kPrefForceSet)) { if (mHasUserValue) { ClearUserValue(); if (!IsLocked()) { @@ -522,16 +529,17 @@ public: !mUserValue.Equals(aType, aValue)) { ReplaceValue(PrefValueKind::User, aType, aValue); if (!IsLocked()) { *aDirty = true; *aValueChanged = true; } } } + return NS_OK; } // Returns false if this pref doesn't have a user value worth saving. bool UserValueToStringForSaving(nsCString& aStr) { if (mHasUserValue && (!mHasDefaultValue || mIsSticky || !mDefaultValue.Equals(Type(), mUserValue))) { if (IsTypeString()) { @@ -752,33 +760,34 @@ pref_SetPref(const char* aPrefName, auto pref = static_cast<PrefHashEntry*>(gHashTable->Add(aPrefName, fallible)); if (!pref) { return NS_ERROR_OUT_OF_MEMORY; } if (!pref->Name()) { // New (zeroed) entry. Initialize it. new (pref) PrefHashEntry(aPrefName, aType); - - } else if (pref->HasDefaultValue() && !pref->IsType(aType)) { + } + + bool valueChanged = false, handleDirty = false; + nsresult rv = + pref->SetValue(aType, aValue, aFlags, &valueChanged, &handleDirty); + if (NS_FAILED(rv)) { NS_WARNING( nsPrintfCString( - "Ignoring attempt to overwrite value of default pref %s (type %s) with " - "the wrong type (%s)!", + "Rejected attempt to change type of pref %s's %s value from %s to %s", aPrefName, + (aFlags & kPrefSetDefault) ? "default" : "user", PrefTypeToString(pref->Type()), PrefTypeToString(aType)) .get()); - return NS_ERROR_UNEXPECTED; + return rv; } - bool valueChanged = false, handleDirty = false; - pref->SetValue(aType, aValue, aFlags, &valueChanged, &handleDirty); - if (handleDirty) { Preferences::HandleDirty(); } if (valueChanged) { NotifyCallbacks(aPrefName); } return NS_OK;
--- a/modules/libpref/test/unit/test_changeType.js +++ b/modules/libpref/test/unit/test_changeType.js @@ -12,52 +12,130 @@ const PREF_STRING = 32; function run_test() { var ps = Cc["@mozilla.org/preferences-service;1"]. getService(Ci.nsIPrefService); let defaultBranch = ps.getDefaultBranch(""); let userBranch = ps.getBranch(""); - //**************************************************************************// - // Can't change the type of prefs that have default values + // Prefs that only have a default value -- we can't change their type. + defaultBranch.setBoolPref("TypeTest.default.bool", true); + defaultBranch.setIntPref("TypeTest.default.int", 23); + defaultBranch.setCharPref("TypeTest.default.char", "hey"); + + do_check_eq(userBranch.getBoolPref("TypeTest.default.bool"), true); + do_check_eq(userBranch.getIntPref("TypeTest.default.int"), 23); + do_check_eq(userBranch.getCharPref("TypeTest.default.char"), "hey"); - defaultBranch.setBoolPref("TypeTest.existing.bool", true); - defaultBranch.setIntPref("TypeTest.existing.int", 23); - defaultBranch.setCharPref("TypeTest.existing.char", "hey"); + // Prefs that only have a user value -- we can change their type, but only + // when we set the user value. + userBranch.setBoolPref("TypeTest.user.bool", false); + userBranch.setIntPref("TypeTest.user.int", 24); + userBranch.setCharPref("TypeTest.user.char", "hi"); + + do_check_eq(userBranch.getBoolPref("TypeTest.user.bool"), false); + do_check_eq(userBranch.getIntPref("TypeTest.user.int"), 24); + do_check_eq(userBranch.getCharPref("TypeTest.user.char"), "hi"); + + // Prefs that have both a default and a user value -- we can't change their + // type. + defaultBranch.setBoolPref("TypeTest.both.bool", true); + userBranch.setBoolPref("TypeTest.both.bool", false); + defaultBranch.setIntPref("TypeTest.both.int", 25); + userBranch.setIntPref("TypeTest.both.int", 26); + defaultBranch.setCharPref("TypeTest.both.char", "yo"); + userBranch.setCharPref("TypeTest.both.char", "ya"); - // The user branch reads back the expected default - do_check_eq(userBranch.getBoolPref("TypeTest.existing.bool"), true); - do_check_eq(userBranch.getIntPref("TypeTest.existing.int"), 23); - do_check_eq(userBranch.getCharPref("TypeTest.existing.char"), "hey"); + do_check_eq(userBranch.getBoolPref("TypeTest.both.bool"), false); + do_check_eq(userBranch.getIntPref("TypeTest.both.int"), 26); + do_check_eq(userBranch.getCharPref("TypeTest.both.char"), "ya"); - // All the combinations of attempted type changes + // We only have a default value, and we try to set a default value of a + // different type --> fails. + do_check_throws(function() { + defaultBranch.setCharPref("TypeTest.default.bool", "boo"); }, Cr.NS_ERROR_UNEXPECTED); + do_check_throws(function() { + defaultBranch.setIntPref("TypeTest.default.bool", 5); }, Cr.NS_ERROR_UNEXPECTED); + do_check_throws(function() { + defaultBranch.setCharPref("TypeTest.default.int", "boo"); }, Cr.NS_ERROR_UNEXPECTED); + do_check_throws(function() { + defaultBranch.setBoolPref("TypeTest.default.int", true); }, Cr.NS_ERROR_UNEXPECTED); do_check_throws(function() { - userBranch.setCharPref("TypeTest.existing.bool", "boo"); }, Cr.NS_ERROR_UNEXPECTED); + defaultBranch.setBoolPref("TypeTest.default.char", true); }, Cr.NS_ERROR_UNEXPECTED); do_check_throws(function() { - userBranch.setIntPref("TypeTest.existing.bool", 5); }, Cr.NS_ERROR_UNEXPECTED); + defaultBranch.setIntPref("TypeTest.default.char", 6); }, Cr.NS_ERROR_UNEXPECTED); + + // We only have a default value, and we try to set a user value of a + // different type --> fails. do_check_throws(function() { - userBranch.setCharPref("TypeTest.existing.int", "boo"); }, Cr.NS_ERROR_UNEXPECTED); + userBranch.setCharPref("TypeTest.default.bool", "boo"); }, Cr.NS_ERROR_UNEXPECTED); + do_check_throws(function() { + userBranch.setIntPref("TypeTest.default.bool", 5); }, Cr.NS_ERROR_UNEXPECTED); do_check_throws(function() { - userBranch.setBoolPref("TypeTest.existing.int", true); }, Cr.NS_ERROR_UNEXPECTED); + userBranch.setCharPref("TypeTest.default.int", "boo"); }, Cr.NS_ERROR_UNEXPECTED); + do_check_throws(function() { + userBranch.setBoolPref("TypeTest.default.int", true); }, Cr.NS_ERROR_UNEXPECTED); + do_check_throws(function() { + userBranch.setBoolPref("TypeTest.default.char", true); }, Cr.NS_ERROR_UNEXPECTED); do_check_throws(function() { - userBranch.setBoolPref("TypeTest.existing.char", true); }, Cr.NS_ERROR_UNEXPECTED); + userBranch.setIntPref("TypeTest.default.char", 6); }, Cr.NS_ERROR_UNEXPECTED); + + // We only have a user value, and we try to set a default value of a + // different type --> fails. + do_check_throws(function() { + defaultBranch.setCharPref("TypeTest.user.bool", "boo"); }, Cr.NS_ERROR_UNEXPECTED); do_check_throws(function() { - userBranch.setIntPref("TypeTest.existing.char", 6); }, Cr.NS_ERROR_UNEXPECTED); - + defaultBranch.setIntPref("TypeTest.user.bool", 5); }, Cr.NS_ERROR_UNEXPECTED); + do_check_throws(function() { + defaultBranch.setCharPref("TypeTest.user.int", "boo"); }, Cr.NS_ERROR_UNEXPECTED); + do_check_throws(function() { + defaultBranch.setBoolPref("TypeTest.user.int", true); }, Cr.NS_ERROR_UNEXPECTED); + do_check_throws(function() { + defaultBranch.setBoolPref("TypeTest.user.char", true); }, Cr.NS_ERROR_UNEXPECTED); + do_check_throws(function() { + defaultBranch.setIntPref("TypeTest.user.char", 6); }, Cr.NS_ERROR_UNEXPECTED); - //**************************************************************************// - // Prefs that don't have default values can mutate - let pref = "TypeTest.user"; - userBranch.setBoolPref(pref, true); - userBranch.setCharPref(pref, "yay"); - do_check_eq(userBranch.getCharPref(pref), "yay"); - userBranch.setIntPref(pref, 7); - do_check_eq(userBranch.getIntPref(pref), 7); - userBranch.setBoolPref(pref, false); - do_check_eq(userBranch.getBoolPref(pref), false); - userBranch.setIntPref(pref, 8); - do_check_eq(userBranch.getIntPref(pref), 8); - userBranch.setCharPref(pref, "whee"); - do_check_eq(userBranch.getCharPref(pref), "whee"); - userBranch.setBoolPref(pref, true); - do_check_eq(userBranch.getBoolPref(pref), true); + // We only have a user value, and we try to set a user value of a + // different type --> SUCCEEDS. + userBranch.setCharPref("TypeTest.user.bool", "boo"); + do_check_eq(userBranch.getCharPref("TypeTest.user.bool"), "boo"); + userBranch.setIntPref("TypeTest.user.bool", 5); + do_check_eq(userBranch.getIntPref("TypeTest.user.bool"), 5); + userBranch.setCharPref("TypeTest.user.int", "boo"); + do_check_eq(userBranch.getCharPref("TypeTest.user.int"), "boo"); + userBranch.setBoolPref("TypeTest.user.int", true); + do_check_eq(userBranch.getBoolPref("TypeTest.user.int"), true); + userBranch.setBoolPref("TypeTest.user.char", true); + do_check_eq(userBranch.getBoolPref("TypeTest.user.char"), true); + userBranch.setIntPref("TypeTest.user.char", 6); + do_check_eq(userBranch.getIntPref("TypeTest.user.char"), 6); + + // We have both a default value and user value, and we try to set a default + // value of a different type --> fails. + do_check_throws(function() { + defaultBranch.setCharPref("TypeTest.both.bool", "boo"); }, Cr.NS_ERROR_UNEXPECTED); + do_check_throws(function() { + defaultBranch.setIntPref("TypeTest.both.bool", 5); }, Cr.NS_ERROR_UNEXPECTED); + do_check_throws(function() { + defaultBranch.setCharPref("TypeTest.both.int", "boo"); }, Cr.NS_ERROR_UNEXPECTED); + do_check_throws(function() { + defaultBranch.setBoolPref("TypeTest.both.int", true); }, Cr.NS_ERROR_UNEXPECTED); + do_check_throws(function() { + defaultBranch.setBoolPref("TypeTest.both.char", true); }, Cr.NS_ERROR_UNEXPECTED); + do_check_throws(function() { + defaultBranch.setIntPref("TypeTest.both.char", 6); }, Cr.NS_ERROR_UNEXPECTED); + + // We have both a default value and user value, and we try to set a user + // value of a different type --> fails. + do_check_throws(function() { + userBranch.setCharPref("TypeTest.both.bool", "boo"); }, Cr.NS_ERROR_UNEXPECTED); + do_check_throws(function() { + userBranch.setIntPref("TypeTest.both.bool", 5); }, Cr.NS_ERROR_UNEXPECTED); + do_check_throws(function() { + userBranch.setCharPref("TypeTest.both.int", "boo"); }, Cr.NS_ERROR_UNEXPECTED); + do_check_throws(function() { + userBranch.setBoolPref("TypeTest.both.int", true); }, Cr.NS_ERROR_UNEXPECTED); + do_check_throws(function() { + userBranch.setBoolPref("TypeTest.both.char", true); }, Cr.NS_ERROR_UNEXPECTED); + do_check_throws(function() { + userBranch.setIntPref("TypeTest.both.char", 6); }, Cr.NS_ERROR_UNEXPECTED); }
--- a/netwerk/ipc/NeckoMessageUtils.h +++ b/netwerk/ipc/NeckoMessageUtils.h @@ -4,25 +4,23 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef mozilla_net_NeckoMessageUtils_h #define mozilla_net_NeckoMessageUtils_h #include "mozilla/DebugOnly.h" #include "ipc/IPCMessageUtils.h" +#include "nsExceptionHandler.h" +#include "nsPrintfCString.h" #include "nsStringGlue.h" #include "prio.h" #include "mozilla/net/DNS.h" #include "TimingStruct.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#include "nsPrintfCString.h" -#endif namespace IPC { // nsIPermissionManager utilities struct Permission { nsCString origin, type; @@ -97,22 +95,21 @@ struct ParamTraits<mozilla::net::NetAddr #if defined(XP_UNIX) } else if (aParam.raw.family == AF_LOCAL) { // Train's already off the rails: let's get a stack trace at least... MOZ_CRASH("Error: please post stack trace to " "https://bugzilla.mozilla.org/show_bug.cgi?id=661158"); aMsg->WriteBytes(aParam.local.path, sizeof(aParam.local.path)); #endif } else { -#ifdef MOZ_CRASHREPORTER if (XRE_IsParentProcess()) { nsPrintfCString msg("%d", aParam.raw.family); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Unknown NetAddr socket family"), msg); } -#endif + MOZ_CRASH("Unknown socket family"); } } static bool Read(const Message* aMsg, PickleIterator* aIter, mozilla::net::NetAddr* aResult) { if (!ReadParam(aMsg, aIter, &aResult->raw.family)) return false;
--- a/security/sandbox/linux/glue/SandboxCrash.cpp +++ b/security/sandbox/linux/glue/SandboxCrash.cpp @@ -13,19 +13,17 @@ #include "SandboxLogging.h" #include <unistd.h> #include <sys/syscall.h> #include "mozilla/Unused.h" #include "mozilla/dom/Exceptions.h" #include "nsContentUtils.h" -#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" -#endif #include "mozilla/StackWalk.h" #include "nsString.h" #include "nsThreadUtils.h" namespace mozilla { // Log JS stack info in the same place as the sandbox violation // message. Useful in case the responsible code is JS and all we have @@ -101,21 +99,18 @@ SandboxLogCStack() MozStackWalk(SandboxPrintStackFrame, /* skip */ 3, /* max */ 0, nullptr); SANDBOX_LOG_ERROR("end of stack."); } static void SandboxCrash(int nr, siginfo_t *info, void *void_context) { pid_t pid = getpid(), tid = syscall(__NR_gettid); - bool dumped = false; + bool dumped = CrashReporter::WriteMinidumpForSigInfo(nr, info, void_context); -#ifdef MOZ_CRASHREPORTER - dumped = CrashReporter::WriteMinidumpForSigInfo(nr, info, void_context); -#endif if (!dumped) { SANDBOX_LOG_ERROR("crash reporter is disabled (or failed);" " trying stack trace:"); SandboxLogCStack(); } // Do this last, in case it crashes or deadlocks. SandboxLogJSStack();
--- a/storage/mozStorageService.cpp +++ b/storage/mozStorageService.cpp @@ -7,34 +7,31 @@ #include "mozilla/Attributes.h" #include "mozilla/DebugOnly.h" #include "mozStorageService.h" #include "mozStorageConnection.h" #include "nsAutoPtr.h" #include "nsCollationCID.h" #include "nsEmbedCID.h" +#include "nsExceptionHandler.h" #include "nsThreadUtils.h" #include "mozStoragePrivateHelpers.h" #include "nsIXPConnect.h" #include "nsIObserverService.h" #include "nsIPropertyBag2.h" #include "mozilla/Services.h" #include "mozilla/Preferences.h" #include "mozilla/LateWriteChecks.h" #include "mozIStorageCompletionCallback.h" #include "mozIStoragePendingStatement.h" #include "sqlite3.h" #include "mozilla/AutoSQLiteLifetime.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - #ifdef XP_WIN // "windows.h" was included and it can #define lots of things we care about... #undef CompareString #endif #include "nsIPromptService.h" //////////////////////////////////////////////////////////////////////////////// @@ -796,23 +793,21 @@ Service::Observe(nsISupports *, const ch return true; }); if (gShutdownChecks == SCM_CRASH) { nsTArray<RefPtr<Connection> > connections; getConnections(connections); for (uint32_t i = 0, n = connections.Length(); i < n; i++) { if (!connections[i]->isClosed()) { -#ifdef MOZ_CRASHREPORTER // getFilename is only the leaf name for the database file, // so it shouldn't contain privacy-sensitive information. CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("StorageConnectionNotClosed"), connections[i]->getFilename()); -#endif #ifdef DEBUG printf_stderr("Storage connection not closed: %s", connections[i]->getFilename().get()); #endif MOZ_CRASH(); } } }
--- a/testing/gtest/mozilla/GTestRunner.cpp +++ b/testing/gtest/mozilla/GTestRunner.cpp @@ -1,19 +1,17 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * 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 "GTestRunner.h" #include "gtest/gtest.h" #include "mozilla/Attributes.h" -#ifdef MOZ_CRASHREPORTER #include "nsICrashReporter.h" -#endif #include "testing/TestHarness.h" #include "prenv.h" #ifdef XP_WIN #include "mozilla/ipc/WindowsMessageLoop.h" #endif using ::testing::EmptyTestEventListener; using ::testing::InitGoogleTest; @@ -86,17 +84,16 @@ int RunGTestFunc(int* argc, char** argv) PR_SetEnv("XPCOM_DEBUG_BREAK=stack-and-abort"); ScopedXPCOM xpcom("GTest"); #ifdef XP_WIN mozilla::ipc::windows::InitUIThread(); #endif -#ifdef MOZ_CRASHREPORTER nsCOMPtr<nsICrashReporter> crashreporter; char *crashreporterStr = PR_GetEnv("MOZ_CRASHREPORTER"); if (crashreporterStr && !strcmp(crashreporterStr, "1")) { //TODO: move this to an even-more-common location to use in all // C++ unittests crashreporter = do_GetService("@mozilla.org/toolkit/crash-reporter;1"); if (crashreporter) { std::cerr << "Setting up crash reporting" << std::endl; @@ -107,17 +104,16 @@ int RunGTestFunc(int* argc, char** argv) nsresult rv = dirsvc->Get(NS_OS_CURRENT_WORKING_DIR, NS_GET_IID(nsIFile), getter_AddRefs(cwd)); MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv)); crashreporter->SetEnabled(true); crashreporter->SetMinidumpPath(cwd); } } -#endif return RUN_ALL_TESTS(); } // We use a static var 'RunGTest' defined in nsAppRunner.cpp. // RunGTest is initialized to nullptr but if GTest (this file) // is linked in then RunGTest will be set here indicating // GTest is supported.
--- a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm +++ b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm @@ -1083,17 +1083,17 @@ this.BrowserTestUtils = { // we might see this called as the process terminates due to previous tests. // We are only looking for "abnormal" exits... if (!subject.hasKey("abnormal")) { dump("\nThis is a normal termination and isn't the one we are looking for...\n"); return; } let dumpID; - if ('nsICrashReporter' in Ci) { + if (AppConstants.MOZ_CRASHREPORTER) { dumpID = subject.getPropertyAsAString('dumpID'); if (!dumpID) { return reject("dumpID was not present despite crash reporting " + "being enabled"); } } let removalPromise = Promise.resolve();
--- a/toolkit/components/crashes/moz.build +++ b/toolkit/components/crashes/moz.build @@ -1,31 +1,33 @@ # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- # vim: set filetype=python: # 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/. SPHINX_TREES['crash-manager'] = 'docs' -EXTRA_COMPONENTS += [ - 'CrashService.js', - 'CrashService.manifest', -] - -EXTRA_JS_MODULES += [ - 'CrashManager.jsm', -] - -TESTING_JS_MODULES += [ - 'CrashManagerTest.jsm', -] - -XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell/xpcshell.ini'] - XPIDL_MODULE = 'toolkit_crashservice' XPIDL_SOURCES += [ 'nsICrashService.idl', ] +if CONFIG['MOZ_CRASHREPORTER']: + EXTRA_COMPONENTS += [ + 'CrashService.js', + 'CrashService.manifest', + ] + + EXTRA_JS_MODULES += [ + 'CrashManager.jsm', + ] + + TESTING_JS_MODULES += [ + 'CrashManagerTest.jsm', + ] + + XPCSHELL_TESTS_MANIFESTS += ['tests/xpcshell/xpcshell.ini'] + with Files('**'): BUG_COMPONENT = ('Toolkit', 'Crash Reporting') +
--- a/toolkit/components/moz.build +++ b/toolkit/components/moz.build @@ -21,16 +21,17 @@ DIRS += [ 'apppicker', 'asyncshutdown', 'backgroundhangmonitor', 'browser', 'cloudstorage', 'commandlines', 'contentprefs', 'contextualidentity', + 'crashes', 'crashmonitor', 'diskspacewatcher', 'downloads', 'extensions', 'filewatcher', 'finalizationwitness', 'find', 'jsdownloads', @@ -75,19 +76,16 @@ DIRS += [ ] if CONFIG['MOZ_BUILD_APP'] != 'mobile/android': DIRS += ['narrate', 'viewsource']; if CONFIG['NS_PRINTING']: DIRS += ['printing'] -if CONFIG['MOZ_CRASHREPORTER']: - DIRS += ['crashes'] - if CONFIG['BUILD_CTYPES']: DIRS += ['ctypes'] if CONFIG['MOZ_FEEDS']: DIRS += ['feeds'] if CONFIG['MOZ_XUL']: DIRS += ['autocomplete', 'printingui', 'satchel']
--- a/toolkit/components/places/tests/gtest/places_test_harness_tail.h +++ b/toolkit/components/places/tests/gtest/places_test_harness_tail.h @@ -1,19 +1,17 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ : * 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 "nsWidgetsCID.h" #include "nsIComponentRegistrar.h" -#ifdef MOZ_CRASHREPORTER #include "nsICrashReporter.h" -#endif #ifndef TEST_NAME #error "Must #define TEST_NAME before including places_test_harness_tail.h" #endif int gTestsIndex = 0; #define TEST_INFO_STR "TEST-INFO | "
--- a/toolkit/components/telemetry/Scalars.yaml +++ b/toolkit/components/telemetry/Scalars.yaml @@ -1353,16 +1353,49 @@ timestamps: expires: never kind: uint notification_emails: - hkirschner@mozilla.com release_channel_collection: opt-out record_in_processes: - main +# The following section contains the service worker scalars. +sw: + synthesized_res_count: + bug_numbers: + - 1416629 + description: > + The count of number of synthesize response made by service workers. + expires: "61" + kind: uint + notification_emails: + - sw-telemetry@mozilla.com + - ttung@mozilla.com + release_channel_collection: opt-out + record_in_processes: + - 'main' + - 'content' + + cors_res_for_so_req_count: + bug_numbers: + - 1416629 + description: > + The count of number of synthesize response made by service workers and + it's a cors type resposne for a same-origin mode request. + expires: "61" + kind: uint + notification_emails: + - sw-telemetry@mozilla.com + - ttung@mozilla.com + release_channel_collection: opt-out + record_in_processes: + - 'main' + - 'content' + # The following section is for probes testing the Telemetry system. They will not be # submitted in pings and are only used for testing. telemetry.test: unsigned_int_kind: bug_numbers: - 1276190 description: > This is a test uint type with a really long description, maybe spanning even multiple
--- a/toolkit/components/terminator/nsTerminator.cpp +++ b/toolkit/components/terminator/nsTerminator.cpp @@ -24,19 +24,17 @@ #include "nsString.h" #include "nsServiceManagerUtils.h" #include "nsDirectoryServiceUtils.h" #include "nsAppDirectoryServiceDefs.h" #include "nsIObserverService.h" #include "nsIPrefService.h" -#if defined(MOZ_CRASHREPORTER) #include "nsExceptionHandler.h" -#endif #include "GeckoProfiler.h" #include "nsThreadUtils.h" #if defined(XP_WIN) #include <windows.h> #else #include <unistd.h> #endif @@ -160,19 +158,18 @@ RunWatchdog(void* arg) mozilla::dom::workers::RuntimeService* runtimeService = mozilla::dom::workers::RuntimeService::GetService(); if (runtimeService) { runtimeService->CrashIfHanging(); } // Shutdown is apparently dead. Crash the process. -#if defined(MOZ_CRASHREPORTER) CrashReporter::SetMinidumpAnalysisAllThreads(); -#endif + MOZ_CRASH("Shutdown too long, probably frozen, causing a crash."); } } //////////////////////////////////////////// // // Writer thread // @@ -550,19 +547,17 @@ nsTerminator::UpdateTelemetry() PR_EnterMonitor(gWriteReady); PR_Notify(gWriteReady); PR_ExitMonitor(gWriteReady); } void nsTerminator::UpdateCrashReport(const char* aTopic) { -#if defined(MOZ_CRASHREPORTER) // In case of crash, we wish to know where in shutdown we are nsAutoCString report(aTopic); Unused << CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ShutdownProgress"), report); -#endif // defined(MOZ_CRASHREPORTER) } } // namespace mozilla
--- a/toolkit/crashreporter/jar.mn +++ b/toolkit/crashreporter/jar.mn @@ -1,7 +1,9 @@ # 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/. toolkit.jar: +#ifdef MOZ_CRASHREPORTER content/global/crashes.xhtml (content/crashes.xhtml) content/global/crashes.js (content/crashes.js) +#endif
--- a/toolkit/crashreporter/moz.build +++ b/toolkit/crashreporter/moz.build @@ -1,115 +1,125 @@ # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- # vim: set filetype=python: # 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/. SPHINX_TREES['crashreporter'] = 'docs' -if CONFIG['OS_ARCH'] == 'WINNT': - DIRS += [ - 'google-breakpad/src/common', - 'google-breakpad/src/processor', - 'breakpad-windows-libxul', - ] - - if CONFIG['MSVC_HAS_DIA_SDK']: - DIRS += ['google-breakpad/src/tools/windows/dump_syms'] - - if CONFIG['MOZ_CRASHREPORTER_INJECTOR']: - DIRS += ['breakpad-windows-standalone'] - -elif CONFIG['OS_ARCH'] == 'Darwin': - DIRS += [ - 'breakpad-client', - 'breakpad-client/mac/crash_generation', - 'breakpad-client/mac/handler', - 'google-breakpad/src/common', - 'google-breakpad/src/common/mac', - 'google-breakpad/src/processor', - 'google-breakpad/src/tools/mac/dump_syms', - ] - -elif CONFIG['OS_ARCH'] == 'Linux': - DIRS += [ - 'breakpad-client', - 'breakpad-client/linux/', - 'google-breakpad/src/common', - 'google-breakpad/src/common/linux', - 'google-breakpad/src/processor', - 'google-breakpad/src/tools/linux/dump_syms', - ] - - -DIRS += [ - 'client', - 'minidump-analyzer', -] - -if CONFIG['MOZ_CRASHREPORTER_INJECTOR']: - DIRS += ['injector'] - UNIFIED_SOURCES += [ - 'InjectCrashReporter.cpp', - 'LoadLibraryRemote.cpp', - ] - -if CONFIG['ENABLE_TESTS']: - DIRS += ['test/gtest'] - -TEST_DIRS += ['test'] - EXPORTS += [ 'nsExceptionHandler.h', ] -UNIFIED_SOURCES += [ - 'nsExceptionHandler.cpp', - 'ThreadAnnotation.cpp', -] +JAR_MANIFESTS += ['jar.mn'] -if CONFIG['OS_ARCH'] == 'Darwin': - UNIFIED_SOURCES += [ - 'mac_utils.mm', - ] - -EXTRA_JS_MODULES += [ - 'CrashReports.jsm', - 'CrashSubmit.jsm', - 'KeyValueParser.jsm', +UNIFIED_SOURCES = [ + 'nsExceptionHandlerUtils.cpp', ] -include('/ipc/chromium/chromium-config.mozbuild') - FINAL_LIBRARY = 'xul' -if CONFIG['OS_TARGET'] == 'Android': - DEFINES['ANDROID_NDK_MAJOR_VERSION'] = CONFIG['ANDROID_NDK_MAJOR_VERSION'] - DEFINES['ANDROID_NDK_MINOR_VERSION'] = CONFIG['ANDROID_NDK_MINOR_VERSION'] - DEFINES['ANDROID_PACKAGE_NAME'] = '"%s"' % CONFIG['ANDROID_PACKAGE_NAME'] - # NDK5 workarounds - DEFINES['_STLP_CONST_CONSTRUCTOR_BUG'] = True - DEFINES['_STLP_NO_MEMBER_TEMPLATES'] = True - LOCAL_INCLUDES += [ - '/toolkit/crashreporter/google-breakpad/src/common/android/include', +if CONFIG['MOZ_CRASHREPORTER']: + if CONFIG['OS_ARCH'] == 'WINNT': + DIRS += [ + 'google-breakpad/src/common', + 'google-breakpad/src/processor', + 'breakpad-windows-libxul', + ] + + if CONFIG['MSVC_HAS_DIA_SDK']: + DIRS += ['google-breakpad/src/tools/windows/dump_syms'] + + if CONFIG['MOZ_CRASHREPORTER_INJECTOR']: + DIRS += ['breakpad-windows-standalone'] + + elif CONFIG['OS_ARCH'] == 'Darwin': + DIRS += [ + 'breakpad-client', + 'breakpad-client/mac/crash_generation', + 'breakpad-client/mac/handler', + 'google-breakpad/src/common', + 'google-breakpad/src/common/mac', + 'google-breakpad/src/processor', + 'google-breakpad/src/tools/mac/dump_syms', + ] + + elif CONFIG['OS_ARCH'] == 'Linux': + DIRS += [ + 'breakpad-client', + 'breakpad-client/linux/', + 'google-breakpad/src/common', + 'google-breakpad/src/common/linux', + 'google-breakpad/src/processor', + 'google-breakpad/src/tools/linux/dump_syms', + ] + + + DIRS += [ + 'client', + 'minidump-analyzer', ] -DEFINES['UNICODE'] = True -DEFINES['_UNICODE'] = True + if CONFIG['MOZ_CRASHREPORTER_INJECTOR']: + DIRS += ['injector'] + UNIFIED_SOURCES += [ + 'InjectCrashReporter.cpp', + 'LoadLibraryRemote.cpp', + ] + + if CONFIG['ENABLE_TESTS']: + DIRS += ['test/gtest'] + + TEST_DIRS += ['test'] -JAR_MANIFESTS += ['jar.mn'] + UNIFIED_SOURCES += [ + 'nsExceptionHandler.cpp', + 'ThreadAnnotation.cpp', + ] + + if CONFIG['OS_ARCH'] == 'Darwin': + UNIFIED_SOURCES += [ + 'mac_utils.mm', + ] + + EXTRA_JS_MODULES += [ + 'CrashReports.jsm', + 'CrashSubmit.jsm', + 'KeyValueParser.jsm', + ] + + include('/ipc/chromium/chromium-config.mozbuild') -LOCAL_INCLUDES += [ - 'google-breakpad/src', -] + if CONFIG['OS_TARGET'] == 'Android': + DEFINES['ANDROID_NDK_MAJOR_VERSION'] = CONFIG['ANDROID_NDK_MAJOR_VERSION'] + DEFINES['ANDROID_NDK_MINOR_VERSION'] = CONFIG['ANDROID_NDK_MINOR_VERSION'] + DEFINES['ANDROID_PACKAGE_NAME'] = '"%s"' % CONFIG['ANDROID_PACKAGE_NAME'] + # NDK5 workarounds + DEFINES['_STLP_CONST_CONSTRUCTOR_BUG'] = True + DEFINES['_STLP_NO_MEMBER_TEMPLATES'] = True + LOCAL_INCLUDES += [ + '/toolkit/crashreporter/google-breakpad/src/common/android/include', + ] + + DEFINES['UNICODE'] = True + DEFINES['_UNICODE'] = True -PYTHON_UNITTEST_MANIFESTS += [ - 'tools/python.ini', -] + LOCAL_INCLUDES += [ + 'google-breakpad/src', + ] + + PYTHON_UNITTEST_MANIFESTS += [ + 'tools/python.ini', + ] -include('/toolkit/crashreporter/crashreporter.mozbuild') + include('/toolkit/crashreporter/crashreporter.mozbuild') + + if CONFIG['GNU_CXX']: + CXXFLAGS += ['-Wno-shadow'] +else: + UNIFIED_SOURCES += [ + 'nsDummyExceptionHandler.cpp', + ] + with Files('**'): BUG_COMPONENT = ('Toolkit', 'Crash Reporting') - -if CONFIG['GNU_CXX']: - CXXFLAGS += ['-Wno-shadow']
new file mode 100644 --- /dev/null +++ b/toolkit/crashreporter/nsDummyExceptionHandler.cpp @@ -0,0 +1,425 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* 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 "nsExceptionHandler.h" +#include "nsExceptionHandlerUtils.h" + +namespace CrashReporter { + +void +AnnotateOOMAllocationSize(size_t size) +{ +} + +void +AnnotateTexturesSize(size_t size) +{ +} + +void +AnnotatePendingIPC(size_t aNumOfPendingIPC, + uint32_t aTopPendingIPCCount, + const char* aTopPendingIPCName, + uint32_t aTopPendingIPCType) +{ +} + +nsresult +SetExceptionHandler(nsIFile* aXREDirectory, + bool force/*=false*/) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +bool +GetEnabled() +{ + return false; +} + +bool +GetMinidumpPath(nsAString& aPath) +{ + return false; +} + +nsresult +SetMinidumpPath(const nsAString& aPath) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +nsresult +SetupExtraData(nsIFile* aAppDataDirectory, + const nsACString& aBuildID) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +nsresult +UnsetExceptionHandler() +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +nsresult +AnnotateCrashReport(const nsACString& key, + const nsACString& data) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +nsresult +RemoveCrashReportAnnotation(const nsACString& key) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +nsresult +SetGarbageCollecting(bool collecting) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +void +SetEventloopNestingLevel(uint32_t level) +{ +} + +void +SetMinidumpAnalysisAllThreads() +{ +} + +nsresult +AppendAppNotesToCrashReport(const nsACString& data) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +bool +GetAnnotation(const nsACString& key, nsACString& data) +{ + return false; +} + +nsresult +RegisterAppMemory(void* ptr, size_t length) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +nsresult +UnregisterAppMemory(void* ptr) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +void +SetIncludeContextHeap(bool aValue) +{ +} + +bool +GetServerURL(nsACString& aServerURL) +{ + return false; +} + +nsresult +SetServerURL(const nsACString& aServerURL) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +nsresult +SetRestartArgs(int argc, char** argv) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +#ifdef XP_WIN32 +nsresult +WriteMinidumpForException(EXCEPTION_POINTERS* aExceptionInfo) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +#endif + +#ifdef XP_LINUX +bool +WriteMinidumpForSigInfo(int signo, + siginfo_t* info, + void* uc) +{ + return false; +} +#endif + +#ifdef XP_MACOSX +nsresult +AppendObjCExceptionInfoToAppNotes(void *inException) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} +#endif + +nsresult +GetSubmitReports(bool* aSubmitReports) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +nsresult +SetSubmitReports(bool aSubmitReports) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +void +SetProfileDirectory(nsIFile* aDir) +{ +} + +void +SetUserAppDataDirectory(nsIFile* aDir) +{ +} + +void +UpdateCrashEventsDir() +{ +} + +bool +GetCrashEventsDir(nsAString& aPath) +{ + return false; +} + +void +SetMemoryReportFile(nsIFile* aFile) +{ +} + +nsresult +GetDefaultMemoryReportFile(nsIFile** aFile) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +void +SetTelemetrySessionId(const nsACString& id) +{ +} + +void +DeleteMinidumpFilesForID(const nsAString& id) +{ +} + +bool +GetMinidumpForID(const nsAString& id, nsIFile** minidump) +{ + return false; +} + +bool +GetIDFromMinidump(nsIFile* minidump, nsAString& id) +{ + return false; +} + +bool +GetExtraFileForID(const nsAString& id, + nsIFile** extraFile) +{ + return false; +} + +bool +GetExtraFileForMinidump(nsIFile* minidump, + nsIFile** extraFile) +{ + return false; +} + +bool +AppendExtraData(const nsAString& id, + const AnnotationTable& data) +{ + return false; +} + +bool +AppendExtraData(nsIFile* extraFile, + const AnnotationTable& data) +{ + return false; +} + +void +OOPInit() +{ +} + +void +GetChildProcessTmpDir(nsIFile** aOutTmpDir) +{ +} + +#if defined(XP_WIN) || defined(XP_MACOSX) +const char* +GetChildNotificationPipe() +{ + return nullptr; +} +#endif + +#ifdef MOZ_CRASHREPORTER_INJECTOR +void +InjectCrashReporterIntoProcess(DWORD processID, InjectorCrashCallback* cb) +{ +} + +void +UnregisterInjectorCallback(DWORD processID) +{ +} + +#endif // MOZ_CRASHREPORTER_INJECTOR + +bool +GetLastRunCrashID(nsAString& id) +{ + return false; +} + +#if defined(XP_WIN) || defined(XP_MACOSX) +void +InitChildProcessTmpDir(nsIFile* aDirOverride) +{ +} +#endif // defined(XP_WIN) || defined(XP_MACOSX) + +#if defined(XP_WIN) +bool +SetRemoteExceptionHandler(const nsACString& crashPipe) +{ + return false; +} + +#elif defined(XP_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS) + +bool +CreateNotificationPipeForChild(int* childCrashFd, int* childCrashRemapFd) +{ + return false; +} + +bool +SetRemoteExceptionHandler() +{ + return false; +} + +#elif defined(XP_MACOSX) + +bool +SetRemoteExceptionHandler(const nsACString& crashPipe) +{ + return false; +} +#endif // XP_WIN + +bool +TakeMinidumpForChild(uint32_t childPid, nsIFile** dump, uint32_t* aSequence) +{ + return false; +} + +void +RenameAdditionalHangMinidump(nsIFile* minidump, nsIFile* childMinidump, + const nsACString& name) +{ +} + +ThreadId +CurrentThreadId() +{ + return -1; +} + +bool +TakeMinidump(nsIFile** aResult, bool aMoveToPending) +{ + return false; +} + +void +CreateMinidumpsAndPair(ProcessHandle aTargetPid, + ThreadId aTargetBlamedThread, + const nsACString& aIncomingPairName, + nsIFile* aIncomingDumpToPair, + nsIFile** aMainDumpOut, + std::function<void(bool)>&& aCallback, + bool aAsync) +{ +} + +bool +CreateAdditionalChildMinidump(ProcessHandle childPid, + ThreadId childBlamedThread, + nsIFile* parentMinidump, + const nsACString& name) +{ + return false; +} + +bool +UnsetRemoteExceptionHandler() +{ + return false; +} + +#if defined(MOZ_WIDGET_ANDROID) +void +SetNotificationPipeForChild(int childCrashFd) +{ +} + +void +AddLibraryMapping(const char* library_name, + uintptr_t start_address, + size_t mapping_length, + size_t file_offset) +{ +} +#endif + +// From ThreadAnnotation.cpp + +void +InitThreadAnnotation() +{ +} + +void +SetCurrentThreadName(const char* aName) +{ +} + +void +GetFlatThreadAnnotation(const std::function<void(const char*)>& aCallback) +{ +} + +void +ShutdownThreadAnnotation() +{ +} + +} // namespace CrashReporter
--- a/toolkit/crashreporter/nsExceptionHandler.cpp +++ b/toolkit/crashreporter/nsExceptionHandler.cpp @@ -1,15 +1,16 @@ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 "nsExceptionHandler.h" +#include "nsExceptionHandlerUtils.h" #include "nsAppDirectoryServiceDefs.h" #include "nsDirectoryServiceDefs.h" #include "nsDirectoryService.h" #include "nsDataHashtable.h" #include "mozilla/ArrayUtils.h" #include "mozilla/Services.h" #include "nsIObserverService.h" @@ -82,17 +83,16 @@ using mozilla::InjectCrashRunnable; #include <prio.h> #include "mozilla/Mutex.h" #include "nsDebug.h" #include "nsCRT.h" #include "nsIFile.h" #include <map> #include <vector> -#include "mozilla/double-conversion.h" #include "mozilla/IOInterposer.h" #include "mozilla/mozalloc_oom.h" #include "mozilla/WindowsDllBlocklist.h" #if defined(XP_MACOSX) CFStringRef reporterClientAppID = CFSTR("org.mozilla.crashreporter"); #endif #if defined(MOZ_WIDGET_ANDROID) @@ -408,64 +408,16 @@ typedef struct { size_t length; size_t file_offset; } mapping_info; static std::vector<mapping_info> library_mappings; typedef std::map<uint32_t,google_breakpad::MappingList> MappingMap; #endif } -// Format a non-negative double to a string, without using C-library functions, -// which need to be avoided (.e.g. bug 1240160, comment 10). Leave the utility -// non-file static so that we can gtest it. Return false if we failed to -// get the formatting done correctly. -bool SimpleNoCLibDtoA(double aValue, char* aBuffer, int aBufferLength) -{ - // aBufferLength is the size of the buffer. Be paranoid. - aBuffer[aBufferLength-1] = '\0'; - - if (aValue < 0) { - return false; - } - - int length, point, i; - bool sign; - bool ok = true; - double_conversion::DoubleToStringConverter::DoubleToAscii( - aValue, - double_conversion::DoubleToStringConverter::SHORTEST, - 8, - aBuffer, - aBufferLength, - &sign, - &length, - &point); - - // length does not account for the 0 terminator. - if (length > point && (length+1) < (aBufferLength-1)) { - // We have to insert a decimal point. Not worried about adding a leading zero - // in the < 1 (point == 0) case. - aBuffer[length+1] = '\0'; - for (i=length; i>point; i-=1) { - aBuffer[i] = aBuffer[i-1]; - } - aBuffer[i] = '.'; // Not worried about locales - } else if (length < point) { - // Trailing zeros scenario - for (i=length; i<point; i+=1) { - if (i >= aBufferLength-2) { - ok = false; - } - aBuffer[i] = '0'; - } - aBuffer[i] = '\0'; - } - return ok; -} - namespace CrashReporter { #ifdef XP_LINUX static inline void my_inttostring(intmax_t t, char* buffer, size_t buffer_length) { my_memset(buffer, 0, buffer_length); my_uitos(buffer, t, my_uint_len(t));
--- a/toolkit/crashreporter/nsExceptionHandler.h +++ b/toolkit/crashreporter/nsExceptionHandler.h @@ -1,13 +1,19 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* 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/. */ +// This header has two implementations, the real one in nsExceptionHandler.cpp +// and a dummy in nsDummyExceptionHandler.cpp. The latter is used in builds +// configured with --disable-crashreporter. If you add or remove a function +// from this header you must update both implementations otherwise you'll break +// builds that disable the crash reporter. + #ifndef nsExceptionHandler_h__ #define nsExceptionHandler_h__ #include "mozilla/Assertions.h" #include <functional> #include <stddef.h> #include <stdint.h> @@ -29,16 +35,29 @@ #include <signal.h> #endif class nsIFile; template<class KeyClass, class DataType> class nsDataHashtable; class nsCStringHashKey; namespace CrashReporter { + +/** + * Returns true if the crash reporter is using the dummy implementation. + */ +static inline bool +IsDummy() { +#ifdef MOZ_CRASHREPORTER + return false; +#else + return true; +#endif +} + nsresult SetExceptionHandler(nsIFile* aXREDirectory, bool force=false); nsresult UnsetExceptionHandler(); /** * Tell the crash reporter to recalculate where crash events files should go. * SetCrashEventsDir is used before XPCOM is initialized from the startup * code. * @@ -243,17 +262,17 @@ public: void InjectCrashReporterIntoProcess(DWORD processID, InjectorCrashCallback* cb); void UnregisterInjectorCallback(DWORD processID); #endif // Child-side API bool SetRemoteExceptionHandler(const nsACString& crashPipe); void InitChildProcessTmpDir(nsIFile* aDirOverride = nullptr); -# elif defined(XP_LINUX) +# elif defined(XP_LINUX) || defined(OS_BSD) || defined(OS_SOLARIS) // Parent-side API for children // Set the outparams for crash reporter server's fd (|childCrashFd|) // and the magic fd number it should be remapped to // (|childCrashRemapFd|) before exec() in the child process. // |SetRemoteExceptionHandler()| in the child process expects to find // the server at |childCrashRemapFd|. Return true iff successful. //
new file mode 100644 --- /dev/null +++ b/toolkit/crashreporter/nsExceptionHandlerUtils.cpp @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* 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 "nsExceptionHandlerUtils.h" + +#include "mozilla/double-conversion.h" + +// Format a non-negative double to a string, without using C-library functions, +// which need to be avoided (.e.g. bug 1240160, comment 10). Return false if +// we failed to get the formatting done correctly. +bool SimpleNoCLibDtoA(double aValue, char* aBuffer, int aBufferLength) +{ + // aBufferLength is the size of the buffer. Be paranoid. + aBuffer[aBufferLength-1] = '\0'; + + if (aValue < 0) { + return false; + } + + int length, point, i; + bool sign; + bool ok = true; + double_conversion::DoubleToStringConverter::DoubleToAscii( + aValue, + double_conversion::DoubleToStringConverter::SHORTEST, + 8, + aBuffer, + aBufferLength, + &sign, + &length, + &point); + + // length does not account for the 0 terminator. + if (length > point && (length+1) < (aBufferLength-1)) { + // We have to insert a decimal point. Not worried about adding a leading zero + // in the < 1 (point == 0) case. + aBuffer[length+1] = '\0'; + for (i=length; i>point; i-=1) { + aBuffer[i] = aBuffer[i-1]; + } + aBuffer[i] = '.'; // Not worried about locales + } else if (length < point) { + // Trailing zeros scenario + for (i=length; i<point; i+=1) { + if (i >= aBufferLength-2) { + ok = false; + } + aBuffer[i] = '0'; + } + aBuffer[i] = '\0'; + } + return ok; +}
new file mode 100644 --- /dev/null +++ b/toolkit/crashreporter/nsExceptionHandlerUtils.h @@ -0,0 +1,12 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* 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/. */ + +#ifndef nsExceptionHandlerUtils_h__ +#define nsExceptionHandlerUtils_h__ + +bool SimpleNoCLibDtoA(double aValue, char* aBuffer, int aBufferLength); + +#endif // nsExceptionHandlerUtils_h__
--- a/toolkit/moz.build +++ b/toolkit/moz.build @@ -2,16 +2,17 @@ # vim: set filetype=python: # 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/. DIRS += [ 'components', 'content', + 'crashreporter', 'forgetaboutsite', 'locales', 'modules', 'mozapps/downloads', 'mozapps/extensions', 'mozapps/handling', 'mozapps/preferences', 'pluginproblem', @@ -41,19 +42,16 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk DIRS += ['system/unixproxy'] elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': DIRS += ['system/osxproxy'] elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': DIRS += ['system/windowsproxy'] elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': DIRS += ['system/androidproxy'] -if CONFIG['MOZ_CRASHREPORTER']: - DIRS += ['crashreporter'] - TEST_HARNESS_FILES.testing.mochitest.browser.toolkit.crashreporter.test.browser += [ 'crashreporter/test/browser/crashreport.sjs', ] with Files('moz.*'): BUG_COMPONENT = ('Core', 'Build Config') with Files('toolkit.mozbuild'):
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm @@ -2196,18 +2196,17 @@ this.XPIProvider = { // UI displayed early in startup (like the compatibility UI) may have // caused us to cache parts of the skin or locale in memory. These must // be flushed to allow extension provided skins and locales to take full // effect Services.obs.notifyObservers(null, "chrome-flush-skin-caches"); Services.obs.notifyObservers(null, "chrome-flush-caches"); } - if ("nsICrashReporter" in Ci && - Services.appinfo instanceof Ci.nsICrashReporter) { + if (AppConstants.MOZ_CRASHREPORTER) { // Annotate the crash report with relevant add-on information. try { Services.appinfo.annotateCrashReport("Theme", this.currentSkin); } catch (e) { } try { Services.appinfo.annotateCrashReport("EMCheckCompatibility", AddonManager.checkCompatibility); } catch (e) { } @@ -2758,24 +2757,26 @@ this.XPIProvider = { logger.error("XPI_verifySignature: " + err); } }, /** * Adds a list of currently active add-ons to the next crash report. */ addAddonsToCrashReporter() { - if (!("nsICrashReporter" in Ci) || - !(Services.appinfo instanceof Ci.nsICrashReporter)) + if (!(Services.appinfo instanceof Ci.nsICrashReporter) || + !AppConstants.MOZ_CRASHREPORTER) { return; + } // In safe mode no add-ons are loaded so we should not include them in the // crash report - if (Services.appinfo.inSafeMode) + if (Services.appinfo.inSafeMode) { return; + } let data = Array.from(XPIStates.enabledAddons(), a => encoded`${a.id}:${a.version}`).join(","); try { Services.appinfo.annotateCrashReport("Add-ons", data); } catch (e) { }
--- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js +++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js @@ -35,16 +35,17 @@ const TIMEOUT_MS = 900000; // still passes. const MAX_TIME_DIFFERENCE = 3000; // Time to reset file modified time relative to Date.now() so we can test that // times are modified (10 hours old). const MAKE_FILE_OLD_DIFFERENCE = 10 * 3600 * 1000; Components.utils.import("resource://gre/modules/addons/AddonRepository.jsm"); +Components.utils.import("resource://gre/modules/AppConstants.jsm"); Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); Components.utils.import("resource://gre/modules/FileUtils.jsm"); Components.utils.import("resource://gre/modules/Services.jsm"); Components.utils.import("resource://gre/modules/NetUtil.jsm"); const { OS } = Components.utils.import("resource://gre/modules/osfile.jsm", {}); Components.utils.import("resource://gre/modules/AsyncShutdown.jsm"); Components.utils.import("resource://testing-common/AddonTestUtils.jsm"); @@ -365,18 +366,19 @@ function isNightlyChannel() { * crash reporting is enabled. The test will fail if the add-on is not in the * annotation. * @param aId * The ID of the add-on * @param aVersion * The version of the add-on */ function do_check_in_crash_annotation(aId, aVersion) { - if (!("nsICrashReporter" in AM_Ci)) + if (!AppConstants.MOZ_CRASHREPORTER) { return; + } if (!("Add-ons" in gAppInfo.annotations)) { do_check_false(true); return; } let addons = gAppInfo.annotations["Add-ons"].split(","); do_check_true(addons.includes(`${encodeURIComponent(aId)}:${encodeURIComponent(aVersion)}`)); @@ -387,18 +389,19 @@ function do_check_in_crash_annotation(aI * crash reporting is enabled. The test will fail if the add-on is in the * annotation. * @param aId * The ID of the add-on * @param aVersion * The version of the add-on */ function do_check_not_in_crash_annotation(aId, aVersion) { - if (!("nsICrashReporter" in AM_Ci)) + if (!AppConstants.MOZ_CRASHREPORTER) { return; + } if (!("Add-ons" in gAppInfo.annotations)) { do_check_true(true); return; } let addons = gAppInfo.annotations["Add-ons"].split(","); do_check_false(addons.includes(`${encodeURIComponent(aId)}:${encodeURIComponent(aVersion)}`));
--- a/toolkit/xre/nsAndroidStartup.cpp +++ b/toolkit/xre/nsAndroidStartup.cpp @@ -24,24 +24,22 @@ using namespace mozilla; extern "C" NS_EXPORT void GeckoStart(JNIEnv* env, char** argv, int argc, const StaticXREAppData& aAppData) { mozilla::jni::SetGeckoThreadEnv(env); -#ifdef MOZ_CRASHREPORTER const struct mapping_info *info = getLibraryMapping(); while (info->name) { CrashReporter::AddLibraryMapping(info->name, info->base, info->len, info->offset); info++; } -#endif if (!argv) { LOG("Failed to get arguments for GeckoStart\n"); return; } BootstrapConfig config; config.appData = &aAppData;
--- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -195,26 +195,24 @@ #ifdef DEBUG #include "mozilla/Logging.h" #endif #ifdef MOZ_JPROF #include "jprof.h" #endif -#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" #include "nsICrashReporter.h" #define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1" #include "nsIPrefService.h" #include "nsIMemoryInfoDumper.h" #if defined(XP_LINUX) && !defined(ANDROID) #include "mozilla/widget/LSBUtils.h" #endif -#endif #include "base/command_line.h" #include "GTestRunner.h" #ifdef MOZ_WIDGET_ANDROID #include "GeneratedJNIWrappers.h" #endif @@ -699,50 +697,44 @@ bool gSafeMode = false; * The nsXULAppInfo object implements nsIFactory so that it can be its own * singleton. */ class nsXULAppInfo : public nsIXULAppInfo, public nsIObserver, #ifdef XP_WIN public nsIWinAppHelper, #endif -#ifdef MOZ_CRASHREPORTER public nsICrashReporter, public nsIFinishDumpingCallback, -#endif public nsIXULRuntime { public: constexpr nsXULAppInfo() {} NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSIPLATFORMINFO NS_DECL_NSIXULAPPINFO NS_DECL_NSIXULRUNTIME NS_DECL_NSIOBSERVER -#ifdef MOZ_CRASHREPORTER NS_DECL_NSICRASHREPORTER NS_DECL_NSIFINISHDUMPINGCALLBACK -#endif #ifdef XP_WIN NS_DECL_NSIWINAPPHELPER #endif }; NS_INTERFACE_MAP_BEGIN(nsXULAppInfo) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXULRuntime) NS_INTERFACE_MAP_ENTRY(nsIXULRuntime) NS_INTERFACE_MAP_ENTRY(nsIObserver) #ifdef XP_WIN NS_INTERFACE_MAP_ENTRY(nsIWinAppHelper) #endif -#ifdef MOZ_CRASHREPORTER NS_INTERFACE_MAP_ENTRY(nsICrashReporter) NS_INTERFACE_MAP_ENTRY(nsIFinishDumpingCallback) -#endif NS_INTERFACE_MAP_ENTRY(nsIPlatformInfo) NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIXULAppInfo, gAppData || XRE_IsContentProcess()) NS_INTERFACE_MAP_END NS_IMETHODIMP_(MozExternalRefCountType) nsXULAppInfo::AddRef() { @@ -1201,17 +1193,16 @@ nsXULAppInfo::GetUserCanElevate(bool *aU if (hToken) CloseHandle(hToken); return NS_OK; } #endif -#ifdef MOZ_CRASHREPORTER NS_IMETHODIMP nsXULAppInfo::GetEnabled(bool *aEnabled) { *aEnabled = CrashReporter::GetEnabled(); return NS_OK; } NS_IMETHODIMP @@ -1431,17 +1422,16 @@ NS_IMETHODIMP nsXULAppInfo::Callback(nsISupports* aData) { nsCOMPtr<nsIFile> file = do_QueryInterface(aData); MOZ_ASSERT(file); CrashReporter::SetMemoryReportFile(file); return NS_OK; } -#endif static const nsXULAppInfo kAppInfo; static nsresult AppInfoConstructor(nsISupports* aOuter, REFNSIID aIID, void **aResult) { NS_ENSURE_NO_AGGREGATION(aOuter); return const_cast<nsXULAppInfo*>(&kAppInfo)-> @@ -1539,17 +1529,17 @@ static const mozilla::Module::CIDEntry k { nullptr } }; static const mozilla::Module::ContractIDEntry kXREContracts[] = { { XULAPPINFO_SERVICE_CONTRACTID, &kAPPINFO_CID }, { XULRUNTIME_SERVICE_CONTRACTID, &kAPPINFO_CID }, #ifdef MOZ_CRASHREPORTER { NS_CRASHREPORTER_CONTRACTID, &kAPPINFO_CID }, -#endif +#endif // MOZ_CRASHREPORTER { NS_PROFILESERVICE_CONTRACTID, &kProfileServiceCID }, { NS_NATIVEAPPSUPPORT_CONTRACTID, &kNativeAppSupportCID }, { nullptr } }; static const mozilla::Module kXREModule = { mozilla::Module::kVersion, kXRECIDs, @@ -2899,17 +2889,16 @@ static void SaveStateForAppInitiatedRest static void RestoreStateForAppInitiatedRestart() { for (auto & savedVar : gSavedVars) { if (savedVar.value) PR_SetEnv(savedVar.value); } } -#ifdef MOZ_CRASHREPORTER // When we first initialize the crash reporter we don't have a profile, // so we set the minidump path to $TEMP. Once we have a profile, // we set it to $PROFILE/minidumps, creating the directory // if needed. static void MakeOrSetMinidumpPath(nsIFile* profD) { nsCOMPtr<nsIFile> dumpD; profD->Clone(getter_AddRefs(dumpD)); @@ -2924,17 +2913,16 @@ static void MakeOrSetMinidumpPath(nsIFil NS_ENSURE_SUCCESS_VOID(rv); } nsAutoString pathStr; if (NS_SUCCEEDED(dumpD->GetPath(pathStr))) CrashReporter::SetMinidumpPath(pathStr); } } -#endif const XREAppData* gAppData = nullptr; #ifdef MOZ_WIDGET_GTK static void MOZ_gdk_display_close(GdkDisplay *display) { #if CLEANUP_MEMORY // XXX wallpaper for bug 417163: don't close the Display if we're using the @@ -3315,17 +3303,16 @@ XREMain::XRE_mainInit(bool* aExitFlag) (const char*) mAppData->maxVersion); return 1; } rv = mDirProvider.Initialize(mAppData->directory, mAppData->xreDirectory); if (NS_FAILED(rv)) return 1; -#ifdef MOZ_CRASHREPORTER if (EnvHasValue("MOZ_CRASHREPORTER")) { mAppData->flags |= NS_XRE_ENABLE_CRASH_REPORTER; } nsCOMPtr<nsIFile> xreBinDirectory; xreBinDirectory = mDirProvider.GetGREBinDir(); if ((mAppData->flags & NS_XRE_ENABLE_CRASH_REPORTER) && @@ -3401,17 +3388,16 @@ XREMain::XRE_mainInit(bool* aExitFlag) nsAutoCString overridePath; overrideini->GetNativePath(overridePath); #endif SaveWordToEnv("MOZ_CRASHREPORTER_STRINGS_OVERRIDE", overridePath); } } } -#endif #if defined(MOZ_SANDBOX) && defined(XP_WIN) if (mAppData->sandboxBrokerServices) { SandboxBroker::Initialize(mAppData->sandboxBrokerServices); } else { #if defined(MOZ_CONTENT_SANDBOX) // If we're sandboxing content and we fail to initialize, then crashing here // seems like the sensible option. @@ -3551,31 +3537,27 @@ XREMain::XRE_mainInit(bool* aExitFlag) } else if (vtype == REG_DWORD && len == sizeof(updateRevision[0])) { cpuUpdateRevision = static_cast<int>(updateRevision[0]); break; } } } } -#ifdef MOZ_CRASHREPORTER if (cpuUpdateRevision > 0) { CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("CPUMicrocodeVersion"), nsPrintfCString("0x%x", cpuUpdateRevision)); } -#endif } #endif -#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("SafeMode"), gSafeMode ? NS_LITERAL_CSTRING("1") : NS_LITERAL_CSTRING("0")); -#endif // Handle --no-remote and --new-instance command line arguments. Setup // the environment to better accommodate other components and various // restart scenarios. ar = CheckArg("no-remote", true); if (ar == ARG_BAD) { PR_fprintf(PR_STDERR, "Error: argument --no-remote is invalid when argument --osint is specified\n"); return 1; @@ -3629,17 +3611,16 @@ XREMain::XRE_mainInit(bool* aExitFlag) } *aExitFlag = true; return 0; } return 0; } -#ifdef MOZ_CRASHREPORTER #ifdef XP_WIN /** * Uses WMI to read some manufacturer information that may be useful for * diagnosing hardware-specific crashes. This function is best-effort; failures * shouldn't burden the caller. COM must be initialized before calling. */ static void AnnotateSystemManufacturer() { @@ -3723,18 +3704,16 @@ AnnotateLSBRelease(void*) nsCString dist, desc, release, codename; if (widget::lsb::GetLSBRelease(dist, desc, release, codename)) { CrashReporter::AppendAppNotesToCrashReport(desc); } } #endif // defined(XP_LINUX) && !defined(ANDROID) -#endif - #ifdef XP_WIN static void ReadAheadDll(const wchar_t* dllName) { wchar_t dllPath[MAX_PATH]; if (ConstructSystem32Path(dllName, dllPath, MAX_PATH)) { ReadAheadLib(dllPath); } } @@ -4183,22 +4162,20 @@ XREMain::XRE_mainStartup(bool* aExitFlag rv = mDirProvider.SetProfile(mProfD, mProfLD); NS_ENSURE_SUCCESS(rv, 1); //////////////////////// NOW WE HAVE A PROFILE //////////////////////// mozilla::Telemetry::SetProfileDir(mProfD); -#ifdef MOZ_CRASHREPORTER if (mAppData->flags & NS_XRE_ENABLE_CRASH_REPORTER) MakeOrSetMinidumpPath(mProfD); CrashReporter::SetProfileDirectory(mProfD); -#endif nsAutoCString version; BuildVersion(version); #ifdef TARGET_OS_ABI NS_NAMED_LITERAL_CSTRING(osABI, TARGET_OS_ABI); #else // No TARGET_XPCOM_ABI, but at least the OS is known @@ -4279,17 +4256,16 @@ XREMain::XRE_mainStartup(bool* aExitFlag if (flagFile) { flagFile->Remove(true); } return 0; } -#if defined(MOZ_CRASHREPORTER) #if defined(MOZ_CONTENT_SANDBOX) void AddSandboxAnnotations() { // Include the sandbox content level, regardless of platform int level = GetEffectiveContentSandboxLevel(); nsAutoCString levelString; levelString.AppendInt(level); @@ -4310,17 +4286,16 @@ void AddSandboxAnnotations() sandboxCapable = SandboxInfo::Get().CanSandboxContent(); #endif CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("ContentSandboxCapable"), sandboxCapable ? NS_LITERAL_CSTRING("1") : NS_LITERAL_CSTRING("0")); } #endif /* MOZ_CONTENT_SANDBOX */ -#endif /* MOZ_CRASHREPORTER */ /* * XRE_mainRun - Command line startup, profile migration, and * the calling of appStartup->Run(). */ nsresult XREMain::XRE_mainRun() { @@ -4345,17 +4320,16 @@ XREMain::XRE_mainRun() comp = do_GetService("@mozilla.org/focus-event-suppressor-service;1"); } #endif rv = mScopedXPCOM->SetWindowCreator(mNativeApp); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); -#ifdef MOZ_CRASHREPORTER // tell the crash reporter to also send the release channel nsCOMPtr<nsIPrefService> prefs = do_GetService("@mozilla.org/preferences-service;1", &rv); if (NS_SUCCEEDED(rv)) { nsCOMPtr<nsIPrefBranch> defaultPrefBranch; rv = prefs->GetDefaultBranch(nullptr, getter_AddRefs(defaultPrefBranch)); if (NS_SUCCEEDED(rv)) { nsAutoCString sval; @@ -4381,18 +4355,16 @@ XREMain::XRE_mainRun() PR_PRIORITY_LOW, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0); #endif #if defined(XP_LINUX) && !defined(ANDROID) PR_CreateThread(PR_USER_THREAD, AnnotateLSBRelease, 0, PR_PRIORITY_LOW, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0); #endif -#endif - if (mStartOffline) { nsCOMPtr<nsIIOService> io(do_GetService("@mozilla.org/network/io-service;1")); NS_ENSURE_TRUE(io, NS_ERROR_FAILURE); io->SetManageOfflineStatus(false); io->SetOffline(true); } @@ -4510,21 +4482,19 @@ XREMain::XRE_mainRun() nsCOMPtr<nsIAppStartup> appStartup (do_GetService(NS_APPSTARTUP_CONTRACTID)); NS_ENSURE_TRUE(appStartup, NS_ERROR_FAILURE); mDirProvider.DoStartup(); OverrideDefaultLocaleIfNeeded(); -#ifdef MOZ_CRASHREPORTER nsCString userAgentLocale; LocaleService::GetInstance()->GetAppLocaleAsLangTag(userAgentLocale); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("useragent_locale"), userAgentLocale); -#endif appStartup->GetShuttingDown(&mShuttingDown); nsCOMPtr<nsICommandLineRunner> cmdLine; nsCOMPtr<nsIFile> workingDir; rv = NS_GetSpecialDirectory(NS_OS_CURRENT_WORKING_DIR, getter_AddRefs(workingDir)); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); @@ -4605,20 +4575,18 @@ XREMain::XRE_mainRun() nsCOMPtr<nsIObserverService> obsService = mozilla::services::GetObserverService(); if (obsService) obsService->NotifyObservers(nullptr, "final-ui-startup", nullptr); (void)appStartup->DoneStartingUp(); -#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("StartupCrash"), NS_LITERAL_CSTRING("0")); -#endif appStartup->GetShuttingDown(&mShuttingDown); } if (!mShuttingDown) { rv = cmdLine->Run(); NS_ENSURE_SUCCESS_LOG(rv, NS_ERROR_FAILURE); @@ -4661,30 +4629,26 @@ XREMain::XRE_mainRun() Telemetry::Accumulate(Telemetry::SANDBOX_HAS_USER_NAMESPACES_PRIVILEGED, sandboxInfo.Test(SandboxInfo::kHasPrivilegedUserNamespaces)); Telemetry::Accumulate(Telemetry::SANDBOX_HAS_USER_NAMESPACES, sandboxInfo.Test(SandboxInfo::kHasUserNamespaces)); Telemetry::Accumulate(Telemetry::SANDBOX_CONTENT_ENABLED, sandboxInfo.Test(SandboxInfo::kEnabledForContent)); Telemetry::Accumulate(Telemetry::SANDBOX_MEDIA_ENABLED, sandboxInfo.Test(SandboxInfo::kEnabledForMedia)); -#if defined(MOZ_CRASHREPORTER) nsAutoCString flagsString; flagsString.AppendInt(sandboxInfo.AsInteger()); CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("ContentSandboxCapabilities"), flagsString); -#endif /* MOZ_CRASHREPORTER */ #endif /* MOZ_SANDBOX && XP_LINUX */ -#if defined(MOZ_CRASHREPORTER) #if defined(MOZ_CONTENT_SANDBOX) AddSandboxAnnotations(); #endif /* MOZ_CONTENT_SANDBOX */ -#endif /* MOZ_CRASHREPORTER */ { rv = appStartup->Run(); if (NS_FAILED(rv)) { NS_ERROR("failed to run appstartup"); gLogConsoleErrors = true; } } @@ -4899,35 +4863,32 @@ XREMain::XRE_main(int argc, char* argv[] MOZ_gdk_display_close(mGdkDisplay); } #endif { rv = LaunchChild(mNativeApp, true); } -#ifdef MOZ_CRASHREPORTER if (mAppData->flags & NS_XRE_ENABLE_CRASH_REPORTER) CrashReporter::UnsetExceptionHandler(); -#endif + return rv == NS_ERROR_LAUNCHED_CHILD_PROCESS ? 0 : 1; } #ifdef MOZ_WIDGET_GTK // gdk_display_close also calls gdk_display_manager_set_default_display // appropriately when necessary. if (!gfxPlatform::IsHeadless()) { MOZ_gdk_display_close(mGdkDisplay); } #endif -#ifdef MOZ_CRASHREPORTER if (mAppData->flags & NS_XRE_ENABLE_CRASH_REPORTER) CrashReporter::UnsetExceptionHandler(); -#endif XRE_DeinitCommandLine(); return NS_FAILED(rv) ? 1 : 0; } void XRE_StopLateWriteChecks(void) {
--- a/toolkit/xre/nsEmbedFunctions.cpp +++ b/toolkit/xre/nsEmbedFunctions.cpp @@ -238,19 +238,17 @@ GeckoProcessType sChildProcessType = Gec } // namespace startup } // namespace mozilla #if defined(MOZ_WIDGET_ANDROID) void XRE_SetAndroidChildFds (JNIEnv* env, int crashFd, int ipcFd) { mozilla::jni::SetGeckoThreadEnv(env); -#if defined(MOZ_CRASHREPORTER) CrashReporter::SetNotificationPipeForChild(crashFd); -#endif // defined(MOZ_CRASHREPORTER) IPC::Channel::SetClientChannelFd(ipcFd); } #endif // defined(MOZ_WIDGET_ANDROID) void XRE_SetProcessType(const char* aProcessTypeString) { static bool called = false; @@ -265,17 +263,16 @@ XRE_SetProcessType(const char* aProcessT ++i) { if (!strcmp(kGeckoProcessTypeString[i], aProcessTypeString)) { sChildProcessType = static_cast<GeckoProcessType>(i); return; } } } -#if defined(MOZ_CRASHREPORTER) // FIXME/bug 539522: this out-of-place function is stuck here because // IPDL wants access to this crashreporter interface, and // crashreporter is built in such a way to make that awkward bool XRE_TakeMinidumpForChild(uint32_t aChildPid, nsIFile** aDump, uint32_t* aSequence) { return CrashReporter::TakeMinidumpForChild(aChildPid, aDump, aSequence); @@ -287,43 +284,40 @@ XRE_SetRemoteExceptionHandler(const char #if defined(XP_WIN) || defined(XP_MACOSX) return CrashReporter::SetRemoteExceptionHandler(nsDependentCString(aPipe)); #elif defined(OS_LINUX) return CrashReporter::SetRemoteExceptionHandler(); #else # error "OOP crash reporter unsupported on this platform" #endif } -#endif // if defined(MOZ_CRASHREPORTER) #if defined(XP_WIN) void SetTaskbarGroupId(const nsString& aId) { if (FAILED(SetCurrentProcessExplicitAppUserModelID(aId.get()))) { NS_WARNING("SetCurrentProcessExplicitAppUserModelID failed for child process."); } } #endif -#if defined(MOZ_CRASHREPORTER) #if defined(MOZ_CONTENT_SANDBOX) void AddContentSandboxLevelAnnotation() { if (XRE_GetProcessType() == GeckoProcessType_Content) { int level = GetEffectiveContentSandboxLevel(); nsAutoCString levelString; levelString.AppendInt(level); CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("ContentSandboxLevel"), levelString); } } #endif /* MOZ_CONTENT_SANDBOX */ -#endif /* MOZ_CRASHREPORTER */ namespace { int GetDebugChildPauseTime() { auto pauseStr = PR_GetEnv("MOZ_DEBUG_CHILD_PAUSE"); if (pauseStr && *pauseStr) { int pause = atoi(pauseStr); if (pause != 1) { // must be !=1 since =1 enables the default pause time @@ -478,45 +472,47 @@ XRE_InitChildProcess(int aArgc, NS_WARNING("child task_set_bootstrap_port() failed"); return NS_ERROR_FAILURE; } #endif SetupErrorHandling(aArgv[0]); -#if defined(MOZ_CRASHREPORTER) - if (aArgc < 1) - return NS_ERROR_FAILURE; - const char* const crashReporterArg = aArgv[--aArgc]; + if (!CrashReporter::IsDummy()) { + if (aArgc < 1) { + return NS_ERROR_FAILURE; + } + + const char* const crashReporterArg = aArgv[--aArgc]; -# if defined(XP_WIN) || defined(XP_MACOSX) - // on windows and mac, |crashReporterArg| is the named pipe on which the - // server is listening for requests, or "-" if crash reporting is - // disabled. - if (0 != strcmp("-", crashReporterArg) && - !XRE_SetRemoteExceptionHandler(crashReporterArg)) { - // Bug 684322 will add better visibility into this condition - NS_WARNING("Could not setup crash reporting\n"); +#if defined(XP_WIN) || defined(XP_MACOSX) + // on windows and mac, |crashReporterArg| is the named pipe on which the + // server is listening for requests, or "-" if crash reporting is + // disabled. + if (0 != strcmp("-", crashReporterArg) && + !XRE_SetRemoteExceptionHandler(crashReporterArg)) { + // Bug 684322 will add better visibility into this condition + NS_WARNING("Could not setup crash reporting\n"); + } +#elif defined(OS_LINUX) + // on POSIX, |crashReporterArg| is "true" if crash reporting is + // enabled, false otherwise + if (0 != strcmp("false", crashReporterArg) && + !XRE_SetRemoteExceptionHandler(nullptr)) { + // Bug 684322 will add better visibility into this condition + NS_WARNING("Could not setup crash reporting\n"); + } +#else +# error "OOP crash reporting unsupported on this platform" +#endif } -# elif defined(OS_LINUX) - // on POSIX, |crashReporterArg| is "true" if crash reporting is - // enabled, false otherwise - if (0 != strcmp("false", crashReporterArg) && - !XRE_SetRemoteExceptionHandler(nullptr)) { - // Bug 684322 will add better visibility into this condition - NS_WARNING("Could not setup crash reporting\n"); - } -# else -# error "OOP crash reporting unsupported on this platform" -# endif // For Init/Shutdown thread name annotations in the crash reporter. CrashReporter::InitThreadAnnotationRAII annotation; -#endif // if defined(MOZ_CRASHREPORTER) gArgv = aArgv; gArgc = aArgc; #ifdef MOZ_X11 XInitThreads(); #endif #if MOZ_WIDGET_GTK == 2 @@ -667,42 +663,38 @@ XRE_InitChildProcess(int aArgc, default: MOZ_CRASH("Unknown main thread class"); } if (!process->Init(aArgc, aArgv)) { return NS_ERROR_FAILURE; } -#ifdef MOZ_CRASHREPORTER #if defined(XP_WIN) || defined(XP_MACOSX) CrashReporter::InitChildProcessTmpDir(crashReportTmpDir); #endif -#endif #if defined(XP_WIN) // Set child processes up such that they will get killed after the // chrome process is killed in cases where the user shuts the system // down or logs off. ::SetProcessShutdownParameters(0x280 - 1, SHUTDOWN_NORETRY); #endif #if defined(MOZ_SANDBOX) && defined(XP_WIN) // We need to do this after the process has been initialised, as // InitLoggingIfRequired may need access to prefs. mozilla::sandboxing::InitLoggingIfRequired(aChildData->ProvideLogFunction); #endif OverrideDefaultLocaleIfNeeded(); -#if defined(MOZ_CRASHREPORTER) #if defined(MOZ_CONTENT_SANDBOX) AddContentSandboxLevelAnnotation(); #endif -#endif // Run the UI event loop on the main thread. uiMessageLoop.MessageLoop::Run(); // Allow ProcessChild to clean up after itself before going out of // scope and being deleted process->CleanUp(); mozilla::Omnijar::CleanUp();
--- a/toolkit/xre/nsX11ErrorHandler.cpp +++ b/toolkit/xre/nsX11ErrorHandler.cpp @@ -112,27 +112,25 @@ X11Error(Display *display, XErrorEvent * notes.AppendLiteral("; sync"); } else { notes.AppendLiteral("; "); notes.AppendInt(uint32_t(age)); notes.AppendLiteral(" requests ago"); } } -#ifdef MOZ_CRASHREPORTER switch (XRE_GetProcessType()) { case GeckoProcessType_Default: case GeckoProcessType_Plugin: case GeckoProcessType_Content: CrashReporter::AppendAppNotesToCrashReport(notes); break; default: ; // crash report notes not supported. } -#endif #ifdef DEBUG // The resource id is unlikely to be useful in a crash report without // context of other ids, but add it to the debug console output. notes.AppendLiteral("; id=0x"); notes.AppendInt(uint32_t(event->resourceid), 16); #ifdef MOZ_X11 // Actually, for requests where Xlib gets the reply synchronously,
--- a/widget/ContentCache.cpp +++ b/widget/ContentCache.cpp @@ -10,19 +10,17 @@ #include "mozilla/IMEStateManager.h" #include "mozilla/IntegerPrintfMacros.h" #include "mozilla/Logging.h" #include "mozilla/Move.h" #include "mozilla/RefPtr.h" #include "mozilla/TextComposition.h" #include "mozilla/TextEvents.h" #include "mozilla/dom/TabParent.h" -#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" -#endif // #ifdef MOZ_CRASHREPORTER #include "nsIWidget.h" namespace mozilla { using namespace dom; using namespace widget; static const char* @@ -1108,17 +1106,17 @@ ContentCacheInParent::OnCompositionEvent "mPendingEventsNeedingAck=%u, mWidgetHasComposition=%s, " "mPendingCompositionCount=%u, mCommitStringByRequest=0x%p", this, ToChar(aEvent.mMessage), GetEscapedUTF8String(aEvent.mData).get(), aEvent.mData.Length(), aEvent.mRanges ? aEvent.mRanges->Length() : 0, mPendingEventsNeedingAck, GetBoolName(mWidgetHasComposition), mPendingCompositionCount, mCommitStringByRequest)); -#if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#if MOZ_DIAGNOSTIC_ASSERT_ENABLED mDispatchedEventMessages.AppendElement(aEvent.mMessage); #endif // #ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED // We must be able to simulate the selection because // we might not receive selection updates in time if (!mWidgetHasComposition) { if (aEvent.mWidget && aEvent.mWidget->PluginHasFocus()) { // If focus is on plugin, we cannot get selection range @@ -1188,56 +1186,56 @@ ContentCacheInParent::OnSelectionEvent( "mPendingCompositionCount=%u", this, ToChar(aSelectionEvent.mMessage), aSelectionEvent.mOffset, aSelectionEvent.mLength, GetBoolName(aSelectionEvent.mReversed), GetBoolName(aSelectionEvent.mExpandToClusterBoundary), GetBoolName(aSelectionEvent.mUseNativeLineBreak), mPendingEventsNeedingAck, GetBoolName(mWidgetHasComposition), mPendingCompositionCount)); -#if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#if MOZ_DIAGNOSTIC_ASSERT_ENABLED mDispatchedEventMessages.AppendElement(aSelectionEvent.mMessage); -#endif // #if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#endif // MOZ_DIAGNOSTIC_ASSERT_ENABLED mPendingEventsNeedingAck++; } void ContentCacheInParent::OnEventNeedingAckHandled(nsIWidget* aWidget, EventMessage aMessage) { // This is called when the child process receives WidgetCompositionEvent or // WidgetSelectionEvent. MOZ_LOG(sContentCacheLog, LogLevel::Info, ("0x%p OnEventNeedingAckHandled(aWidget=0x%p, " "aMessage=%s), mPendingEventsNeedingAck=%u, mPendingCompositionCount=%" PRIu8, this, aWidget, ToChar(aMessage), mPendingEventsNeedingAck, mPendingCompositionCount)); -#if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#if MOZ_DIAGNOSTIC_ASSERT_ENABLED mReceivedEventMessages.AppendElement(aMessage); -#endif // #if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#endif // MOZ_DIAGNOSTIC_ASSERT_ENABLED if (WidgetCompositionEvent::IsFollowedByCompositionEnd(aMessage) || aMessage == eCompositionCommitRequestHandled) { -#if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#if MOZ_DIAGNOSTIC_ASSERT_ENABLED if (mPendingCompositionCount == 1) { RemoveUnnecessaryEventMessageLog(); } -#endif // #if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#endif // #if MOZ_DIAGNOSTIC_ASSERT_ENABLED if (NS_WARN_IF(!mPendingCompositionCount)) { -#if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#if MOZ_DIAGNOSTIC_ASSERT_ENABLED nsPrintfCString info("\nThere is no pending composition but received %s " "message from the remote child\n\n", ToChar(aMessage)); AppendEventMessageLog(info); CrashReporter::AppendAppNotesToCrashReport(info); -#endif // #if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#endif // #if MOZ_DIAGNOSTIC_ASSERT_ENABLED MOZ_DIAGNOSTIC_ASSERT(false, "No pending composition but received unexpected commit event"); mPendingCompositionCount = 1; } mPendingCompositionCount--; // Forget composition string only when the latest composition string is // handled in the remote process because if there is 2 or more pending @@ -1249,23 +1247,23 @@ ContentCacheInParent::OnEventNeedingAckH // Forget pending commit string length if it's handled in the remote // process. Note that this doesn't care too old composition's commit // string because in such case, we cannot return proper information // to IME synchornously. mPendingCommitLength = 0; } if (NS_WARN_IF(!mPendingEventsNeedingAck)) { -#if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#if MOZ_DIAGNOSTIC_ASSERT_ENABLED nsPrintfCString info("\nThere is no pending events but received %s " "message from the remote child\n\n", ToChar(aMessage)); AppendEventMessageLog(info); CrashReporter::AppendAppNotesToCrashReport(info); -#endif // #if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#endif // #if MOZ_DIAGNOSTIC_ASSERT_ENABLED MOZ_DIAGNOSTIC_ASSERT(false, "No pending event message but received unexpected event"); mPendingEventsNeedingAck = 1; } if (--mPendingEventsNeedingAck) { return; } @@ -1289,68 +1287,68 @@ ContentCacheInParent::RequestIMEToCommit MOZ_ASSERT(!mCommitStringByRequest); // If there are 2 or more pending compositions, we already sent // eCompositionCommit(AsIs) to the remote process. So, this request is // too late for IME. The remote process should wait following // composition events for cleaning up TextComposition and handle the // request as it's handled asynchronously. if (mPendingCompositionCount > 1) { -#if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#if MOZ_DIAGNOSTIC_ASSERT_ENABLED mRequestIMEToCommitCompositionResults. AppendElement(RequestIMEToCommitCompositionResult:: eToOldCompositionReceived); -#endif // #if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#endif // #if MOZ_DIAGNOSTIC_ASSERT_ENABLED return false; } // If there is no pending composition, we may have already sent // eCompositionCommit(AsIs) event for the active composition. If so, the // remote process will receive composition events which causes cleaning up // TextComposition. So, this shouldn't do nothing and TextComposition // should handle the request as it's handled asynchronously. if (mIsPendingLastCommitEvent) { -#if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#if MOZ_DIAGNOSTIC_ASSERT_ENABLED mRequestIMEToCommitCompositionResults. AppendElement(RequestIMEToCommitCompositionResult:: eToCommittedCompositionReceived); -#endif // #if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#endif // #if MOZ_DIAGNOSTIC_ASSERT_ENABLED return false; } // If TabParent which has IME focus was already changed to different one, the // request shouldn't be sent to IME because it's too late. if (!IMEStateManager::DoesTabParentHaveIMEFocus(&mTabParent)) { // Use the latest composition string which may not be handled in the // remote process for avoiding data loss. -#if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#if MOZ_DIAGNOSTIC_ASSERT_ENABLED mRequestIMEToCommitCompositionResults. AppendElement(RequestIMEToCommitCompositionResult:: eReceivedAfterTabParentBlur); -#endif // #if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#endif // #if MOZ_DIAGNOSTIC_ASSERT_ENABLED aCommittedString = mCompositionString; // After we return true from here, i.e., without actually requesting IME // to commit composition, we will receive eCompositionCommitRequestHandled // pseudo event message from the remote process. So, we need to increment // mPendingEventsNeedingAck here. mPendingEventsNeedingAck++; return true; } RefPtr<TextComposition> composition = IMEStateManager::GetTextCompositionFor(aWidget); if (NS_WARN_IF(!composition)) { MOZ_LOG(sContentCacheLog, LogLevel::Warning, (" 0x%p RequestToCommitComposition(), " "does nothing due to no composition", this)); -#if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#if MOZ_DIAGNOSTIC_ASSERT_ENABLED mRequestIMEToCommitCompositionResults. AppendElement(RequestIMEToCommitCompositionResult:: eReceivedButNoTextComposition); -#endif // #if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#endif // #if MOZ_DIAGNOSTIC_ASSERT_ENABLED return false; } mCommitStringByRequest = &aCommittedString; // Request commit or cancel composition with TextComposition because we may // have already requested to commit or cancel the composition or we may // have already received eCompositionCommit(AsIs) event. Those status are @@ -1371,36 +1369,36 @@ ContentCacheInParent::RequestIMEToCommit // TextComposition instance will synthesize commit events and wait to // receive delayed composition events. When TextComposition instances both // in this process and the remote process will be destroyed when delayed // composition events received. TextComposition instance in the parent // process will dispatch following composition events and be destroyed // normally. On the other hand, TextComposition instance in the remote // process won't dispatch following composition events and will be // destroyed by IMEStateManager::DispatchCompositionEvent(). -#if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#if MOZ_DIAGNOSTIC_ASSERT_ENABLED mRequestIMEToCommitCompositionResults. AppendElement(RequestIMEToCommitCompositionResult:: eHandledAsynchronously); -#endif // #if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#endif // #if MOZ_DIAGNOSTIC_ASSERT_ENABLED return false; } // When the composition is committed synchronously, the commit string will be // returned to the remote process. Then, PuppetWidget will dispatch // eCompositionCommit event with the returned commit string (i.e., the value // is aCommittedString of this method). Finally, TextComposition instance in // the remote process will be destroyed by // IMEStateManager::DispatchCompositionEvent() at receiving the // eCompositionCommit event (Note that TextComposition instance in this // process was already destroyed). -#if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#if MOZ_DIAGNOSTIC_ASSERT_ENABLED mRequestIMEToCommitCompositionResults. AppendElement(RequestIMEToCommitCompositionResult::eHandledSynchronously); -#endif // #if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#endif // #if MOZ_DIAGNOSTIC_ASSERT_ENABLED return true; } void ContentCacheInParent::MaybeNotifyIME(nsIWidget* aWidget, const IMENotification& aNotification) { if (!mPendingEventsNeedingAck) { @@ -1487,17 +1485,17 @@ ContentCacheInParent::FlushPendingNotifi (mPendingTextChange.HasNotification() || mPendingSelectionChange.HasNotification() || mPendingLayoutChange.HasNotification() || mPendingCompositionUpdate.HasNotification())) { FlushPendingNotifications(widget); } } -#if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#if MOZ_DIAGNOSTIC_ASSERT_ENABLED void ContentCacheInParent::RemoveUnnecessaryEventMessageLog() { bool foundLastCompositionStart = false; for (size_t i = mDispatchedEventMessages.Length(); i > 1; i--) { if (mDispatchedEventMessages[i - 1] != eCompositionStart) { continue; @@ -1576,17 +1574,17 @@ ContentCacheInParent::AppendEventMessage mRequestIMEToCommitCompositionResults) { aLog.AppendLiteral(" "); aLog.Append(ToReadableText(result)); aLog.AppendLiteral("\n"); } aLog.AppendLiteral("\n"); } -#endif // #if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#endif // #if MOZ_DIAGNOSTIC_ASSERT_ENABLED /***************************************************************************** * mozilla::ContentCache::TextRectArray *****************************************************************************/ LayoutDeviceIntRect ContentCache::TextRectArray::GetRect(uint32_t aOffset) const {
--- a/widget/ContentCache.h +++ b/widget/ContentCache.h @@ -405,17 +405,17 @@ public: const IMENotification& aNotification); private: IMENotification mPendingSelectionChange; IMENotification mPendingTextChange; IMENotification mPendingLayoutChange; IMENotification mPendingCompositionUpdate; -#if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#if MOZ_DIAGNOSTIC_ASSERT_ENABLED // Log of event messages to be output to crash report. nsTArray<EventMessage> mDispatchedEventMessages; nsTArray<EventMessage> mReceivedEventMessages; // Log of RequestIMEToCommitComposition() in the last 2 compositions. enum class RequestIMEToCommitCompositionResult : uint8_t { eToOldCompositionReceived, eToCommittedCompositionReceived, @@ -445,17 +445,17 @@ private: case RequestIMEToCommitCompositionResult::eHandledSynchronously: return "Commit reqeust is handled synchronously"; default: return "Unknown reason"; } } nsTArray<RequestIMEToCommitCompositionResult> mRequestIMEToCommitCompositionResults; -#endif // #if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#endif // MOZ_DIAGNOSTIC_ASSERT_ENABLED // mTabParent is owner of the instance. dom::TabParent& MOZ_NON_OWNING_REF mTabParent; // mCompositionString is composition string which were sent to the remote // process but not yet committed in the remote process. nsString mCompositionString; // This is not nullptr only while the instance is requesting IME to // composition. Then, data value of dispatched composition events should @@ -502,25 +502,25 @@ private: LayoutDeviceIntRect& aTextRect) const; bool GetUnionTextRects(uint32_t aOffset, uint32_t aLength, bool aRoundToExistingOffset, LayoutDeviceIntRect& aUnionTextRect) const; void FlushPendingNotifications(nsIWidget* aWidget); -#if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#if MOZ_DIAGNOSTIC_ASSERT_ENABLED /** * Remove unnecessary messages from mDispatchedEventMessages and * mReceivedEventMessages. */ void RemoveUnnecessaryEventMessageLog(); /** * Append event message log to aLog. */ void AppendEventMessageLog(nsACString& aLog) const; -#endif // #if defined(MOZ_CRASHREPORTER) && MOZ_DIAGNOSTIC_ASSERT_ENABLED +#endif // #if MOZ_DIAGNOSTIC_ASSERT_ENABLED }; } // namespace mozilla #endif // mozilla_ContentCache_h
--- a/widget/GfxInfoBase.cpp +++ b/widget/GfxInfoBase.cpp @@ -33,20 +33,16 @@ #include "mozilla/gfx/Logging.h" #include "mozilla/gfx/gfxVars.h" #include "MediaPrefs.h" #include "gfxPrefs.h" #include "gfxPlatform.h" #include "gfxConfig.h" #include "DriverCrashGuard.h" -#if defined(MOZ_CRASHREPORTER) -#include "nsExceptionHandler.h" -#endif - using namespace mozilla::widget; using namespace mozilla; using mozilla::MutexAutoLock; nsTArray<GfxDriverInfo>* GfxInfoBase::mDriverInfo; nsTArray<dom::GfxInfoFeatureStatus>* GfxInfoBase::mFeatureStatus; bool GfxInfoBase::mDriverInfoObserverInitialized; bool GfxInfoBase::mShutdownOccurred;
--- a/widget/GfxInfoX11.cpp +++ b/widget/GfxInfoX11.cpp @@ -6,24 +6,22 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <errno.h> #include <sys/utsname.h> #include "nsCRTGlue.h" +#include "nsExceptionHandler.h" +#include "nsICrashReporter.h" #include "prenv.h" #include "GfxInfoX11.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#include "nsICrashReporter.h" -#endif namespace mozilla { namespace widget { #ifdef DEBUG NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug) #endif @@ -171,37 +169,35 @@ GfxInfo::GetData() mAdapterDescription.AppendPrintf(" (exited with status %d)", WEXITSTATUS(glxtest_status)); if (received_signal) mAdapterDescription.AppendPrintf(" (received signal %d)", WTERMSIG(glxtest_status)); if (bytesread) { mAdapterDescription.AppendLiteral(": "); mAdapterDescription.Append(nsDependentCString(buf)); mAdapterDescription.Append('\n'); } -#ifdef MOZ_CRASHREPORTER + CrashReporter::AppendAppNotesToCrashReport(mAdapterDescription); -#endif return; } mAdapterDescription.Append(mVendor); mAdapterDescription.AppendLiteral(" -- "); mAdapterDescription.Append(mRenderer); nsAutoCString note; note.AppendLiteral("OpenGL: "); note.Append(mAdapterDescription); note.AppendLiteral(" -- "); note.Append(mVersion); if (mHasTextureFromPixmap) note.AppendLiteral(" -- texture_from_pixmap"); note.Append('\n'); -#ifdef MOZ_CRASHREPORTER + CrashReporter::AppendAppNotesToCrashReport(note); -#endif // determine the major OpenGL version. That's the first integer in the version string. mGLMajorVersion = strtol(mVersion.get(), 0, 10); // determine driver type (vendor) and where in the version string // the actual driver version numbers should be expected to be found (whereToReadVersionNumbers) const char *whereToReadVersionNumbers = nullptr; const char *Mesa_in_version_string = strstr(mVersion.get(), "Mesa");
--- a/widget/android/GfxInfo.cpp +++ b/widget/android/GfxInfo.cpp @@ -3,27 +3,25 @@ * 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 "GfxInfo.h" #include "GLContext.h" #include "GLContextProvider.h" #include "nsUnicharUtils.h" #include "prenv.h" +#include "nsExceptionHandler.h" #include "nsHashKeys.h" +#include "nsICrashReporter.h" #include "nsVersionComparator.h" #include "AndroidBridge.h" #include "nsIWindowWatcher.h" #include "nsServiceManagerUtils.h" -#if defined(MOZ_CRASHREPORTER) -#include "nsExceptionHandler.h" -#include "nsICrashReporter.h" #define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1" -#endif namespace mozilla { namespace widget { class GfxInfo::GLStrings { nsCString mVendor; nsCString mRenderer; @@ -345,31 +343,29 @@ GfxInfo::GetIsGPU2Active(bool* aIsGPU2Ac { EnsureInitialized(); return NS_ERROR_FAILURE; } void GfxInfo::AddCrashReportAnnotations() { -#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterVendorID"), mGLStrings->Vendor()); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDeviceID"), mGLStrings->Renderer()); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AdapterDriverVersion"), mGLStrings->Version()); /* Add an App Note for now so that we get the data immediately. These * can go away after we store the above in the socorro db */ nsAutoCString note; note.AppendPrintf("AdapterDescription: '%s'\n", mAdapterDescription.get()); CrashReporter::AppendAppNotesToCrashReport(note); -#endif } const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() { if (mDriverInfo->IsEmpty()) { APPEND_TO_DRIVER_BLOCKLIST2(OperatingSystem::Android, (nsAString&) GfxDriverInfo::GetDeviceVendor(VendorAll), GfxDriverInfo::allDevices,
--- a/widget/android/jni/Utils.cpp +++ b/widget/android/jni/Utils.cpp @@ -4,20 +4,17 @@ #include <android/log.h> #include <pthread.h> #include "mozilla/Assertions.h" #include "GeneratedJNIWrappers.h" #include "AndroidBuild.h" #include "nsAppShell.h" - -#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" -#endif namespace mozilla { namespace jni { namespace detail { #define DEFINE_PRIMITIVE_TYPE_ADAPTER(NativeType, JNIType, JNIName, ABIName) \ \ @@ -201,30 +198,28 @@ bool HandleUncaughtException(JNIEnv* aEn return true; } bool ReportException(JNIEnv* aEnv, jthrowable aExc, jstring aStack) { bool result = true; -#ifdef MOZ_CRASHREPORTER result &= NS_SUCCEEDED(CrashReporter::AnnotateCrashReport( NS_LITERAL_CSTRING("JavaStackTrace"), String::Ref::From(aStack)->ToCString())); auto appNotes = java::GeckoAppShell::GetAppNotes(); if (NS_WARN_IF(aEnv->ExceptionCheck())) { aEnv->ExceptionDescribe(); aEnv->ExceptionClear(); } else if (appNotes) { CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("\n") + appNotes->ToCString()); } -#endif // MOZ_CRASHREPORTER if (sOOMErrorClass && aEnv->IsInstanceOf(aExc, sOOMErrorClass)) { NS_ABORT_OOM(0); // Unknown OOM size } return result; } namespace {
--- a/widget/android/nsAppShell.cpp +++ b/widget/android/nsAppShell.cpp @@ -4,21 +4,23 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsAppShell.h" #include "base/basictypes.h" #include "base/message_loop.h" #include "base/task.h" #include "mozilla/Hal.h" +#include "nsExceptionHandler.h" #include "nsIScreen.h" #include "nsIScreenManager.h" #include "nsWindow.h" #include "nsThreadUtils.h" #include "nsICommandLineRunner.h" +#include "nsICrashReporter.h" #include "nsIObserverService.h" #include "nsIAppStartup.h" #include "nsIGeolocationProvider.h" #include "nsCacheService.h" #include "nsIDOMEventListener.h" #include "nsIDOMClientRectList.h" #include "nsIDOMClientRect.h" #include "nsIDOMWakeLockListener.h" @@ -53,21 +55,16 @@ #include "nsIURI.h" #include "IHistory.h" #endif #ifdef MOZ_LOGGING #include "mozilla/Logging.h" #endif -#ifdef MOZ_CRASHREPORTER -#include "nsICrashReporter.h" -#include "nsExceptionHandler.h" -#endif - #include "AndroidAlerts.h" #include "AndroidUiThread.h" #include "ANRReporter.h" #include "GeckoBatteryManager.h" #include "GeckoNetworkManager.h" #include "GeckoProcessManager.h" #include "GeckoScreenOrientation.h" #include "GeckoVRManager.h"
--- a/widget/cocoa/GfxInfo.mm +++ b/widget/cocoa/GfxInfo.mm @@ -5,29 +5,27 @@ #include <OpenGL/OpenGL.h> #include <OpenGL/CGLRenderers.h> #include "mozilla/ArrayUtils.h" #include "GfxInfo.h" #include "nsUnicharUtils.h" +#include "nsExceptionHandler.h" #include "nsCocoaFeatures.h" +#include "nsICrashReporter.h" #include "mozilla/Preferences.h" #include <algorithm> #import <Foundation/Foundation.h> #import <IOKit/IOKitLib.h> #import <Cocoa/Cocoa.h> -#if defined(MOZ_CRASHREPORTER) -#include "nsExceptionHandler.h" -#include "nsICrashReporter.h" #define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1" -#endif using namespace mozilla; using namespace mozilla::widget; #ifdef DEBUG NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug) #endif @@ -270,17 +268,16 @@ NS_IMETHODIMP GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) { return NS_ERROR_FAILURE; } void GfxInfo::AddCrashReportAnnotations() { -#if defined(MOZ_CRASHREPORTER) nsString deviceID, vendorID, driverVersion; nsAutoCString narrowDeviceID, narrowVendorID, narrowDriverVersion; GetAdapterDeviceID(deviceID); CopyUTF16toUTF8(deviceID, narrowDeviceID); GetAdapterVendorID(vendorID); CopyUTF16toUTF8(vendorID, narrowVendorID); GetAdapterDriverVersion(driverVersion); @@ -296,17 +293,16 @@ GfxInfo::AddCrashReportAnnotations() * can go away after we store the above in the socorro db */ nsAutoCString note; /* AppendPrintf only supports 32 character strings, mrghh. */ note.AppendLiteral("AdapterVendorID: "); note.Append(narrowVendorID); note.AppendLiteral(", AdapterDeviceID: "); note.Append(narrowDeviceID); CrashReporter::AppendAppNotesToCrashReport(note); -#endif } // We don't support checking driver versions on Mac. #define IMPLEMENT_MAC_DRIVER_BLOCKLIST(os, vendor, device, features, blockOn, ruleId) \ APPEND_TO_DRIVER_BLOCKLIST(os, vendor, device, features, blockOn, \ DRIVER_COMPARISON_IGNORED, V(0,0,0,0), ruleId, "")
--- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -14,16 +14,17 @@ #include "nsCocoaWindow.h" #include "mozilla/MiscEvents.h" #include "mozilla/MouseEvents.h" #include "mozilla/TextEvents.h" #include "mozilla/TouchEvents.h" #include "nsArrayUtils.h" +#include "nsExceptionHandler.h" #include "nsObjCExceptions.h" #include "nsCOMPtr.h" #include "nsThreadUtils.h" #include "nsToolkit.h" #include "nsCRT.h" #include "nsFontMetrics.h" #include "nsIRollupListener.h" @@ -78,19 +79,16 @@ #include "gfxPrefs.h" #include "mozilla/gfx/2D.h" #include "mozilla/gfx/BorrowedContext.h" #include "mozilla/gfx/MacIOSurface.h" #ifdef ACCESSIBILITY #include "nsAccessibilityService.h" #include "mozilla/a11y/Platform.h" #endif -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif #include "mozilla/Preferences.h" #include <dlfcn.h> #include <ApplicationServices/ApplicationServices.h> #include "GeckoProfiler.h" @@ -5518,41 +5516,40 @@ GetIntegerDeltaForEvent(NSEvent* aEvent) NSWindow *viewWindow = [self window]; if (viewWindow && [viewWindow isKeyWindow]) { [viewWindow orderWindow:NSWindowAbove relativeTo:0]; } #if !defined(RELEASE_OR_BETA) || defined(DEBUG) if (!Preferences::GetBool("intl.allow-insecure-text-input", false) && mGeckoChild && mTextInputHandler && mTextInputHandler->IsFocused()) { -#ifdef MOZ_CRASHREPORTER NSWindow* window = [self window]; NSString* info = [NSString stringWithFormat:@"\nview [%@], window [%@], window is key %i, is fullscreen %i, app is active %i", self, window, [window isKeyWindow], ([window styleMask] & (1 << 14)) != 0, [NSApp isActive]]; nsAutoCString additionalInfo([info UTF8String]); -#endif + if (mGeckoChild->GetInputContext().IsPasswordEditor() && !TextInputHandler::IsSecureEventInputEnabled()) { #define CRASH_MESSAGE "A password editor has focus, but not in secure input mode" -#ifdef MOZ_CRASHREPORTER + CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("\nBug 893973: ") + NS_LITERAL_CSTRING(CRASH_MESSAGE)); CrashReporter::AppendAppNotesToCrashReport(additionalInfo); -#endif + MOZ_CRASH(CRASH_MESSAGE); #undef CRASH_MESSAGE } else if (!mGeckoChild->GetInputContext().IsPasswordEditor() && TextInputHandler::IsSecureEventInputEnabled()) { #define CRASH_MESSAGE "A non-password editor has focus, but in secure input mode" -#ifdef MOZ_CRASHREPORTER + CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("\nBug 893973: ") + NS_LITERAL_CSTRING(CRASH_MESSAGE)); CrashReporter::AppendAppNotesToCrashReport(additionalInfo); -#endif + MOZ_CRASH(CRASH_MESSAGE); #undef CRASH_MESSAGE } } #endif // #if !defined(RELEASE_OR_BETA) || defined(DEBUG) nsAutoRetainCocoaObject kungFuDeathGrip(self); if (mGeckoChild) {
--- a/widget/nsBaseAppShell.cpp +++ b/widget/nsBaseAppShell.cpp @@ -1,19 +1,17 @@ /* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */ /* 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 "base/message_loop.h" #include "nsBaseAppShell.h" -#if defined(MOZ_CRASHREPORTER) #include "nsExceptionHandler.h" -#endif #include "nsThreadUtils.h" #include "nsIObserverService.h" #include "nsServiceManagerUtils.h" #include "mozilla/Services.h" #include "nsXULAppAPI.h" // When processing the next thread event, the appshell may process native // events (if not in performance mode), which can result in suppressing the @@ -315,28 +313,24 @@ nsBaseAppShell::DispatchDummyEvent(nsITh return NS_SUCCEEDED(aTarget->Dispatch(mDummyEvent, NS_DISPATCH_NORMAL)); } void nsBaseAppShell::IncrementEventloopNestingLevel() { ++mEventloopNestingLevel; -#if defined(MOZ_CRASHREPORTER) CrashReporter::SetEventloopNestingLevel(mEventloopNestingLevel); -#endif } void nsBaseAppShell::DecrementEventloopNestingLevel() { --mEventloopNestingLevel; -#if defined(MOZ_CRASHREPORTER) CrashReporter::SetEventloopNestingLevel(mEventloopNestingLevel); -#endif } // Called from the main thread NS_IMETHODIMP nsBaseAppShell::AfterProcessNextEvent(nsIThreadInternal *thr, bool eventWasProcessed) { return NS_OK;
--- a/widget/windows/GfxInfo.cpp +++ b/widget/windows/GfxInfo.cpp @@ -13,25 +13,23 @@ #include "GfxInfoWebGL.h" #include "nsUnicharUtils.h" #include "prenv.h" #include "prprf.h" #include "GfxDriverInfo.h" #include "mozilla/Preferences.h" #include "mozilla/gfx/DeviceManagerDx.h" #include "mozilla/gfx/Logging.h" +#include "nsExceptionHandler.h" +#include "nsICrashReporter.h" #include "nsPrintfCString.h" #include "jsapi.h" #include <intrin.h> -#if defined(MOZ_CRASHREPORTER) -#include "nsExceptionHandler.h" -#include "nsICrashReporter.h" #define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1" -#endif using namespace mozilla; using namespace mozilla::gfx; using namespace mozilla::widget; #ifdef DEBUG NS_IMPL_ISUPPORTS_INHERITED(GfxInfo, GfxInfoBase, nsIGfxInfoDebug) #endif @@ -849,37 +847,34 @@ NS_IMETHODIMP GfxInfo::GetIsGPU2Active(bool* aIsGPU2Active) { // This is never the case, as the active GPU ends up being // the first one. It should probably be removed. *aIsGPU2Active = false; return NS_OK; } -#if defined(MOZ_CRASHREPORTER) /* Cisco's VPN software can cause corruption of the floating point state. * Make a note of this in our crash reports so that some weird crashes * make more sense */ static void CheckForCiscoVPN() { LONG result; HKEY key; /* This will give false positives, but hopefully no false negatives */ result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Cisco Systems\\VPN Client", 0, KEY_QUERY_VALUE, &key); if (result == ERROR_SUCCESS) { RegCloseKey(key); CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("Cisco VPN\n")); } } -#endif void GfxInfo::AddCrashReportAnnotations() { -#if defined(MOZ_CRASHREPORTER) CheckForCiscoVPN(); if (mHasDriverVersionMismatch) { CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("DriverVersionMismatch\n")); } nsString deviceID, vendorID, driverVersion, subsysID; nsCString narrowDeviceID, narrowVendorID, narrowDriverVersion, narrowSubsysID; @@ -949,18 +944,16 @@ GfxInfo::AddCrashReportAnnotations() note.AppendLiteral(", AdapterDeviceID2: "); note.Append(narrowDeviceID2); note.AppendLiteral(", AdapterSubsysID2: "); note.Append(narrowSubsysID2); note.AppendLiteral(", AdapterDriverVersion2: "); note.Append(NS_LossyConvertUTF16toASCII(adapterDriverVersionString2)); } CrashReporter::AppendAppNotesToCrashReport(note); - -#endif } static OperatingSystem WindowsVersionToOperatingSystem(int32_t aWindowsVersion) { switch(aWindowsVersion) { case kWindows7: return OperatingSystem::Windows7;
--- a/widget/windows/KeyboardLayout.cpp +++ b/widget/windows/KeyboardLayout.cpp @@ -7,19 +7,17 @@ #include "mozilla/ArrayUtils.h" #include "mozilla/DebugOnly.h" #include "mozilla/MouseEvents.h" #include "mozilla/MiscEvents.h" #include "mozilla/TextEvents.h" #include "nsAlgorithm.h" -#ifdef MOZ_CRASHREPORTER #include "nsExceptionHandler.h" -#endif #include "nsGkAtoms.h" #include "nsIIdleServiceInternal.h" #include "nsIWindowsRegKey.h" #include "nsMemory.h" #include "nsPrintfCString.h" #include "nsQuickSort.h" #include "nsServiceManagerUtils.h" #include "nsToolkit.h" @@ -2691,18 +2689,16 @@ NativeKey::NeedsToHandleWithoutFollowing return false; } // Even if the key is a printable key, it might cause non-printable character // input with modifier key(s). return mIsPrintableKey; } -#ifdef MOZ_CRASHREPORTER - static nsCString GetResultOfInSendMessageEx() { DWORD ret = ::InSendMessageEx(nullptr); if (!ret) { return NS_LITERAL_CSTRING("ISMEX_NOSEND"); } nsAutoCString result; @@ -2725,18 +2721,16 @@ GetResultOfInSendMessageEx() if (!result.IsEmpty()) { result += " | "; } result += "ISMEX_SEND"; } return result; } -#endif // #ifdef MOZ_CRASHREPORTER - bool NativeKey::MayBeSameCharMessage(const MSG& aCharMsg1, const MSG& aCharMsg2) const { // NOTE: Although, we don't know when this case occurs, the scan code value // in lParam may be changed from 0 to something. The changed value // is different from the scan code of handling keydown message. static const LPARAM kScanCodeMask = 0x00FF0000; @@ -2970,17 +2964,16 @@ NativeKey::GetFollowingCharMessage(MSG& } MOZ_LOG(sNativeKeyLogger, LogLevel::Error, ("%p NativeKey::GetFollowingCharMessage(), FAILED, lost target " "message to remove, nextKeyMsg=%s", this, ToString(nextKeyMsg).get())); } if (doCrash) { -#ifdef MOZ_CRASHREPORTER nsPrintfCString info("\nPeekMessage() failed to remove char message! " "\nActive keyboard layout=0x%08X (%s), " "\nHandling message: %s, InSendMessageEx()=%s, " "\nFound message: %s, " "\nWM_NULL has been removed: %d, " "\nNext key message in all windows: %s, " "time=%d, ", KeyboardLayout::GetActiveLayout(), @@ -2996,17 +2989,17 @@ NativeKey::GetFollowingCharMessage(MSG& PM_NOREMOVE | PM_NOYIELD)) { nsPrintfCString info("\nNext message in all windows: %s, time=%d", ToString(nextMsg).get(), nextMsg.time); CrashReporter::AppendAppNotesToCrashReport(info); } else { CrashReporter::AppendAppNotesToCrashReport( NS_LITERAL_CSTRING("\nThere is no message in any window")); } -#endif // #ifdef MOZ_CRASHREPORTER + MOZ_CRASH("We lost the following char message"); } // We're still not sure why ::PeekMessage() may return WM_NULL even with // its first message and its last message are same message. However, // at developing Metrofox, we met this case even with usual keyboard // layouts. So, it might be possible in desktop application or it really // occurs with some odd keyboard layouts which perhaps hook API. @@ -3115,17 +3108,16 @@ NativeKey::GetFollowingCharMessage(MSG& // in lParam may be changed from 0 to something. The changed value // is different from the scan code of handling keydown message. MOZ_LOG(sNativeKeyLogger, LogLevel::Error, ("%p NativeKey::GetFollowingCharMessage(), FAILED, removed message " "is really different from what we have already found, removedMsg=%s, " "nextKeyMsg=%s, kFoundCharMsg=%s", this, ToString(removedMsg).get(), ToString(nextKeyMsg).get(), ToString(kFoundCharMsg).get())); -#ifdef MOZ_CRASHREPORTER nsPrintfCString info("\nPeekMessage() removed unexpcted char message! " "\nActive keyboard layout=0x%08X (%s), " "\nHandling message: %s, InSendMessageEx()=%s, " "\nFound message: %s, " "\nRemoved message: %s, ", KeyboardLayout::GetActiveLayout(), KeyboardLayout::GetActiveLayoutName().get(), ToString(mMsg).get(), @@ -3153,35 +3145,33 @@ NativeKey::GetFollowingCharMessage(MSG& PM_NOREMOVE | PM_NOYIELD)) { nsPrintfCString info("\nNext key message in all windows: %s.", ToString(nextKeyMsgInAllWindows).get()); CrashReporter::AppendAppNotesToCrashReport(info); } else { CrashReporter::AppendAppNotesToCrashReport( NS_LITERAL_CSTRING("\nThere is no key message in any windows.")); } -#endif // #ifdef MOZ_CRASHREPORTER + MOZ_CRASH("PeekMessage() removed unexpected message"); } MOZ_LOG(sNativeKeyLogger, LogLevel::Error, ("%p NativeKey::GetFollowingCharMessage(), FAILED, removed messages " "are all WM_NULL, nextKeyMsg=%s", this, ToString(nextKeyMsg).get())); -#ifdef MOZ_CRASHREPORTER nsPrintfCString info("\nWe lost following char message! " "\nActive keyboard layout=0x%08X (%s), " "\nHandling message: %s, InSendMessageEx()=%s, \n" "Found message: %s, removed a lot of WM_NULL", KeyboardLayout::GetActiveLayout(), KeyboardLayout::GetActiveLayoutName().get(), ToString(mMsg).get(), GetResultOfInSendMessageEx().get(), ToString(kFoundCharMsg).get()); CrashReporter::AppendAppNotesToCrashReport(info); -#endif // #ifdef MOZ_CRASHREPORTER MOZ_CRASH("We lost the following char message"); return false; } bool NativeKey::MaybeDispatchPluginEventsForRemovedCharMessages() const { MOZ_ASSERT(IsKeyDownMessage());
--- a/widget/windows/moz.build +++ b/widget/windows/moz.build @@ -37,16 +37,17 @@ UNIFIED_SOURCES += [ 'CompositorWidgetParent.cpp', 'GfxInfo.cpp', 'IEnumFE.cpp', 'IMMHandler.cpp', 'InkCollector.cpp', 'InProcessWinCompositorWidget.cpp', 'JumpListItem.cpp', 'KeyboardLayout.cpp', + 'LSPAnnotator.cpp', 'nsAppShell.cpp', 'nsClipboard.cpp', 'nsColorPicker.cpp', 'nsDataObj.cpp', 'nsDataObjCollection.cpp', 'nsDragService.cpp', 'nsIdleServiceWin.cpp', 'nsImageClipboard.cpp', @@ -82,21 +83,16 @@ SOURCES += [ 'nsBidiKeyboard.cpp', 'nsFilePicker.cpp', 'nsWidgetFactory.cpp', 'WinCompositorWidget.cpp', 'WindowsUIUtils.cpp', 'WinMouseScrollHandler.cpp', ] -if CONFIG['MOZ_CRASHREPORTER']: - UNIFIED_SOURCES += [ - 'LSPAnnotator.cpp', - ] - if CONFIG['NS_PRINTING']: UNIFIED_SOURCES += [ 'nsDeviceContextSpecWin.cpp', 'nsPrintDialogUtil.cpp', 'nsPrintDialogWin.cpp', 'nsPrintOptionsWin.cpp', 'nsPrintSettingsWin.cpp', ]
--- a/widget/windows/nsAppShell.cpp +++ b/widget/windows/nsAppShell.cpp @@ -159,19 +159,17 @@ nsAppShell::~nsAppShell() // the UI thread. SendMessage(mEventWnd, WM_CLOSE, 0, 0); } } nsresult nsAppShell::Init() { -#ifdef MOZ_CRASHREPORTER LSPAnnotate(); -#endif mLastNativeEventScheduled = TimeStamp::NowLoRes(); mozilla::ipc::windows::InitUIThread(); sTaskbarButtonCreatedMsg = ::RegisterWindowMessageW(kTaskbarButtonEventId); NS_ASSERTION(sTaskbarButtonCreatedMsg, "Could not register taskbar button creation message");
--- a/xpcom/base/CycleCollectedJSContext.cpp +++ b/xpcom/base/CycleCollectedJSContext.cpp @@ -32,20 +32,16 @@ #include "nsCycleCollectionParticipant.h" #include "nsCycleCollector.h" #include "nsDOMJSUtils.h" #include "nsDOMMutationObserver.h" #include "nsJSUtils.h" #include "nsWrapperCache.h" #include "nsStringBuffer.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - #include "nsIException.h" #include "nsIPlatformInfo.h" #include "nsThread.h" #include "nsThreadUtils.h" #include "xpcpublic.h" using namespace mozilla; using namespace mozilla::dom;
--- a/xpcom/base/CycleCollectedJSRuntime.cpp +++ b/xpcom/base/CycleCollectedJSRuntime.cpp @@ -76,29 +76,26 @@ #include "jsprf.h" #include "js/Debug.h" #include "js/GCAPI.h" #include "nsContentUtils.h" #include "nsCycleCollectionNoteRootCallback.h" #include "nsCycleCollectionParticipant.h" #include "nsCycleCollector.h" #include "nsDOMJSUtils.h" +#include "nsExceptionHandler.h" #include "nsJSUtils.h" #include "nsWrapperCache.h" #include "nsStringBuffer.h" #include "GeckoProfiler.h" #ifdef MOZ_GECKO_PROFILER #include "ProfilerMarkerPayload.h" #endif -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - #include "nsIException.h" #include "nsIPlatformInfo.h" #include "nsThread.h" #include "nsThreadUtils.h" #include "xpcpublic.h" using namespace mozilla; using namespace mozilla::dom; @@ -540,20 +537,19 @@ CycleCollectedJSRuntime::CycleCollectedJ aCx, GCNurseryCollectionCallback); } JS_SetObjectsTenuredCallback(aCx, JSObjectsTenuredCb, this); JS::SetOutOfMemoryCallback(aCx, OutOfMemoryCallback, this); JS_SetExternalStringSizeofCallback(aCx, SizeofExternalStringCallback); JS::SetBuildIdOp(aCx, GetBuildId); JS::SetWarningReporter(aCx, MozCrashWarningReporter); -#ifdef MOZ_CRASHREPORTER - js::AutoEnterOOMUnsafeRegion::setAnnotateOOMAllocationSizeCallback( - CrashReporter::AnnotateOOMAllocationSize); -#endif + + js::AutoEnterOOMUnsafeRegion::setAnnotateOOMAllocationSizeCallback( + CrashReporter::AnnotateOOMAllocationSize); static js::DOMCallbacks DOMcallbacks = { InstanceClassHasProtoAtDepth }; SetDOMCallbacks(aCx, &DOMcallbacks); js::SetScriptEnvironmentPreparer(aCx, &mEnvironmentPreparer); JS::dbg::SetDebuggerMallocSizeOf(aCx, moz_malloc_size_of); @@ -1442,46 +1438,42 @@ CycleCollectedJSRuntime::FinalizeDeferre } } void CycleCollectedJSRuntime::AnnotateAndSetOutOfMemory(OOMState* aStatePtr, OOMState aNewState) { *aStatePtr = aNewState; -#ifdef MOZ_CRASHREPORTER CrashReporter::AnnotateCrashReport(aStatePtr == &mOutOfMemoryState ? NS_LITERAL_CSTRING("JSOutOfMemory") : NS_LITERAL_CSTRING("JSLargeAllocationFailure"), aNewState == OOMState::Reporting ? NS_LITERAL_CSTRING("Reporting") : aNewState == OOMState::Reported ? NS_LITERAL_CSTRING("Reported") : NS_LITERAL_CSTRING("Recovered")); -#endif } void CycleCollectedJSRuntime::OnGC(JSContext* aContext, JSGCStatus aStatus) { switch (aStatus) { case JSGC_BEGIN: nsCycleCollector_prepareForGarbageCollection(); mZonesWaitingForGC.Clear(); break; case JSGC_END: { -#ifdef MOZ_CRASHREPORTER if (mOutOfMemoryState == OOMState::Reported) { AnnotateAndSetOutOfMemory(&mOutOfMemoryState, OOMState::Recovered); } if (mLargeAllocationFailureState == OOMState::Reported) { AnnotateAndSetOutOfMemory(&mLargeAllocationFailureState, OOMState::Recovered); } -#endif // Do any deferred finalization of native objects. Normally we do this // incrementally for an incremental GC, and immediately for a // non-incremental GC, on the basis that the type of GC reflects how // urgently resources should be destroyed. However under some circumstances // (such as in js::InternalCallOrConstruct) we can end up running a // non-incremental GC when there is a pending exception, and the finalizers // are not set up to handle that. In that case, just run them later, after
--- a/xpcom/base/nsCrashOnException.cpp +++ b/xpcom/base/nsCrashOnException.cpp @@ -1,34 +1,31 @@ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 "nsCrashOnException.h" #include "nsCOMPtr.h" +#include "nsICrashReporter.h" #include "nsServiceManagerUtils.h" -#ifdef MOZ_CRASHREPORTER -#include "nsICrashReporter.h" -#endif namespace mozilla { static int ReportException(EXCEPTION_POINTERS* aExceptionInfo) { -#ifdef MOZ_CRASHREPORTER nsCOMPtr<nsICrashReporter> cr = do_GetService("@mozilla.org/toolkit/crash-reporter;1"); if (cr) { cr->WriteMinidumpForException(aExceptionInfo); } -#endif + return EXCEPTION_EXECUTE_HANDLER; } XPCOM_API(LRESULT) CallWindowProcCrashProtected(WNDPROC aWndProc, HWND aHWnd, UINT aMsg, WPARAM aWParam, LPARAM aLParam) { MOZ_SEH_TRY {
--- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -162,16 +162,17 @@ #include "mozilla/LinkedList.h" #include "mozilla/MemoryReporting.h" #include "mozilla/Move.h" #include "mozilla/SegmentedVector.h" #include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionNoteRootCallback.h" #include "nsDeque.h" +#include "nsExceptionHandler.h" #include "nsCycleCollector.h" #include "nsThreadUtils.h" #include "nsXULAppAPI.h" #include "prenv.h" #include "nsPrintfCString.h" #include "nsTArray.h" #include "nsIConsoleService.h" #include "mozilla/Attributes.h" @@ -186,20 +187,16 @@ #include <stdio.h> #include "mozilla/AutoGlobalTimelineMarker.h" #include "mozilla/Likely.h" #include "mozilla/PoisonIOInterposer.h" #include "mozilla/Telemetry.h" #include "mozilla/ThreadLocal.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - using namespace mozilla; struct NurseryPurpleBufferEntry { void* mPtr; nsCycleCollectionParticipant* mParticipant; nsCycleCollectingAutoRefCnt* mRefCnt; }; @@ -663,24 +660,22 @@ public: void PtrInfo::AnnotatedReleaseAssert(bool aCondition, const char* aMessage) { if (aCondition) { return; } -#ifdef MOZ_CRASHREPORTER const char* piName = "Unknown"; if (mParticipant) { piName = mParticipant->ClassName(); } nsPrintfCString msg("%s, for class %s", aMessage, piName); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("CycleCollector"), msg); -#endif MOZ_CRASH(); } /** * A structure designed to be used like a linked list of PtrInfo, except * it allocates many PtrInfos at a time. */
--- a/xpcom/base/nsDebugImpl.cpp +++ b/xpcom/base/nsDebugImpl.cpp @@ -8,19 +8,17 @@ #include "base/process_util.h" #include "mozilla/Atomics.h" #include "mozilla/Printf.h" #include "MainThreadUtils.h" #include "nsDebugImpl.h" #include "nsDebug.h" -#ifdef MOZ_CRASHREPORTER -# include "nsExceptionHandler.h" -#endif +#include "nsExceptionHandler.h" #include "nsString.h" #include "nsXULAppAPI.h" #include "prprf.h" #include "nsError.h" #include "prerror.h" #include "prerr.h" #include "prenv.h" @@ -387,31 +385,29 @@ NS_DebugBreak(uint32_t aSeverity, const case NS_DEBUG_WARNING: return; case NS_DEBUG_BREAK: Break(buf.buffer); return; case NS_DEBUG_ABORT: { -#if defined(MOZ_CRASHREPORTER) // Updating crash annotations in the child causes us to do IPC. This can // really cause trouble if we're asserting from within IPC code. So we // have to do without the annotations in that case. if (XRE_IsParentProcess()) { // Don't include the PID in the crash report annotation to // allow faceting on crash-stats.mozilla.org. nsCString note("xpcom_runtime_abort("); note += nonPIDBuf.buffer; note += ")"; CrashReporter::AppendAppNotesToCrashReport(note); CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AbortMessage"), nsDependentCString(nonPIDBuf.buffer)); } -#endif // MOZ_CRASHREPORTER #if defined(DEBUG) && defined(_WIN32) RealBreak(); #endif #if defined(DEBUG) nsTraceRefcnt::WalkTheStack(stderr); #endif Abort(buf.buffer); @@ -609,13 +605,11 @@ NS_ErrorAccordingToNSPR() case PR_NO_ACCESS_RIGHTS_ERROR: return NS_ERROR_FILE_ACCESS_DENIED; default: return NS_ERROR_FAILURE; } } void NS_ABORT_OOM(size_t aSize) { -#if defined(MOZ_CRASHREPORTER) CrashReporter::AnnotateOOMAllocationSize(aSize); -#endif MOZ_CRASH("OOM"); }
--- a/xpcom/base/nsObjCExceptions.h +++ b/xpcom/base/nsObjCExceptions.h @@ -12,17 +12,17 @@ #define nsObjCExceptions_h_ #import <Foundation/Foundation.h> #ifdef DEBUG #import <ExceptionHandling/NSExceptionHandler.h> #endif -#if defined(MOZ_CRASHREPORTER) && defined(__cplusplus) +#if defined(__cplusplus) #include "nsICrashReporter.h" #include "nsCOMPtr.h" #include "nsServiceManagerUtils.h" #endif #include <unistd.h> #include <signal.h> #include "nsError.h" @@ -42,17 +42,17 @@ __attribute__((unused)) static void nsObjCExceptionLog(NSException* aException) { NSLog(@"Mozilla has caught an Obj-C exception [%@: %@]", [aException name], [aException reason]); -#if defined(MOZ_CRASHREPORTER) && defined(__cplusplus) +#if defined(__cplusplus) // Attach exception info to the crash report. nsCOMPtr<nsICrashReporter> crashReporter = do_GetService("@mozilla.org/toolkit/crash-reporter;1"); if (crashReporter) { crashReporter->AppendObjCExceptionInfoToAppNotes(static_cast<void*>(aException)); } #endif
--- a/xpcom/build/nsXULAppAPI.h +++ b/xpcom/build/nsXULAppAPI.h @@ -398,26 +398,24 @@ XRE_API(const char*, #if defined(MOZ_WIDGET_ANDROID) XRE_API(void, XRE_SetAndroidChildFds, (JNIEnv* env, int crashFd, int ipcFd)) #endif // defined(MOZ_WIDGET_ANDROID) XRE_API(void, XRE_SetProcessType, (const char* aProcessTypeString)) -#if defined(MOZ_CRASHREPORTER) // Used in the "master" parent process hosting the crash server XRE_API(bool, XRE_TakeMinidumpForChild, (uint32_t aChildPid, nsIFile** aDump, uint32_t* aSequence)) // Used in child processes. XRE_API(bool, XRE_SetRemoteExceptionHandler, (const char* aPipe)) -#endif namespace mozilla { namespace gmp { class GMPLoader; } // namespace gmp } // namespace mozilla XRE_API(nsresult,
--- a/xpcom/system/moz.build +++ b/xpcom/system/moz.build @@ -1,25 +1,21 @@ # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- # vim: set filetype=python: # 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/. XPIDL_SOURCES += [ 'nsIBlocklistService.idl', + 'nsICrashReporter.idl', 'nsIDeviceSensors.idl', 'nsIGConfService.idl', 'nsIGeolocationProvider.idl', 'nsIGIOService.idl', 'nsIGSettingsService.idl', 'nsIHapticFeedback.idl', 'nsIPlatformInfo.idl', 'nsIXULAppInfo.idl', 'nsIXULRuntime.idl', ] -if CONFIG['MOZ_CRASHREPORTER']: - XPIDL_SOURCES += [ - 'nsICrashReporter.idl', - ] - XPIDL_MODULE = 'xpcom_system'
--- a/xpcom/tests/gtest/TestDeadlockDetector.cpp +++ b/xpcom/tests/gtest/TestDeadlockDetector.cpp @@ -3,30 +3,27 @@ * 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 "mozilla/ArrayUtils.h" #include "prthread.h" +#include "nsCOMPtr.h" +#include "nsICrashReporter.h" +#include "nsMemory.h" +#include "nsServiceManagerUtils.h" #include "nsTArray.h" -#include "nsMemory.h" #include "mozilla/CondVar.h" #include "mozilla/RecursiveMutex.h" #include "mozilla/ReentrantMonitor.h" #include "mozilla/Mutex.h" -#ifdef MOZ_CRASHREPORTER -#include "nsCOMPtr.h" -#include "nsICrashReporter.h" -#include "nsServiceManagerUtils.h" -#endif - #include "gtest/gtest.h" using namespace mozilla; // The code in this file is also used by // storage/test/gtest/test_deadlock_detector.cpp. The following two macros are // used to provide the necessary differentiation between this file and that // file. @@ -69,23 +66,21 @@ protected: } private: unsigned int mOldSleepDuration; }; void DisableCrashReporter() { -#ifdef MOZ_CRASHREPORTER nsCOMPtr<nsICrashReporter> crashreporter = do_GetService("@mozilla.org/toolkit/crash-reporter;1"); if (crashreporter) { crashreporter->SetEnabled(false); } -#endif } //----------------------------------------------------------------------------- // Single-threaded sanity tests // Stupidest possible deadlock. int Sanity_Child()
--- a/xpcom/tests/gtest/TestPLDHash.cpp +++ b/xpcom/tests/gtest/TestPLDHash.cpp @@ -1,35 +1,32 @@ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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 "PLDHashTable.h" #include "nsCOMPtr.h" +#include "nsICrashReporter.h" #include "nsServiceManagerUtils.h" #include "gtest/gtest.h" // This test mostly focuses on edge cases. But more coverage of normal // operations wouldn't be a bad thing. #ifdef XP_UNIX #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> // This global variable is defined in toolkit/xre/nsSigHandlers.cpp. extern unsigned int _gdb_sleep_duration; #endif -#ifdef MOZ_CRASHREPORTER -#include "nsICrashReporter.h" -#endif - // We can test that certain operations cause expected aborts by forking // and then checking that the child aborted in the expected way (i.e. via // MOZ_CRASH). We skip this for the following configurations. // - On Windows, because it doesn't have fork(). // - On non-DEBUG builds, because the crashes cause the crash reporter to pop // up when running this test locally, which is surprising and annoying. // - On ASAN builds, because ASAN alters the way a MOZ_CRASHing process // terminates, which makes it harder to test if the right thing has occurred. @@ -44,23 +41,21 @@ TestCrashyOperation(void (*aCrashyOperat int pid = fork(); ASSERT_NE(pid, -1); if (pid == 0) { // Disable the crashreporter -- writing a crash dump in the child will // prevent the parent from writing a subsequent dump. Crashes here are // expected, so we don't want their stacks to show up in the log anyway. -#ifdef MOZ_CRASHREPORTER nsCOMPtr<nsICrashReporter> crashreporter = do_GetService("@mozilla.org/toolkit/crash-reporter;1"); if (crashreporter) { crashreporter->SetEnabled(false); } -#endif // Child: perform the crashy operation. fprintf(stderr, "TestCrashyOperation: The following crash is expected. Do not panic.\n"); aCrashyOperation(); fprintf(stderr, "TestCrashyOperation: didn't crash?!\n"); ASSERT_TRUE(false); // shouldn't reach here }
--- a/xpcom/tests/gtest/TestSTLWrappers.cpp +++ b/xpcom/tests/gtest/TestSTLWrappers.cpp @@ -5,21 +5,19 @@ # error "failed to wrap <algorithm>" #endif #include <vector> #ifndef mozilla_vector_h # error "failed to wrap <vector>" #endif -#ifdef MOZ_CRASHREPORTER #include "nsCOMPtr.h" #include "nsICrashReporter.h" #include "nsServiceManagerUtils.h" -#endif // gcc errors out if we |try ... catch| with -fno-exceptions, but we // can still test on windows #ifdef _MSC_VER // C4530 will be generated whenever try...catch is used without // enabling exceptions. We know we don't enbale exceptions. # pragma warning( disable : 4530 ) # define TRY try @@ -36,23 +34,21 @@ extern unsigned int _gdb_sleep_duration; #endif void ShouldAbort() { #if defined(XP_UNIX) _gdb_sleep_duration = 0; #endif -#ifdef MOZ_CRASHREPORTER nsCOMPtr<nsICrashReporter> crashreporter = do_GetService("@mozilla.org/toolkit/crash-reporter;1"); if (crashreporter) { crashreporter->SetEnabled(false); } -#endif std::vector<int> v; int rv = 1; TRY { // v.at(1) on empty v should abort; NOT throw an exception // (Do some arithmetic with result of v.at() to avoid
--- a/xpcom/threads/HangMonitor.cpp +++ b/xpcom/threads/HangMonitor.cpp @@ -9,27 +9,24 @@ #include "mozilla/Atomics.h" #include "mozilla/BackgroundHangMonitor.h" #include "mozilla/Monitor.h" #include "mozilla/Preferences.h" #include "mozilla/ProcessedStack.h" #include "mozilla/Telemetry.h" #include "mozilla/StaticPtr.h" #include "mozilla/UniquePtr.h" +#include "nsExceptionHandler.h" #include "nsReadableUtils.h" #include "nsThreadUtils.h" #include "mozilla/StackWalk.h" #include "nsThreadUtils.h" #include "nsXULAppAPI.h" #include "GeckoProfiler.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - #ifdef XP_WIN #include <windows.h> #endif #if defined(MOZ_GECKO_PROFILER) && defined(MOZ_PROFILING) && defined(XP_WIN) #define REPORT_CHROME_HANGS #endif @@ -105,25 +102,23 @@ Crash() } #ifdef XP_WIN if (::IsDebuggerPresent()) { return; } #endif -#ifdef MOZ_CRASHREPORTER // If you change this, you must also deal with the threadsafety of AnnotateCrashReport in // non-chrome processes! if (GeckoProcessType_Default == XRE_GetProcessType()) { CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Hang"), NS_LITERAL_CSTRING("1")); CrashReporter::SetMinidumpAnalysisAllThreads(); } -#endif MOZ_CRASH("HangMonitor triggered"); } #ifdef REPORT_CHROME_HANGS static void ChromeStackWalker(uint32_t aFrameNumber, void* aPC, void* aSP, void* aClosure)
--- a/xpcom/threads/nsThread.cpp +++ b/xpcom/threads/nsThread.cpp @@ -33,26 +33,24 @@ #include "mozilla/Services.h" #include "mozilla/SystemGroup.h" #include "nsXPCOMPrivate.h" #include "mozilla/ChaosMode.h" #include "mozilla/Telemetry.h" #include "mozilla/TimeStamp.h" #include "mozilla/Unused.h" #include "mozilla/dom/ScriptSettings.h" +#include "nsICrashReporter.h" #include "nsThreadSyncDispatch.h" +#include "nsServiceManagerUtils.h" #include "GeckoProfiler.h" #include "InputEventStatistics.h" #include "ThreadEventTarget.h" -#ifdef MOZ_CRASHREPORTER -#include "nsServiceManagerUtils.h" -#include "nsICrashReporter.h" #include "mozilla/dom/ContentChild.h" -#endif #ifdef XP_LINUX #include <sys/time.h> #include <sys/resource.h> #include <sched.h> #endif #define HAVE_UALARM _BSD_SOURCE || (_XOPEN_SOURCE >= 500 || \ @@ -471,17 +469,16 @@ nsThread::ThreadFunc(void* aArg) FreeTraceInfo(); #endif NS_RELEASE(self); } //----------------------------------------------------------------------------- -#ifdef MOZ_CRASHREPORTER // Tell the crash reporter to save a memory report if our heuristics determine // that an OOM failure is likely to occur soon. // Memory usage will not be checked more than every 30 seconds or saved more // than every 3 minutes // If |aShouldSave == kForceReport|, a report will be saved regardless of // whether the process is low on memory or not. However, it will still not be // saved if a report was saved less than 3 minutes ago. bool @@ -536,17 +533,16 @@ nsThread::SaveMemoryReportNearOOM(Should nextCheck = now + TimeDuration::FromSeconds(kLowMemorySaveSeconds); } else { recentlySavedReport = false; nextCheck = now + TimeDuration::FromSeconds(kLowMemoryCheckSeconds); } return recentlySavedReport; } -#endif #ifdef MOZ_CANARY int sCanaryOutputFD = -1; #endif nsThread::nsThread(NotNull<SynchronizedEventQueue*> aQueue, MainThreadFlag aMainThread, uint32_t aStackSize) @@ -1202,21 +1198,19 @@ nsThread::DoMainThreadSpecificProcessing mpPending == MemPressure_New ? u"low-memory-no-forward" : u"low-memory-ongoing-no-forward"); } else { NS_WARNING("Can't get observer service!"); } } } -#ifdef MOZ_CRASHREPORTER if (!ShuttingDown()) { SaveMemoryReportNearOOM(ShouldSaveMemoryReport::kMaybeReport); } -#endif } NS_IMETHODIMP nsThread::GetEventTarget(nsIEventTarget** aEventTarget) { nsCOMPtr<nsIEventTarget> target = this; target.forget(aEventTarget); return NS_OK;
--- a/xpcom/threads/nsThread.h +++ b/xpcom/threads/nsThread.h @@ -82,25 +82,23 @@ public: uint32_t RecursionDepth() const; void ShutdownComplete(NotNull<struct nsThreadShutdownContext*> aContext); void WaitForAllAsynchronousShutdowns(); -#ifdef MOZ_CRASHREPORTER enum class ShouldSaveMemoryReport { kMaybeReport, kForceReport }; static bool SaveMemoryReportNearOOM(ShouldSaveMemoryReport aShouldSave); -#endif static const uint32_t kRunnableNameBufSize = 1000; static mozilla::Array<char, kRunnableNameBufSize> sMainThreadRunnableName; void EnableInputEventPrioritization() { EventQueue()->EnableInputEventPrioritization(); }
--- a/xpcom/threads/nsThreadUtils.cpp +++ b/xpcom/threads/nsThreadUtils.cpp @@ -5,38 +5,33 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsThreadUtils.h" #include "mozilla/Attributes.h" #include "mozilla/Likely.h" #include "mozilla/TimeStamp.h" #include "LeakRefPtr.h" #include "nsComponentManagerUtils.h" +#include "nsExceptionHandler.h" #include "nsITimer.h" -#include "nsComponentManagerUtils.h" - #ifdef MOZILLA_INTERNAL_API # include "nsThreadManager.h" #else # include "nsXPCOMCIDInternal.h" # include "nsIThreadManager.h" # include "nsServiceManagerUtils.h" #endif #ifdef XP_WIN #include <windows.h> #elif defined(XP_MACOSX) #include <sys/resource.h> #endif -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif - using namespace mozilla; #ifndef XPCOM_GLUE_AVOID_NSPR NS_IMPL_ISUPPORTS(IdlePeriod, nsIIdlePeriod) NS_IMETHODIMP IdlePeriod::GetIdlePeriodHint(TimeStamp* aIdleDeadline) @@ -512,19 +507,17 @@ NS_ProcessNextEvent(nsIThread* aThread, bool val; return NS_SUCCEEDED(aThread->ProcessNextEvent(aMayWait, &val)) && val; } void NS_SetCurrentThreadName(const char* aName) { PR_SetCurrentThreadName(aName); -#ifdef MOZ_CRASHREPORTER CrashReporter::SetCurrentThreadName(aName); -#endif } #ifdef MOZILLA_INTERNAL_API nsIThread* NS_GetCurrentThread() { return nsThreadManager::get().GetCurrentThread(); }