Skip to content

Commit

Permalink
Merge "tp: fix ubsan violation" into main
Browse files Browse the repository at this point in the history
  • Loading branch information
LalitMaganti authored and Gerrit Code Review committed Oct 21, 2024
2 parents f70dfe1 + 24a1c07 commit 4809807
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/trace_processor/importers/common/global_args_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,13 @@ class GlobalArgsTracker {

// Assumes that the interval [begin, end) of |args| has args with the same key
// grouped together.
ArgSetId AddArgSet(const CompactArg* start,
const CompactArg* end,
uint32_t stride) {
ArgSetId AddArgSet(const void* start, const void* end, uint32_t stride) {
base::SmallVector<const CompactArg*, 64> valid;

// TODO(eseckler): Also detect "invalid" key combinations in args sets (e.g.
// "foo" and "foo.bar" in the same arg set)?
for (const auto* ptr = start; ptr != end;
ptr = reinterpret_cast<const CompactArg*>(
reinterpret_cast<const uint8_t*>(ptr) + stride)) {
for (const void* ptr = start; ptr != end;
ptr = reinterpret_cast<const uint8_t*>(ptr) + stride) {
const auto& arg = *reinterpret_cast<const CompactArg*>(ptr);
if (!valid.empty() && valid.back()->key == arg.key) {
// Last arg had the same key as this one. In case of kSkipIfExists, skip
Expand All @@ -138,7 +135,7 @@ class GlobalArgsTracker {
PERFETTO_DCHECK(arg.update_policy == UpdatePolicy::kAddOrUpdate);
valid.pop_back();
}
valid.emplace_back(ptr);
valid.emplace_back(&arg);
}

base::Hasher hash;
Expand Down

0 comments on commit 4809807

Please sign in to comment.