Bug 719427. Add a comment about malloc_logger. r=espindola
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Tue, 27 Mar 2012 13:48:58 -0400
changeset 93746 fbe032073e04874ef540a5012e7fb853e8bee309
parent 93745 752737597c228b8185517bf029fe1cea77e574c3
child 93747 f6b7b4b9f235b18ec544d7477f3fc563fd180dcf
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersespindola
bugs719427
milestone14.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 719427. Add a comment about malloc_logger. r=espindola
xpcom/base/nsStackWalk.cpp
--- a/xpcom/base/nsStackWalk.cpp
+++ b/xpcom/base/nsStackWalk.cpp
@@ -146,29 +146,32 @@ StackWalkInitCriticalAddress()
     return;
   gCriticalAddress.mInit = true;
   // We must not do work when 'new_sem_from_pool' calls realloc, since
   // it holds a non-reentrant spin-lock and we will quickly deadlock.
   // new_sem_from_pool is not directly accessible using dlsym, so
   // we force a situation where new_sem_from_pool is on the stack and
   // use dladdr to check the addresses.
 
+  // malloc_logger can be set by external tools like 'Instruments' or 'leaks'
   malloc_logger_t *old_malloc_logger = malloc_logger;
   malloc_logger = my_malloc_logger;
 
   pthread_cond_t cond;
   int r = pthread_cond_init(&cond, 0);
   MOZ_ASSERT(r == 0);
   pthread_mutex_t mutex;
   r = pthread_mutex_init(&mutex,0);
   MOZ_ASSERT(r == 0);
   r = pthread_mutex_lock(&mutex);
   MOZ_ASSERT(r == 0);
   struct timespec abstime = {0, 1};
   r = pthread_cond_timedwait_relative_np(&cond, &mutex, &abstime);
+
+  // restore the previous malloc logger
   malloc_logger = old_malloc_logger;
 
   // On Lion, malloc is no longer called from pthread_cond_*wait*. This prevents
   // us from finding the address, but that is fine, since with no call to malloc
   // there is no critical address.
   MOZ_ASSERT(OnLionOrLater() || gCriticalAddress.mAddr != NULL);
   MOZ_ASSERT(r == ETIMEDOUT);
   r = pthread_mutex_unlock(&mutex);