[compiler-rt] [scudo] Apply filling option when realloc grows a block in-place too (PR #93212)

Christopher Ferris via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 4 17:33:20 PDT 2024


================
@@ -565,6 +565,19 @@ class Allocator {
             storeSecondaryAllocationStackMaybe(Options, OldPtr, NewSize);
           }
         }
+
+        // If we've increased the size, fill the extra bytes.
+        if (NewSize > OldSize) {
----------------
cferris1000 wrote:

>From the rest of the code, you need to do this for allocations coming from the secondary, but allocations coming from the primary have the entire size filled on allocation (see initChunk). The only way that a primary allocation would need this is if the allocation shrunk and then expanded. That operation is very, very unlikely to happen. But to make this still work in that case, you could modify this so that if a primary allocation shrinks, then set all of the bytes after the shrunk allocation to the fill. That would mean the performance of the normal case doesn't require this extra memset for primary allocations.

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


More information about the llvm-commits mailing list