Bug 1424709 - Force disable the OSX system "nano allocator". r?spohl draft
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 31 Jan 2018 17:18:01 +0900
changeset 749710 358273c7aefa65d59f4fca11b4df3885a44a7a1b
parent 748652 52194341e14975696365e98511da81bfb278668b
push id97475
push userbmo:mh+mozilla@glandium.org
push dateWed, 31 Jan 2018 21:46:01 +0000
reviewersspohl
bugs1424709
milestone60.0a1
Bug 1424709 - Force disable the OSX system "nano allocator". r?spohl 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/zone.c
--- a/browser/app/macbuild/Contents/Info.plist.in
+++ b/browser/app/macbuild/Contents/Info.plist.in
@@ -220,16 +220,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/zone.c
+++ b/memory/build/zone.c
@@ -415,16 +415,22 @@ register_zone(void)
   // the default zone when it is created for "small" allocations
   // (< 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
     // makes the last registered one the default.  On OSX < 10.6,