Bug 1449084 - Early-exit in profiler_add_marker_for_thread if the profiler is not running. r?mystor draft
authorMarkus Stange <mstange@themasta.com>
Mon, 26 Mar 2018 23:01:54 -0400
changeset 781245 a3912da749bef7df1ff48e281a183135783bbc70
parent 781042 ee1d1bf1dc8a83eec16967ddb61dd5024c8d6058
child 781246 851079810914040fd0673646e55b3441e1ee21c4
push id106255
push userbmo:mstange@themasta.com
push dateThu, 12 Apr 2018 19:45:02 +0000
reviewersmystor
bugs1449084
milestone61.0a1
Bug 1449084 - Early-exit in profiler_add_marker_for_thread if the profiler is not running. r?mystor MozReview-Commit-ID: Kiqur4ZJobi
tools/profiler/core/platform.cpp
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -3340,27 +3340,30 @@ profiler_add_marker(const char* aMarkerN
 // to lock here.
 void
 profiler_add_marker_for_thread(int aThreadId,
                                const char* aMarkerName,
                                UniquePtr<ProfilerMarkerPayload> aPayload)
 {
   MOZ_RELEASE_ASSERT(CorePS::Exists());
 
+  PSAutoLock lock(gPSMutex);
+  if (!ActivePS::Exists(lock)) {
+    return;
+  }
+
   // Create the ProfilerMarker which we're going to store.
   TimeStamp origin = (aPayload && !aPayload->GetStartTime().IsNull())
                    ? aPayload->GetStartTime()
                    : TimeStamp::Now();
   TimeDuration delta = origin - CorePS::ProcessStartTime();
   ProfilerMarker* marker =
     new ProfilerMarker(aMarkerName, aThreadId, Move(aPayload),
                        delta.ToMilliseconds());
 
-  PSAutoLock lock(gPSMutex);
-
 #ifdef DEBUG
   // Assert that our thread ID makes sense
   bool realThread = false;
   const nsTArray<UniquePtr<RegisteredThread>>& registeredThreads =
     CorePS::RegisteredThreads(lock);
   for (auto& thread : registeredThreads) {
     RefPtr<ThreadInfo> info = thread->Info();
     if (info->ThreadId() == aThreadId) {