Skip to content

[scudo] Fix the misused Exhausted in region allocation #89852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2024

Conversation

ChiaHungDuan
Copy link
Contributor

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

`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()
@llvmbot
Copy link
Member

llvmbot commented Apr 24, 2024

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

Author: None (ChiaHungDuan)

Changes

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

@ChiaHungDuan ChiaHungDuan requested a review from fabio-d April 24, 2024 01:11
Copy link
Contributor

@cferris1000 cferris1000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Contributor

@fabio-d fabio-d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ChiaHungDuan ChiaHungDuan merged commit c7f4b3e into llvm:main Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants