Bug 1589493 - Expose CrashReporterHost::isLikelyOOM();r=gsvelto

We'll use this method to expose additional information to the front-end for recovering from OOM.

Differential Revision: https://phabricator.services.mozilla.com/D54129

--HG--
extra : moz-landing-system : lando
This commit is contained in:
David Teller 2020-02-25 18:16:33 +00:00
Родитель d670a75ef4
Коммит c15218401c
2 изменённых файлов: 25 добавлений и 0 удалений

Просмотреть файл

@ -8,6 +8,7 @@
#include "CrashReporterMetadataShmem.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/recordreplay/ParentIPC.h"
#include "mozilla/EnumeratedRange.h"
#include "mozilla/Sprintf.h"
#include "mozilla/SyncRunnable.h"
#include "mozilla/Telemetry.h"
@ -241,5 +242,21 @@ void CrashReporterHost::AddAnnotation(CrashReporter::Annotation aKey,
mExtraAnnotations[aKey] = aValue;
}
bool CrashReporterHost::IsLikelyOOM() {
// The data is only populated during the call to `FinalizeCrashReport()`.
MOZ_ASSERT(mFinalized);
if (mExtraAnnotations[CrashReporter::Annotation::OOMAllocationSize].Length() >
0) {
// If `OOMAllocationSize` was set, we know that the crash happened
// because an allocation failed (`malloc` returned `nullptr`).
//
// As Unix systems generally allow `malloc` to return a non-null value
// even when no virtual memory is available, this doesn't cover all
// cases of OOM under Unix (far from it).
return true;
}
return false;
}
} // namespace ipc
} // namespace mozilla

Просмотреть файл

@ -94,6 +94,14 @@ class CrashReporterHost {
return mExtraAnnotations[CrashReporter::Annotation::additional_minidumps];
}
// Return `true` if this crash reporter has been identified as a likely OOM.
//
// At the time of this writing, OOMs detection is considered reliable under
// Windows but other platforms quite often return false negatives.
//
// `CrashReporterHost::FinalizeCrashReport()` MUST have been called already.
bool IsLikelyOOM();
// This is a static helper function to notify the crash service that a
// crash has occurred and record the crash with telemetry. This can be called
// from any thread, and if not called from the main thread, will post a