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

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 23 18:11:42 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

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

Author: None (ChiaHungDuan)

<details>
<summary>Changes</summary>

`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()

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


1 Files Affected:

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


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

``````````

</details>


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


More information about the llvm-commits mailing list