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

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 16 13:50:11 PDT 2021


cryptoad 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));
----------------
yroux wrote:
> 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
ack, working on it.


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