From dfac78ef7c0dfbc6c99c92668658a775d7279698 Mon Sep 17 00:00:00 2001 From: Denis Palmeiro Date: Wed, 8 May 2019 20:49:19 +0000 Subject: [PATCH] bug 1530011: When calculating event durations, if we reach the end of the event list then use the last event as the end event for any events that remain on the stack r=sfink An assert occurs while calculating durations whenever we reach the end of the event list and we didn't encounter the TraceLogger_Stop events for events that were still active when the profiler stopped. The fix is to use the last event as the end event for any remaining events on the stack. Differential Revision: https://phabricator.services.mozilla.com/D29926 --HG-- extra : moz-landing-system : lando --- js/src/vm/TraceLogging.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/js/src/vm/TraceLogging.cpp b/js/src/vm/TraceLogging.cpp index 70040070077a..8c2952cf60fe 100644 --- a/js/src/vm/TraceLogging.cpp +++ b/js/src/vm/TraceLogging.cpp @@ -903,6 +903,24 @@ size_t JS::TraceLoggerDurationImpl::NextChunk(JSContext* cx, size_t* dataIndex, return 0; } } + + // If we reach the end of the list, use the last event as the end + // event for all events remaining on the stack. + if (j == events.size() - 1) { + while (!eventStack.empty()) { + uint32_t prev = eventStack.popCopy(); + double delta = + (events[j].time - events[prev].time).ToMicroseconds(); + if (prev == *dataIndex) { + MOZ_ASSERT(eventStack.empty()); + duration = delta; + } else { + if (!eventMap.putNew(prev, delta)) { + return 0; + } + } + } + } } }