Bug 946817 - Don't assert mPseudoStack on B2G. r=BenWa
authorJim Chen <nchen@mozilla.com>
Fri, 06 Dec 2013 09:50:21 -0500
changeset 174889 1be0c6a852039d96472cfd4f6cc67c5c350253d6
parent 174888 e10be8b045441c11b9e754eb4d9d5b297e177c5a
child 174890 52ef0645705fd7d20d3807bea3a987e419892520
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBenWa
bugs946817
milestone28.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 946817 - Don't assert mPseudoStack on B2G. r=BenWa
xpcom/threads/ThreadStackHelper.cpp
--- a/xpcom/threads/ThreadStackHelper.cpp
+++ b/xpcom/threads/ThreadStackHelper.cpp
@@ -79,17 +79,17 @@ ThreadStackHelper::~ThreadStackHelper()
 #endif
 }
 
 void
 ThreadStackHelper::GetStack(Stack& aStack)
 {
   // Always run PrepareStackBuffer first to clear aStack
   if (!PrepareStackBuffer(aStack)) {
-    MOZ_ASSERT(false);
+    // Skip and return empty aStack
     return;
   }
 
 #if defined(XP_LINUX)
   if (!sInitialized) {
     MOZ_ASSERT(false);
     return;
   }
@@ -144,23 +144,33 @@ ThreadStackHelper::SigAction(int aSignal
   sCurrent = nullptr;
   ::sem_post(&sSem);
 }
 
 #endif // XP_LINUX
 
 bool
 ThreadStackHelper::PrepareStackBuffer(Stack& aStack) {
+  // Return false to skip getting the stack and return an empty stack
   aStack.clear();
 #ifdef MOZ_ENABLE_PROFILER_SPS
+  /* Normally, provided the profiler is enabled, it would be an error if we
+     don't have a pseudostack here (the thread probably forgot to call
+     profiler_register_thread). However, on B2G, profiling secondary threads
+     may be disabled despite profiler being enabled. This is by-design and
+     is not an error. */
+#ifdef MOZ_WIDGET_GONK
   if (!mPseudoStack) {
     return false;
   }
+#endif
+  MOZ_ASSERT(mPseudoStack);
   mStackBuffer.clear();
-  return mStackBuffer.reserve(mMaxStackSize);
+  MOZ_ALWAYS_TRUE(mStackBuffer.reserve(mMaxStackSize));
+  return true;
 #else
   return false;
 #endif
 }
 
 void
 ThreadStackHelper::FillStackBuffer() {
 #ifdef MOZ_ENABLE_PROFILER_SPS