[PATCH] D104402: [scudo] Ensure proper allocator alignment in TSD test

Yvan Roux via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 16 12:36:47 PDT 2021


yroux added inline comments.


================
Comment at: compiler-rt/lib/scudo/standalone/tsd_shared.h:157
     const u32 Index = atomic_fetch_add(&CurrentIndex, 1U, memory_order_relaxed);
+    DCHECK(isAligned(reinterpret_cast<uptr>(&TSDs[Index % NumberOfTSDs]),
+                     SCUDO_CACHE_LINE_SIZE));
----------------
vitalybuka wrote:
> vitalybuka wrote:
> > vitalybuka wrote:
> > > Should we just check isAligned(this, alignof(*this)) ?
> > > 
> > I guess alignas in allocator promises alignment which is not delivered buy "new"
> > So maybe more consistent solution is just to put DCHECK(isAligned) into every class with alignas statement.
> > 
> e.g.
> GlobalQuarantine::Init
> SizeClassAllocator64::Init
> SizeClassAllocator32::SizeClassAllocator32
> TSD::Init
> 
> 
Ah yes, it seems better indeed.
I verified it on ARM and it fixes the issue as well


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104402/new/

https://reviews.llvm.org/D104402



More information about the llvm-commits mailing list