[PATCH] D38574: [Sanitizers] ASan: detect new/delete calls with mismatched alignment.
Aleksey Shlyapnikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 23 18:10:32 PDT 2017
alekseyshl added a comment.
In https://reviews.llvm.org/D38574#904329, @eugenis wrote:
> What exactly is "default alignment" and what happens if it is equal to 8? Will it be treated as incompatible with 8?
The wording is derived from the standard, default-aligned vs over-aligned memory. malloc/etc allocate default-aligned memory, posix_memalign allocate over-aligned memory.
The standard says that new/delete pairs must match in regard of the alignement and default- and over-aligned memory must not be mixed.
There's __STDCPP_DEFAULT_NEW_ALIGNMENT__ defined and alignments > it will be passed explicitly, otherwise it's implicit, that is, if it happens to be equal to 8, it' supposed to be treated as default.
> What happens if once source file is built with aligned-delete support, and the other - without (-std=c++14)? Looks like new() from the former would not be compatible with delete() from the latter.
Well, the standard says that new/delete pairs must match, so you're correct, they will be incompatible. Using their example, imagine aligned new uses a separate arena for allocation, how would alignment unaware delete be able to free that memory?
https://reviews.llvm.org/D38574
More information about the llvm-commits
mailing list