This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Relax the restriction on SizeClassAllocator64::kAllocatorSize
ClosedPublic

Authored by MaskRay on Jun 23 2023, 2:11 PM.

Details

Summary

Commit 278ccdacdcbde3399f1fa4b3ab929212e4e0322c says that kAllocatorSize
must be >= (1<<32), but this is not accurate. This static_assert causes 128GiB
kAllocatorSize to be unable to select DefaultSizeClassMap (kRegionSize is
1<<31).

Relax the restriction to be able to satisfy the largest size class. This allows
DefaultSizeClassMap to be usable with 128GiB kAllocatorSize, with
check-{asan,lsan,sanitizer} passing.

Diff Detail

Event Timeline

MaskRay created this revision.Jun 23 2023, 2:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2023, 2:11 PM
Herald added a subscriber: Enna1. · View Herald Transcript
MaskRay requested review of this revision.Jun 23 2023, 2:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2023, 2:11 PM
kstoimenov accepted this revision.Jun 27 2023, 3:53 PM
This revision is now accepted and ready to land.Jun 27 2023, 3:53 PM
vitalybuka accepted this revision.Jun 27 2023, 7:39 PM
aganea added a subscriber: aganea.Oct 2 2023, 9:51 AM
aganea added inline comments.
compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
639

@MaskRay I was seeing this when building on Windows with ToT:

C:\git\llvm-project>ninja check-asan -C stage1_msvc
ninja: Entering directory `stage1_msvc'
[33/56] Generating ASAN_NOINST_TEST_OBJECTS.asan_noinst_test.cpp.x86_64-inline.o
In file included from C:/git/llvm-project/compiler-rt/lib/asan/tests/asan_noinst_test.cpp:24:
In file included from C:/git/llvm-project/compiler-rt/lib/asan\asan_allocator.h:20:
In file included from C:/git/llvm-project/compiler-rt/lib\sanitizer_common/sanitizer_allocator.h:74:
C:/git/llvm-project/compiler-rt/lib\sanitizer_common\sanitizer_allocator_primary64.h:639:54: warning: 'static_assert' with no message is a C++17 extension [-Wc++17-extensions]
  639 |   static_assert(kRegionSize >= SizeClassMap::kMaxSize);
      |                                                      ^
      |                                                      , ""
1 warning generated.

I fixed it in https://reviews.llvm.org/rGd58fb40670ea

static_assert with no message requires --std=c++17 which is not present for this test object. Otherwise we could add that here. The build command for that object is currently:

COMMAND = cmd.exe /C "cd /D C:\git\llvm-project\stage1_msvc\projects\compiler-rt\lib\asan\tests && C:\git\llvm-project\stage1_msvc\.\bin\clang.exe -DGTEST_NO_LLVM_SUPPORT=1 -DGTEST_HAS_RTTI=0 -IC:/git/llvm-project/llvm/../third-party/unittest/googletest/include -IC:/git/llvm-project/llvm/../third-party/unittest/googletest -Wno-deprecated-declarations -IC:/git/llvm-project/compiler-rt/include -IC:/git/llvm-project/compiler-rt/lib -IC:/git/llvm-project/compiler-rt/lib/asan -IC:/git/llvm-project/compiler-rt/lib/sanitizer_common/tests -DSANITIZER_COMMON_NO_REDEFINE_BUILTINS -fno-rtti -O2 -Wno-format -Werror=sign-compare -gline-tables-only -gcodeview -DASAN_HAS_IGNORELIST=1 -DASAN_HAS_EXCEPTIONS=1 -DASAN_UAR=0 -c -o ASAN_NOINST_TEST_OBJECTS.asan_noinst_test.cpp.x86_64-inline.o C:/git/llvm-project/compiler-rt/lib/asan/tests/asan_noinst_test.cpp"

static_assert with no message requires --std=c++17 which is not present for this test object. Otherwise we could add that here. The build command for that object is currently:

COMMAND = cmd.exe /C "cd /D C:\git\llvm-project\stage1_msvc\projects\compiler-rt\lib\asan\tests && C:\git\llvm-project\stage1_msvc\.\bin\clang.exe -DGTEST_NO_LLVM_SUPPORT=1 -DGTEST_HAS_RTTI=0 -IC:/git/llvm-project/llvm/../third-party/unittest/googletest/include -IC:/git/llvm-project/llvm/../third-party/unittest/googletest -Wno-deprecated-declarations -IC:/git/llvm-project/compiler-rt/include -IC:/git/llvm-project/compiler-rt/lib -IC:/git/llvm-project/compiler-rt/lib/asan -IC:/git/llvm-project/compiler-rt/lib/sanitizer_common/tests -DSANITIZER_COMMON_NO_REDEFINE_BUILTINS -fno-rtti -O2 -Wno-format -Werror=sign-compare -gline-tables-only -gcodeview -DASAN_HAS_IGNORELIST=1 -DASAN_HAS_EXCEPTIONS=1 -DASAN_UAR=0 -c -o ASAN_NOINST_TEST_OBJECTS.asan_noinst_test.cpp.x86_64-inline.o C:/git/llvm-project/compiler-rt/lib/asan/tests/asan_noinst_test.cpp"

Yes, looks like cmake issue, but I am fine either way. We can let cmake fix to those who will need more important c++17 features.

MaskRay added a comment.EditedOct 9 2023, 11:45 PM

static_assert with no message requires --std=c++17 which is not present for this test object. Otherwise we could add that here. The build command for that object is currently:

COMMAND = cmd.exe /C "cd /D C:\git\llvm-project\stage1_msvc\projects\compiler-rt\lib\asan\tests && C:\git\llvm-project\stage1_msvc\.\bin\clang.exe -DGTEST_NO_LLVM_SUPPORT=1 -DGTEST_HAS_RTTI=0 -IC:/git/llvm-project/llvm/../third-party/unittest/googletest/include -IC:/git/llvm-project/llvm/../third-party/unittest/googletest -Wno-deprecated-declarations -IC:/git/llvm-project/compiler-rt/include -IC:/git/llvm-project/compiler-rt/lib -IC:/git/llvm-project/compiler-rt/lib/asan -IC:/git/llvm-project/compiler-rt/lib/sanitizer_common/tests -DSANITIZER_COMMON_NO_REDEFINE_BUILTINS -fno-rtti -O2 -Wno-format -Werror=sign-compare -gline-tables-only -gcodeview -DASAN_HAS_IGNORELIST=1 -DASAN_HAS_EXCEPTIONS=1 -DASAN_UAR=0 -c -o ASAN_NOINST_TEST_OBJECTS.asan_noinst_test.cpp.x86_64-inline.o C:/git/llvm-project/compiler-rt/lib/asan/tests/asan_noinst_test.cpp"

Yes, looks like cmake issue, but I am fine either way. We can let cmake fix to those who will need more important c++17 features.

@aganea https://reviews.llvm.org/rGd58fb40670ea looks fine to me, though I'd hope that we can fix the CMake issue: we pass -std=c++17 to other files but somehow lose -std=c++17 for ASAN_NOINST_TEST_OBJECTS.asan_noinst_test.cpp.x86_64-inline.o?
The current CMake issue would cause C++14 vs C++17 differences depending on the host compiler's default -std=.