[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:58 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: None (ChiaHungDuan)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/111039.diff


1 Files Affected:

- (modified) compiler-rt/lib/scudo/standalone/primary64.h (+3-4) 


``````````diff
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;

``````````

</details>


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


More information about the llvm-commits mailing list