Bug 737959 - Fix the startup crash with MallocStackLogging; r=bsmedberg
authorEhsan Akhgari <ehsan.akhgari@gmail.com>
Thu, 22 Mar 2012 13:18:36 -0400
changeset 93363 e8d4d50cee766ca472c693b46edfe5336e5e8eea
parent 93362 7839dd4bcdb5f1433ece55a70278f9d3e377cad4
child 93364 149297a4bbc25c01efc0a8fa957e9403dcc8d15b
push idunknown
push userunknown
push dateunknown
reviewersbsmedberg
bugs737959
milestone14.0a1
Bug 737959 - Fix the startup crash with MallocStackLogging; r=bsmedberg
xpcom/base/nsStackWalk.cpp
--- a/xpcom/base/nsStackWalk.cpp
+++ b/xpcom/base/nsStackWalk.cpp
@@ -146,30 +146,30 @@ 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.
 
-  MOZ_ASSERT(malloc_logger == NULL);
+  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);
-  malloc_logger = NULL;
+  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);
   MOZ_ASSERT(r == 0);