Bug 1373281 - Null-check mStackToFill before collecting psuedostacks, r=froydnj
authorMichael Layzell <michael@thelayzells.com>
Thu, 15 Jun 2017 11:58:22 -0400
changeset 412991 c83344a415617b997c07104a92f085f476d974b7
parent 412990 f6b101870099486db6ed20f76db31996ea87b4b9
child 412992 12caabbf2ba860021b1879c5cc9e7ce521aa373e
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1373281
milestone56.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 1373281 - Null-check mStackToFill before collecting psuedostacks, r=froydnj This was causing a crash on nightly. The browser would try to collect only a native stack, and then attempt to dereference the null pointer for the pseudostack. I think this didn't happen on infra as it only occurs when the user has hung a sufficient number of times. MozReview-Commit-ID: 6RSW2llKBjT
xpcom/threads/ThreadStackHelper.cpp
--- a/xpcom/threads/ThreadStackHelper.cpp
+++ b/xpcom/threads/ThreadStackHelper.cpp
@@ -127,31 +127,37 @@ ThreadStackHelper::GetStacksInternal(Sta
 #ifdef MOZ_THREADSTACKHELPER_PSEUDO
   ScopedSetPtr<Stack> stackPtr(mStackToFill, aStack);
 #endif
 #ifdef MOZ_THREADSTACKHELPER_NATIVE
   ScopedSetPtr<NativeStack> nativeStackPtr(mNativeStackToFill, aNativeStack);
 #endif
 
   auto callback = [&, this] (void** aPCs, size_t aCount) {
-    FillStackBuffer();
+#ifdef MOZ_THREADSTACKHELPER_PSEUDO
+    if (mStackToFill) {
+      FillStackBuffer();
+    }
+#endif
 
 #ifdef MOZ_THREADSTACKHELPER_NATIVE
     if (mNativeStackToFill) {
       while (aCount-- &&
              mNativeStackToFill->size() < mNativeStackToFill->capacity()) {
         mNativeStackToFill->push_back(reinterpret_cast<uintptr_t>(aPCs[aCount]));
       }
     }
 #endif
   };
 
-  profiler_suspend_and_sample_thread(mThreadId,
-                                     callback,
-                                     /* aSampleNative = */ !!aNativeStack);
+  if (mStackToFill || mNativeStackToFill) {
+    profiler_suspend_and_sample_thread(mThreadId,
+                                       callback,
+                                       /* aSampleNative = */ !!aNativeStack);
+  }
 #endif
 }
 
 bool
 ThreadStackHelper::PrepareStackBuffer(Stack& aStack)
 {
   // Return false to skip getting the stack and return an empty stack
   aStack.clear();