[compiler-rt] c7f4b3e - [scudo] Fix the misused Exhausted in region allocation (#89852)

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 25 19:40:43 PDT 2024


Author: ChiaHungDuan
Date: 2024-04-25T19:40:40-07:00
New Revision: c7f4b3e1bd5cab43d6f733a5107b2946c76bc0bb

URL: https://github.com/llvm/llvm-project/commit/c7f4b3e1bd5cab43d6f733a5107b2946c76bc0bb
DIFF: https://github.com/llvm/llvm-project/commit/c7f4b3e1bd5cab43d6f733a5107b2946c76bc0bb.diff

LOG: [scudo] Fix the misused Exhausted in region allocation (#89852)

`Region->Exhausted` indicates that we don't have more pages to create
new blocks in the region. It has different meaning from region
allocation failure.

Also fix a minor lint in popBlocks()

Added: 
    

Modified: 
    compiler-rt/lib/scudo/standalone/primary64.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/scudo/standalone/primary64.h b/compiler-rt/lib/scudo/standalone/primary64.h
index 61d57976ae43b6..d6119051b1622f 100644
--- a/compiler-rt/lib/scudo/standalone/primary64.h
+++ b/compiler-rt/lib/scudo/standalone/primary64.h
@@ -884,9 +884,10 @@ template <typename Config> class SizeClassAllocator64 {
         ScopedLock ML(Region->MMLock);
 
         const bool RegionIsExhausted = Region->Exhausted;
-        if (!RegionIsExhausted)
+        if (!RegionIsExhausted) {
           PopCount = populateFreeListAndPopBlocks(C, ClassId, Region, ToArray,
                                                   MaxBlockCount);
+        }
         ReportRegionExhausted = !RegionIsExhausted && Region->Exhausted;
 
         {
@@ -1019,7 +1020,6 @@ template <typename Config> class SizeClassAllocator64 {
                                           MAP_ALLOWNOMEM))) {
         Printf("Can't reserve pages for size class %zu.\n",
                getSizeByClassId(ClassId));
-        Region->Exhausted = true;
         return 0U;
       }
       initRegion(Region, ClassId,


        


More information about the llvm-commits mailing list