Aligned new does not require size to be a multiple of alignment, so
memalign is the correct choice instead of aligned_alloc.
Fixes false reports for unaligned sizes.
Differential D119161
[HWASan] Use hwasan_memalign for aligned new. vitalybuka on Feb 7 2022, 10:13 AM. Authored by
Details Aligned new does not require size to be a multiple of alignment, so Fixes false reports for unaligned sizes.
Diff Detail
Event TimelineComment Actions This doesn't build on our bots: https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket/8822637711003001489/+/u/package_clang/stdout?format=raw : 'RUN: at line 2'; /b/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/./bin/clang --driver-mode=g++ -m64 -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -fsanitize-hwaddress-experimental-aliasing -mllvm -hwasan-generate-tags-with-calls=1 -mllvm -hwasan-globals -mllvm -hwasan-use-short-granules -mllvm -hwasan-instrument-landing-pads=0 -mllvm -hwasan-instrument-personality-functions -std=c++17 /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/test/hwasan/TestCases/new-test.cpp -o /b/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/projects/compiler-rt/test/hwasan/X86_64/TestCases/Output/new-test.cpp.tmp [...] Command Output (stderr): -- /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/test/hwasan/TestCases/new-test.cpp:22:32: error: no member named 'align_val_t' in namespace 'std' constexpr auto kAlign = std::align_val_t{8}; ~~~~~^ /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/test/hwasan/TestCases/new-test.cpp:22:43: error: expected ';' at end of declaration constexpr auto kAlign = std::align_val_t{8}; ^ ; 2 errors generated. The problem is probably that system gcc on that bot is fairly old. So we have gcc 10.2 somewhere on the side, and pass '-DCOMPILER_RT_TEST_COMPILER_CFLAGS=--gcc-toolchain=/b/s/w/ir/cache/builder/src/third_party/llvm-build-tools/gcc-10.2.0-trusty -Wl,-rpath,/b/s/w/ir/cache/builder/src/third_party/llvm-build-tools/gcc-10.2.0-trusty/lib64 -Wl,-rpath,/b/s/w/ir/cache/builder/src/third_party/llvm-build-tools/gcc-10.2.0-trusty/lib32' to cmake, but it looks like that doesn't make it into %clangxx_hwasan (?)
|
Maybe just:
// REQUIRES: Clang