Skip to content

Commit 19cfc30

Browse files
committed
compiler-rt: Make the tests pass on AArch64 and with page size != 4096.
This makes the tests pass on my AArch64 machine with 16K pages. Not sure why some of the AArch64-specific test failures don't seem to occur on sanitizer-aarch64-linux. I could also reproduce them by running buildbot_cmake.sh on my machine. Pull Request: #153860
1 parent 21a5729 commit 19cfc30

File tree

10 files changed

+45
-9
lines changed

10 files changed

+45
-9
lines changed

compiler-rt/lib/gwp_asan/tests/basic.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ TEST_F(DefaultGuardedPoolAllocator, NonPowerOfTwoAlignment) {
6565

6666
// Added multi-page slots? You'll need to expand this test.
6767
TEST_F(DefaultGuardedPoolAllocator, TooBigForSinglePageSlots) {
68-
EXPECT_EQ(nullptr, GPA.allocate(0x1001, 0));
69-
EXPECT_EQ(nullptr, GPA.allocate(0x1001, 1));
70-
EXPECT_EQ(nullptr, GPA.allocate(0x1001, 0x1000));
71-
EXPECT_EQ(nullptr, GPA.allocate(1, 0x2000));
72-
EXPECT_EQ(nullptr, GPA.allocate(0, 0x2000));
68+
size_t PageSize = sysconf(_SC_PAGESIZE);
69+
EXPECT_EQ(nullptr, GPA.allocate(PageSize + 1, 0));
70+
EXPECT_EQ(nullptr, GPA.allocate(PageSize + 1, 1));
71+
EXPECT_EQ(nullptr, GPA.allocate(PageSize + 1, PageSize));
72+
EXPECT_EQ(nullptr, GPA.allocate(1, 2 * PageSize));
73+
EXPECT_EQ(nullptr, GPA.allocate(0, 2 * PageSize));
7374
}
7475

7576
TEST_F(CustomGuardedPoolAllocator, AllocAllSlots) {

compiler-rt/lib/gwp_asan/tests/never_allocated.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
#include "gwp_asan/tests/harness.h"
1414

1515
TEST_P(BacktraceGuardedPoolAllocatorDeathTest, NeverAllocated) {
16+
size_t PageSize = sysconf(_SC_PAGESIZE);
17+
1618
SCOPED_TRACE("");
17-
void *Ptr = GPA.allocate(0x1000);
19+
void *Ptr = GPA.allocate(PageSize);
1820
GPA.deallocate(Ptr);
1921

2022
std::string DeathNeedle =
@@ -23,7 +25,7 @@ TEST_P(BacktraceGuardedPoolAllocatorDeathTest, NeverAllocated) {
2325
// Trigger a guard page in a completely different slot that's never allocated.
2426
// Previously, there was a bug that this would result in nullptr-dereference
2527
// in the posix crash handler.
26-
char *volatile NeverAllocatedPtr = static_cast<char *>(Ptr) + 0x3000;
28+
char *volatile NeverAllocatedPtr = static_cast<char *>(Ptr) + 3 * PageSize;
2729
if (!Recoverable) {
2830
EXPECT_DEATH(*NeverAllocatedPtr = 0, DeathNeedle);
2931
return;
@@ -37,8 +39,8 @@ TEST_P(BacktraceGuardedPoolAllocatorDeathTest, NeverAllocated) {
3739
GetOutputBuffer().clear();
3840
for (size_t i = 0; i < 100; ++i) {
3941
*NeverAllocatedPtr = 0;
40-
*(NeverAllocatedPtr + 0x2000) = 0;
41-
*(NeverAllocatedPtr + 0x3000) = 0;
42+
*(NeverAllocatedPtr + 2 * PageSize) = 0;
43+
*(NeverAllocatedPtr + 3 * PageSize) = 0;
4244
ASSERT_TRUE(GetOutputBuffer().empty());
4345
}
4446

compiler-rt/test/asan/TestCases/Linux/release_to_os_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// RUN: %env_asan_opts=allocator_release_to_os_interval_ms=-1 %run %t force 2>&1 | FileCheck %s --check-prefix=FORCE_RELEASE
77

88
// REQUIRES: x86_64-target-arch
9+
// REQUIRES: page-size-4096
910

1011
#include <algorithm>
1112
#include <assert.h>

compiler-rt/test/cfi/cross-dso/lit.local.cfg.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ def getRoot(config):
1212
# Android O (API level 26) has support for cross-dso cfi in libdl.so.
1313
if config.android and "android-26" not in config.available_features:
1414
config.unsupported = True
15+
16+
# The runtime library only supports 4K pages.
17+
if "page-size-4096" not in config.available_features:
18+
config.unsupported = True

compiler-rt/test/lit.common.cfg.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,23 @@ def is_windows_lto_supported():
965965
else:
966966
config.available_features.add("memprof-shadow-scale-3")
967967

968+
969+
def target_page_size():
970+
try:
971+
proc = subprocess.Popen(
972+
f"{emulator or ''} python3",
973+
shell=True,
974+
stdin=subprocess.PIPE,
975+
stdout=subprocess.PIPE,
976+
)
977+
out, err = proc.communicate(b'import os; print(os.sysconf("SC_PAGESIZE"))')
978+
return int(out)
979+
except:
980+
return 4096
981+
982+
983+
config.available_features.add(f"page-size-{target_page_size()}")
984+
968985
if config.expensive_checks:
969986
config.available_features.add("expensive_checks")
970987

compiler-rt/test/msan/dtls_test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
1212
// Reports use-of-uninitialized-value, not analyzed
1313
XFAIL: target={{.*netbsd.*}}
14+
XFAIL: aarch64-target-arch
1415
1516
*/
1617

compiler-rt/test/sanitizer_common/TestCases/Linux/odd_stack_size.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clangxx -O1 %s -o %t && %run %t
2+
// REQUIRES: page-size-4096
23
// UNSUPPORTED: android
34

45
// Fail on powerpc64 bots with:

compiler-rt/test/sanitizer_common/TestCases/Linux/release_to_os_test.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
// FIXME: This mode uses 32bit allocator without purge.
1212
// UNSUPPORTED: hwasan-aliasing
1313

14+
// Page size is hardcoded below, but test still fails even if not hardcoded.
15+
// REQUIRES: page-size-4096
16+
1417
#include <algorithm>
1518
#include <assert.h>
1619
#include <fcntl.h>

compiler-rt/test/sanitizer_common/TestCases/Linux/resize_tls_dynamic.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
// FIXME: Investigate
1212
// UNSUPPORTED: target=powerpc64{{.*}}
1313

14+
// Fails because AArch64 uses TLSDESC instead of __tls_get_addr.
15+
// UNSUPPORTED: aarch64-target-arch
16+
1417
#include <string.h>
1518

1619
#ifndef BUILD_DSO

compiler-rt/test/sanitizer_common/TestCases/Linux/tls_get_addr.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
// FIXME: Fails for unknown reasons.
1414
// UNSUPPORTED: powerpc64le-target-arch
1515

16+
// Fails because AArch64 uses TLSDESC instead of __tls_get_addr.
17+
// UNSUPPORTED: aarch64-target-arch
18+
1619
#ifndef BUILD_SO
1720
# include <assert.h>
1821
# include <dlfcn.h>

0 commit comments

Comments
 (0)