From 0246f46386bc6a106bcd67ae8afe650b0d4c1d6d Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Mon, 20 Jan 2025 21:03:49 +0100 Subject: [PATCH] deps: timeDeltas in cpu profiles are signed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some cases, they can take a negative value (don't really know why because supposedly v8 uses a monotonic clock). We don't want to cast them to unsigned to avoid overflows. PR-URL: https://github.com/nodesource/nsolid/pull/254 Reviewed-By: Juan José Arboleda --- deps/v8/src/profiler/profile-generator.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/deps/v8/src/profiler/profile-generator.cc b/deps/v8/src/profiler/profile-generator.cc index 59c11b2649..6937534dae 100644 --- a/deps/v8/src/profiler/profile-generator.cc +++ b/deps/v8/src/profiler/profile-generator.cc @@ -885,8 +885,9 @@ void CpuProfileJSONSerializer::SerializeTimeDeltas() { int count = profile_->samples_count(); base::TimeTicks lastTimestamp = profile_->start_time(); for (int i = 0; i < count; i++) { - writer_->AddNumber(static_cast( - (profile_->sample(i).timestamp - lastTimestamp).InMicroseconds())); + int delta = static_cast( + (profile_->sample(i).timestamp - lastTimestamp).InMicroseconds()); + writer_->AddString(std::to_string(delta).c_str()); if (i != (count - 1)) writer_->AddString(","); lastTimestamp = profile_->sample(i).timestamp; }