Bug 696281 - disable trace malloc stacks on OS X too. r=dbaron.
authorRafael Ávila de Espíndola <respindola@mozilla.com>
Fri, 28 Oct 2011 18:43:49 -0400
changeset 80733 93e293c8758056784d259e651f7128d8d796cc24
parent 80732 a92ec8fb2ab8f31c5c418325c88eea5eeb1afa4d
child 80734 97a7011b26702576c2e5ee16066f32ceb174e417
push id434
push userclegnitto@mozilla.com
push dateWed, 21 Dec 2011 12:10:54 +0000
treeherdermozilla-beta@bddb6ed8dd47 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs696281
milestone10.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 696281 - disable trace malloc stacks on OS X too. r=dbaron. This patch disables trace malloc stacks on OS X too. To make this work, we still have to look on the stack to decide if we must set immediate_abort, but we can avoid other work like decoding the addresses.
build/automation.py.in
testing/xpcshell/runxpcshelltests.py
tools/trace-malloc/lib/nsTraceMalloc.c
--- a/build/automation.py.in
+++ b/build/automation.py.in
@@ -649,22 +649,17 @@ user_pref("camino.use_system_proxy_setti
     if crashreporter:
       env['MOZ_CRASHREPORTER_NO_REPORT'] = '1'
       env['MOZ_CRASHREPORTER'] = '1'
     else:
       env['MOZ_CRASHREPORTER_DISABLE'] = '1'
 
     env['GNOME_DISABLE_CRASH_DIALOG'] = '1'
     env['XRE_NO_WINDOWS_CRASH_DIALOG'] = '1'
-
-    # Don't do this for Mac since it makes the Mac OS X 10.5 (32-bit)
-    # trace-malloc leak test hang.  (It doesn't make the 10.6 (64-bit)
-    # leak test hang, though.)
-    if not self.IS_MAC:
-      env['NS_TRACE_MALLOC_DISABLE_STACKS'] = '1'
+    env['NS_TRACE_MALLOC_DISABLE_STACKS'] = '1'
     return env
 
   if IS_WIN32:
     PeekNamedPipe = ctypes.windll.kernel32.PeekNamedPipe
     GetLastError = ctypes.windll.kernel32.GetLastError
 
     def readWithTimeout(self, f, timeout):
       """Try to read a line of output from the file object |f|.
--- a/testing/xpcshell/runxpcshelltests.py
+++ b/testing/xpcshell/runxpcshelltests.py
@@ -157,20 +157,17 @@ class XPCShellTests(object):
     """
     self.env = dict(os.environ)
     # Make assertions fatal
     self.env["XPCOM_DEBUG_BREAK"] = "stack-and-abort"
     # Don't launch the crash reporter client
     self.env["MOZ_CRASHREPORTER_NO_REPORT"] = "1"
     # Capturing backtraces is very slow on some platforms, and it's
     # disabled by automation.py too
-    if not (sys.platform == 'osx' or sys.platform == "darwin"):
-      # XXX automation.py has this odd special case; without it, bug
-      # 618052 seems to be exacerbated
-      self.env["NS_TRACE_MALLOC_DISABLE_STACKS"] = "1"
+    self.env["NS_TRACE_MALLOC_DISABLE_STACKS"] = "1"
 
     if sys.platform == 'win32':
       self.env["PATH"] = self.env["PATH"] + ";" + self.xrePath
     elif sys.platform in ('os2emx', 'os2knix'):
       os.environ["BEGINLIBPATH"] = self.xrePath + ";" + self.env["BEGINLIBPATH"]
       os.environ["LIBPATHSTRICT"] = "T"
     elif sys.platform == 'osx' or sys.platform == "darwin":
       self.env["DYLD_LIBRARY_PATH"] = self.xrePath
--- a/tools/trace-malloc/lib/nsTraceMalloc.c
+++ b/tools/trace-malloc/lib/nsTraceMalloc.c
@@ -952,16 +952,28 @@ backtrace(tm_thread *t, int skip, int *i
     stack_buffer_info *info = &t->backtrace_buf;
     void ** new_stack_buffer;
     size_t new_stack_buffer_size;
     nsresult rv;
 
     t->suppress_tracing++;
 
     if (!stacks_enabled) {
+#if defined(XP_MACOSX)
+        /* Walk the stack, even if stacks_enabled is false. We do this to
+           check if we must set immediate_abort. */
+        info->entries = 0;
+        rv = NS_StackWalk(stack_callback, skip, info);
+        *immediate_abort = rv == NS_ERROR_UNEXPECTED;
+        if (rv == NS_ERROR_UNEXPECTED || info->entries == 0) {
+            t->suppress_tracing--;
+            return NULL;
+        }
+#endif
+
         /*
          * Create a single fake stack frame so that all the tools get
          * data in the correct format.
          */
         *immediate_abort = 0;
         if (info->size < 1) {
             PR_ASSERT(!info->buffer); /* !info->size == !info->buffer */
             info->buffer = __libc_malloc(1 * sizeof(void*));