[compiler-rt] [scudo] Add config option to modify get usable size behavior (PR #158710)

via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 8 16:04:42 PDT 2025


================
@@ -57,6 +57,10 @@ BASE_OPTIONAL(const bool, MaySupportMemoryTagging, false)
 // Disable the quarantine code.
 BASE_OPTIONAL(const bool, QuarantineDisabled, false)
 
+// If set to true, malloc_usable_size returns the exact size of the allocation.
+// If set to false, return the total available size in the allocation.
+BASE_OPTIONAL(const bool, ExactUsableSize, true)
----------------
ChiaHungDuan wrote:

Maybe I miss something. I mean something like
```
      if (UNLIKELY(useMemoryTagging<AllocatorConfig>(Primary.Options.load()))) {
        TaggedChunk = loadTag(Chunk);
        Size = getSize(reinterpret_cast<void *>(Chunk), &Header);
      } else {
        Size = getUsableSize(reinterpret_cast<void *>(Chunk), &Header);
      }
```
`ExactUsableSize` is replaced by `useMemoryTagging<AllocatorConfig>(Primary.Options.load())`


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


More information about the llvm-commits mailing list