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-03-02 11:22:05 +00:00
Родитель bbf498d4bf
Коммит a1a07fa35d
2 изменённых файлов: 22 добавлений и 0 удалений

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

@ -235,5 +235,19 @@ 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 `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 mExtraAnnotations[CrashReporter::Annotation::OOMAllocationSize]
.Length() > 0;
}
} // 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