Bug 1424709 - Force disable the OSX system "nano allocator". r=spohl, a=RyanVM
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 31 Jan 2018 17:18:01 +0900
changeset 356857 e2d56c22cd3ac481013c858393826866b00a1912
parent 356856 613330624c46b9bda222fb02f6742cee4b4ebf18
child 356858 54f2f7f93b30b9f59607d2c0ae1fe7a1bad80229
push id7552
push userryanvm@gmail.com
push dateTue, 20 Feb 2018 21:20:17 +0000
treeherdermozilla-esr52@8a4265c8fb41 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl, RyanVM
bugs1424709
milestone52.6.1
Bug 1424709 - Force disable the OSX system "nano allocator". r=spohl, a=RyanVM We're not actually using it, and it messes up with the zone allocator in mozjemalloc after fork(). See the lengthy analysis in https://bugzilla.mozilla.org/show_bug.cgi?id=1424709#c34 and following.
browser/app/macbuild/Contents/Info.plist.in
memory/build/replace_malloc.c
--- a/browser/app/macbuild/Contents/Info.plist.in
+++ b/browser/app/macbuild/Contents/Info.plist.in
@@ -200,16 +200,21 @@
 		</dict>
 	</array>
 	<key>CFBundleVersion</key>
 	<string>%MAC_BUNDLE_VERSION%</string>
 	<key>NSAppleScriptEnabled</key>
 	<true/>
 	<key>LSApplicationCategoryType</key>
 	<string>public.app-category.productivity</string>
+	<key>LSEnvironment</key>
+	<dict>
+		<key>MallocNanoZone</key>
+		<string>0</string>
+	</dict>
 	<key>LSFileQuarantineEnabled</key>
 	<true/>
 	<key>LSMinimumSystemVersion</key>
 	<string>10.9.0</string>
   <key>NSSupportsAutomaticGraphicsSwitching</key>
   <true/>
   <key>NSPrincipalClass</key>
   <string>GeckoNSApplication</string>
--- a/memory/build/replace_malloc.c
+++ b/memory/build/replace_malloc.c
@@ -508,16 +508,22 @@ register_zone(void)
    * (< 15 KiB), but assumes the default zone is a scalable_zone.  This
    * obviously fails when the default zone is the jemalloc zone, so
    * malloc_default_purgeable_zone is called beforehand so that the
    * default purgeable zone is created when the default zone is still
    * a scalable_zone.
    */
   malloc_zone_t *purgeable_zone = malloc_default_purgeable_zone();
 
+  // There is a problem related to the above with the system nano zone, which
+  // is hard to work around from here, and that is instead worked around by
+  // disabling the nano zone through an environment variable
+  // (MallocNanoZone=0). In Firefox, we do that through
+  // browser/app/macbuild/Contents/Info.plist.in.
+
   /* Register the custom zone.  At this point it won't be the default. */
   malloc_zone_register(&zone);
 
   do {
     /*
      * Unregister and reregister the default zone.  On OSX >= 10.6,
      * unregistering takes the last registered zone and places it at the
      * location of the specified zone.  Unregistering the default zone thus