This is an archive of the discontinued LLVM Phabricator instance.

[HWASan] Use hwasan_memalign for aligned new.
ClosedPublic

Authored by vitalybuka on Feb 7 2022, 10:13 AM.

Details

Summary

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.

Diff Detail

Event Timeline

morehouse requested review of this revision.Feb 7 2022, 10:13 AM
morehouse created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2022, 10:13 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
eugenis accepted this revision.Feb 7 2022, 1:05 PM

LGTM

This revision is now accepted and ready to land.Feb 7 2022, 1:05 PM
This revision was landed with ongoing or failed builds.Feb 7 2022, 1:10 PM
This revision was automatically updated to reflect the committed changes.
thakis added a subscriber: thakis.Feb 10 2022, 6:05 AM

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 (?)

vitalybuka added inline comments.Feb 10 2022, 12:39 PM
compiler-rt/test/hwasan/TestCases/new-test.cpp
5–8

Maybe just:
// REQUIRES: Clang

vitalybuka added inline comments.Feb 10 2022, 12:45 PM
compiler-rt/test/hwasan/TestCases/new-test.cpp
5–8

ignore this
it's already clang, just different std lib

vitalybuka reopened this revision.Feb 18 2022, 7:23 PM
This revision is now accepted and ready to land.Feb 18 2022, 7:23 PM
vitalybuka commandeered this revision.Feb 18 2022, 7:23 PM
vitalybuka edited reviewers, added: morehouse; removed: vitalybuka.

Fix test for older glibcxx

This revision was landed with ongoing or failed builds.Feb 23 2022, 2:22 PM
This revision was automatically updated to reflect the committed changes.