diff --git a/compiler-rt/lib/scudo/standalone/secondary.h b/compiler-rt/lib/scudo/standalone/secondary.h --- a/compiler-rt/lib/scudo/standalone/secondary.h +++ b/compiler-rt/lib/scudo/standalone/secondary.h @@ -528,7 +528,9 @@ InUseBlocks.push_back(H); AllocatedBytes += BlockSize; NumberOfAllocs++; - Stats.add(StatAllocated, BlockSize); + // Use H->CommitSize since on deallocate it's hard to recalculate + // the BlockSize to update the stats properly. + Stats.add(StatAllocated, H->CommitSize); Stats.add(StatMapped, H->MemMap.getCapacity()); } return Ptr;