Bug 1453003 - Ignore calls to profiler_unregister_thread() that happen after the main thread has shut down. r?njn draft
authorMarkus Stange <mstange@themasta.com>
Thu, 12 Apr 2018 22:41:03 -0400
changeset 781527 d875e47cf011c3819a2cbbcdfb38ad5e2277ac0b
parent 781526 9abc1b4552fd459e8b3b809e82cf492ca41798fb
push id106325
push userbmo:mstange@themasta.com
push dateFri, 13 Apr 2018 02:41:47 +0000
reviewersnjn
bugs1453003
milestone61.0a1
Bug 1453003 - Ignore calls to profiler_unregister_thread() that happen after the main thread has shut down. r?njn MozReview-Commit-ID: 1PmoQe5BbPZ
tools/profiler/core/platform.cpp
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -3147,17 +3147,21 @@ profiler_register_thread(const char* aNa
   void* stackTop = GetStackTop(aGuessStackTop);
   locked_register_thread(lock, aName, stackTop);
 }
 
 void
 profiler_unregister_thread()
 {
   MOZ_ASSERT_IF(NS_IsMainThread(), Scheduler::IsCooperativeThread());
-  MOZ_RELEASE_ASSERT(CorePS::Exists());
+
+  if (!CorePS::Exists()) {
+    // This function can be called after the main thread has already shut down.
+    return;
+  }
 
   PSAutoLock lock(gPSMutex);
 
   // We don't call RegisteredThread::StopJSSampling() here; there's no point
   // doing that for a JS thread that is in the process of disappearing.
 
   RegisteredThread* registeredThread = FindCurrentThreadRegisteredThread(lock);
   MOZ_RELEASE_ASSERT(registeredThread == TLSRegisteredThread::RegisteredThread(lock));