[compiler-rt] [scudo] Fix the loading of a signed value to an unsigned storage (PR #111039)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 3 11:33:19 PDT 2024


https://github.com/ChiaHungDuan created https://github.com/llvm/llvm-project/pull/111039

None

>From 73aabe06f83ccf09084d3664629322c39eee523e Mon Sep 17 00:00:00 2001
From: Chia-hung Duan <chiahungduan at google.com>
Date: Thu, 3 Oct 2024 18:29:08 +0000
Subject: [PATCH] [scudo] Fix the loading of a signed value to an unsigned
 storage

---
 compiler-rt/lib/scudo/standalone/primary64.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/compiler-rt/lib/scudo/standalone/primary64.h b/compiler-rt/lib/scudo/standalone/primary64.h
index c02058219b5e13..97188a5ac235cc 100644
--- a/compiler-rt/lib/scudo/standalone/primary64.h
+++ b/compiler-rt/lib/scudo/standalone/primary64.h
@@ -1403,12 +1403,11 @@ template <typename Config> class SizeClassAllocator64 {
       if (RegionPushedBytesDelta < Region->ReleaseInfo.TryReleaseThreshold / 2)
         return false;
 
-      const u64 IntervalNs =
-          static_cast<u64>(atomic_load_relaxed(&ReleaseToOsIntervalMs)) *
-          1000000;
-      if (IntervalNs < 0)
+      const s64 IntervalMs = atomic_load_relaxed(&ReleaseToOsIntervalMs);
+      if (IntervalMs < 0)
         return false;
 
+      const u64 IntervalNs = static_cast<u64>(IntervalMs) * 1000000;
       const u64 CurTimeNs = getMonotonicTimeFast();
       const u64 DiffSinceLastReleaseNs =
           CurTimeNs - Region->ReleaseInfo.LastReleaseAtNs;



More information about the llvm-commits mailing list