Bug 1539133 - Explicitly say not being able to mmap is likely OOM. r=decoder,glandium
authorGian-Carlo Pascutto <gcp@mozilla.com>
Tue, 12 Nov 2019 00:04:46 +0000
changeset 501754 d65ec56af99764c4370edc565668ce1ec638ee01
parent 501753 b582b54b01d487a85940142585615937b7c5fbda
child 501755 5d93cdf79d2796c10ea902470cab90b9f903b159
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdecoder, glandium
bugs1539133
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1539133 - Explicitly say not being able to mmap is likely OOM. r=decoder,glandium Differential Revision: https://phabricator.services.mozilla.com/D43929
memory/build/mozjemalloc.cpp
--- a/memory/build/mozjemalloc.cpp
+++ b/memory/build/mozjemalloc.cpp
@@ -1289,17 +1289,29 @@ static inline void pages_decommit(void* 
     }
     aAddr = (void*)((uintptr_t)aAddr + pages_size);
     aSize -= pages_size;
     pages_size = std::min(aSize, kChunkSize);
   }
 #else
   if (mmap(aAddr, aSize, PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1,
            0) == MAP_FAILED) {
-    MOZ_CRASH();
+    // We'd like to report the OOM for our tooling, but we can't allocate
+    // memory at this point, so avoid the use of printf.
+    const char out_of_mappings[] =
+        "[unhandlable oom] Failed to mmap, likely no more mappings "
+        "available " __FILE__ " : " MOZ_STRINGIFY(__LINE__);
+    if (errno == ENOMEM) {
+#ifndef ANDROID
+      fputs(out_of_mappings, stderr);
+      fflush(stderr);
+#endif
+      MOZ_CRASH_ANNOTATE(out_of_mappings);
+    }
+    MOZ_REALLY_CRASH(__LINE__);
   }
   MozTagAnonymousMemory(aAddr, aSize, "jemalloc-decommitted");
 #endif
 }
 
 // Commit pages. Returns whether pages were committed.
 MOZ_MUST_USE static inline bool pages_commit(void* aAddr, size_t aSize) {
 #ifdef XP_WIN