[compiler-rt] 0d45bbc - [scudo] Skip releaseToOSMaybe if there's no byte in freelist
Chia-hung Duan via llvm-commits
llvm-commits at lists.llvm.org
Wed May 10 13:20:55 PDT 2023
Author: Chia-hung Duan
Date: 2023-05-10T20:20:17Z
New Revision: 0d45bbcb6007f5c345bacd30f94d61f6d9dfebb2
URL: https://github.com/llvm/llvm-project/commit/0d45bbcb6007f5c345bacd30f94d61f6d9dfebb2
DIFF: https://github.com/llvm/llvm-project/commit/0d45bbcb6007f5c345bacd30f94d61f6d9dfebb2.diff
LOG: [scudo] Skip releaseToOSMaybe if there's no byte in freelist
In primary32, the unused region will have max/min region index with 0
value and it's an invalid index. Skip releaseToOSMaybe in both primary32
and primary64 even it's M_PURGE_ALL.
Differential Revision: https://reviews.llvm.org/D150243
Added:
Modified:
compiler-rt/lib/scudo/standalone/primary32.h
compiler-rt/lib/scudo/standalone/primary64.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/scudo/standalone/primary32.h b/compiler-rt/lib/scudo/standalone/primary32.h
index 7ac8df9dd95e4..726db754f245e 100644
--- a/compiler-rt/lib/scudo/standalone/primary32.h
+++ b/compiler-rt/lib/scudo/standalone/primary32.h
@@ -737,6 +737,9 @@ template <typename Config> class SizeClassAllocator32 {
Sci->AllocatedUser -
(Sci->Stats.PoppedBlocks - Sci->Stats.PushedBlocks) * BlockSize;
+ if (UNLIKELY(BytesInFreeList == 0))
+ return 0;
+
bool MaySkip = false;
if (BytesInFreeList <= Sci->ReleaseInfo.BytesInFreeListAtLastCheckpoint) {
diff --git a/compiler-rt/lib/scudo/standalone/primary64.h b/compiler-rt/lib/scudo/standalone/primary64.h
index b954b7c0bf2ae..39248376eaac7 100644
--- a/compiler-rt/lib/scudo/standalone/primary64.h
+++ b/compiler-rt/lib/scudo/standalone/primary64.h
@@ -845,6 +845,9 @@ template <typename Config> class SizeClassAllocator64 {
Region->AllocatedUser -
(Region->Stats.PoppedBlocks - Region->Stats.PushedBlocks) * BlockSize;
+ if (UNLIKELY(BytesInFreeList == 0))
+ return 0;
+
bool MaySkip = false;
// Always update `BytesInFreeListAtLastCheckpoint` with the smallest value
More information about the llvm-commits
mailing list