[cfe-dev] Alignment problems in Clang's internal data structures?
Renato Golin
renato.golin at linaro.org
Tue Feb 17 01:42:10 PST 2015
On 17 February 2015 at 00:38, Ahmed Bougacha <ahmed.bougacha at gmail.com> wrote:
> std::size_t Size = sizeof(DeclRefExpr);
> if (...)
> Size += sizeof(...);
> ...
> void *Mem = Context.Allocate(Size, llvm::alignOf<DeclRefExpr>());
This sounds wrong. You should have something like:
std::size_t Size = sizeof(DeclRefExpr);
std::size_t Align = llvm::alignOf<DeclRefExpr>();
if (...) {
Size += sizeof(...);
Align = std::max(Align, llvm::alignOf<...>());
}
...
void *Mem = Context.Allocate(Size, Align);
> UBSan's alignment sanitizer would be *very* useful here, but my
> understanding is, ARM isn't currently supported, and running it on X86
> is futile (at least x86_64, maybe i386 could reproduce though; that's
> on my todo list.)
It'd be great to have UBSAN working on ARM, at least that small part. :)
But that also mean we'd have to actually run it as a buildbot to make
sure we don't re-introduce the pattern.
Another thing we could do is to run as many santisers as we can during
releases, at least when running the test-suite. But first, I need to
set this up and actually run it with all SANs and fix all bugs before
the next release (3.7). We'll get there, eventually. :)
cheers,
--renato
More information about the cfe-dev
mailing list