Commit 3ba39507 authored by Eric Seckler's avatar Eric Seckler Committed by Commit Bot

perfetto: Attempt to address crashes in TETLES::UpdateDuration

We're seeing crashes within AddTraceEvent called from UpdateDuration
when attempting to access the trace event's category pointer. The
category pointer is nullptr in this case, which leads me to believe
that UpdateDuration may attempt to access an uninitialized TraceEvent
from the complete_event_stack_.

One piece of code that looks suspicious to me is the update of
current_stack_depth_ in UpdateDuration in case the handle's
event_index and current_stack_depth_ mismatch for some reason.

Provided the DCHECK holds, it still shouldn't cause an invalid
TraceEvent to be accessed in later invocations of UpdateDuration, but
this is an attempt to make the update a little safer nevertheless.

Bug: 983307
Change-Id: I6c6e4dc02bdde5e5e324c65ffb6e5cfe1028c6dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1741919
Auto-Submit: Eric Seckler <eseckler@chromium.org>
Reviewed-by: default avatarSami Kyöstilä <skyostil@chromium.org>
Commit-Queue: Eric Seckler <eseckler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685526}
parent 38d036fa
......@@ -4,6 +4,8 @@
#include "services/tracing/public/cpp/perfetto/track_event_thread_local_event_sink.h"
#include <algorithm>
#include "base/stl_util.h"
#include "base/strings/pattern.h"
#include "base/strings/strcat.h"
......@@ -580,7 +582,8 @@ void TrackEventThreadLocalEventSink::UpdateDuration(
DCHECK(handle.event_index > 0 &&
handle.event_index < current_stack_depth_ &&
!base::trace_event::TraceLog::GetInstance()->IsEnabled());
current_stack_depth_ = handle.event_index - 1;
current_stack_depth_ = std::min(
current_stack_depth_, static_cast<uint32_t>(handle.event_index - 1));
return;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment