summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChia-hung Duan <chiahungduan@google.com>2023-05-10 02:40:48 +0000
committerChia-hung Duan <chiahungduan@google.com>2023-05-11 22:52:29 +0000
commit6c1aab9e382bfe5a8402f23f7d069f87a3945690 (patch)
tree09c3c6b2758a55c55b6e714845aefc262605a061
parentfffce1a6d019877207986f527f63b5156cefbb06 (diff)
downloadscudo-6c1aab9e382bfe5a8402f23f7d069f87a3945690.tar.gz
[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 Bug: 281770880 GitOrigin-RevId: 0d45bbcb6007f5c345bacd30f94d61f6d9dfebb2 Change-Id: I30c38113b2962ad1e8fced524b63befc5ea8ae4f Merged-In: I30c38113b2962ad1e8fced524b63befc5ea8ae4f (cherry picked from commit fba440e260ad35005f853ebb35081b2a76acc997)
-rw-r--r--standalone/primary32.h3
-rw-r--r--standalone/primary64.h3
2 files changed, 6 insertions, 0 deletions
diff --git a/standalone/primary32.h b/standalone/primary32.h
index 7ac8df9dd95..726db754f24 100644
--- a/standalone/primary32.h
+++ b/standalone/primary32.h
@@ -737,6 +737,9 @@ private:
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/standalone/primary64.h b/standalone/primary64.h
index b954b7c0bf2..39248376eaa 100644
--- a/standalone/primary64.h
+++ b/standalone/primary64.h
@@ -845,6 +845,9 @@ private:
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