Bug 1466693: Use system malloc in SetOutputFile because jemalloc isn't yet initialized. r=sfink
authorAndré Bargull <andre.bargull@gmail.com>
Mon, 04 Jun 2018 14:56:33 -0700
changeset 421282 6d859a75b7cc5eb7ad31388889d711caaa553cda
parent 421281 e498ba8d51d8d2800cfe8a5656eac3a25384c8db
child 421283 46d845389b970ade7754694a03cb3438e6985faa
push id104021
push userebalazs@mozilla.com
push dateTue, 05 Jun 2018 11:01:08 +0000
treeherdermozilla-inbound@6d859a75b7cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1466693
milestone62.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 1466693: Use system malloc in SetOutputFile because jemalloc isn't yet initialized. r=sfink
js/src/shell/js.cpp
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -8910,30 +8910,36 @@ Shell(JSContext* cx, OptionParser* op, c
      * This printing depends on atoms still existing.
      */
     for (CompartmentsIter c(cx->runtime()); !c.done(); c.next())
         PrintTypes(cx, c, false);
 
     return result;
 }
 
+// Used to allocate memory when jemalloc isn't yet initialized.
+JS_DECLARE_NEW_METHODS(SystemAlloc_New, malloc, static)
+
 static void
 SetOutputFile(const char* const envVar,
               RCFile* defaultOut,
               RCFile** outFileP)
 {
     RCFile* outFile;
 
     const char* outPath = getenv(envVar);
     FILE* newfp;
     if (outPath && *outPath && (newfp = fopen(outPath, "w")))
-        outFile = js_new<RCFile>(newfp);
+        outFile = SystemAlloc_New<RCFile>(newfp);
     else
         outFile = defaultOut;
 
+    if (!outFile)
+        MOZ_CRASH("Failed to allocate output file");
+
     outFile->acquire();
     *outFileP = outFile;
 }
 
 static void
 PreInit()
 {
 #ifdef XP_WIN