Bug 1453003 - Ignore calls to profiler_unregister_thread() that happen after the main thread has shut down. r?njn
MozReview-Commit-ID: 1PmoQe5BbPZ
--- 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));