From 76ae51adfd11878f1555277e539cc51a7f1833c4 Mon Sep 17 00:00:00 2001 From: Gavin Halliday Date: Fri, 18 Oct 2024 11:04:59 +0100 Subject: [PATCH] HPCC-32826 Avoid integer underflow when calculating elapsed cycles Signed-off-by: Gavin Halliday --- system/include/platform.h | 2 +- system/jlib/jdebug.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/system/include/platform.h b/system/include/platform.h index 2421016a4b1..c72aefb4360 100644 --- a/system/include/platform.h +++ b/system/include/platform.h @@ -492,7 +492,7 @@ typedef unsigned __int64 hash64_t; typedef unsigned __int64 __uint64; typedef __uint64 offset_t; typedef unsigned char byte; -typedef __int64 cycle_t; +typedef __uint64 cycle_t; // This must be unsigned to avoid integer overflow issues when subtracting typedef unsigned __int64 timestamp_type; // BUILD_TAG not needed here anymore - defined in build_tag.h diff --git a/system/jlib/jdebug.cpp b/system/jlib/jdebug.cpp index 5fa81ba1b96..8a4d795c7b5 100644 --- a/system/jlib/jdebug.cpp +++ b/system/jlib/jdebug.cpp @@ -483,8 +483,8 @@ class TimeSectionInfo : public MappingBase unsigned getCount() const { return count; } StringAttr scope; - __int64 totalcycles; - __int64 maxcycles; + cycle_t totalcycles; + cycle_t maxcycles; unsigned count; };