Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions compiler-rt/lib/gwp_asan/tests/basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ TEST_F(DefaultGuardedPoolAllocator, NonPowerOfTwoAlignment) {

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

TEST_F(CustomGuardedPoolAllocator, AllocAllSlots) {
Expand Down
10 changes: 6 additions & 4 deletions compiler-rt/lib/gwp_asan/tests/never_allocated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
#include "gwp_asan/tests/harness.h"

TEST_P(BacktraceGuardedPoolAllocatorDeathTest, NeverAllocated) {
size_t PageSize = sysconf(_SC_PAGESIZE);

SCOPED_TRACE("");
void *Ptr = GPA.allocate(0x1000);
void *Ptr = GPA.allocate(PageSize);
GPA.deallocate(Ptr);

std::string DeathNeedle =
Expand All @@ -23,7 +25,7 @@ TEST_P(BacktraceGuardedPoolAllocatorDeathTest, NeverAllocated) {
// Trigger a guard page in a completely different slot that's never allocated.
// Previously, there was a bug that this would result in nullptr-dereference
// in the posix crash handler.
char *volatile NeverAllocatedPtr = static_cast<char *>(Ptr) + 0x3000;
char *volatile NeverAllocatedPtr = static_cast<char *>(Ptr) + 3 * PageSize;
if (!Recoverable) {
EXPECT_DEATH(*NeverAllocatedPtr = 0, DeathNeedle);
return;
Expand All @@ -37,8 +39,8 @@ TEST_P(BacktraceGuardedPoolAllocatorDeathTest, NeverAllocated) {
GetOutputBuffer().clear();
for (size_t i = 0; i < 100; ++i) {
*NeverAllocatedPtr = 0;
*(NeverAllocatedPtr + 0x2000) = 0;
*(NeverAllocatedPtr + 0x3000) = 0;
*(NeverAllocatedPtr + 2 * PageSize) = 0;
*(NeverAllocatedPtr + 3 * PageSize) = 0;
ASSERT_TRUE(GetOutputBuffer().empty());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// RUN: %env_asan_opts=allocator_release_to_os_interval_ms=-1 %run %t force 2>&1 | FileCheck %s --check-prefix=FORCE_RELEASE

// REQUIRES: x86_64-target-arch
// REQUIRES: page-size-4096

#include <algorithm>
#include <assert.h>
Expand Down
4 changes: 4 additions & 0 deletions compiler-rt/test/cfi/cross-dso/lit.local.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ def getRoot(config):
# Android O (API level 26) has support for cross-dso cfi in libdl.so.
if config.android and "android-26" not in config.available_features:
config.unsupported = True

# The runtime library only supports 4K pages.
if "page-size-4096" not in config.available_features:
config.unsupported = True
7 changes: 5 additions & 2 deletions compiler-rt/test/dfsan/atomic.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// RUN: %clangxx_dfsan %s -fno-exceptions -o %t && %run %t
// RUN: %clangxx_dfsan -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 %s -fno-exceptions -o %t && %run %t
// RUN: %clangxx_dfsan %s -fno-exceptions -D_GLIBCXX_NO_ASSERTIONS -o %t && %run %t
// RUN: %clangxx_dfsan -DORIGIN_TRACKING -mllvm -dfsan-track-origins=1 %s -fno-exceptions -D_GLIBCXX_NO_ASSERTIONS -o %t && %run %t
//
// Use -fno-exceptions to turn off exceptions to avoid instrumenting
// __cxa_begin_catch, std::terminate and __gxx_personality_v0.
//
// Use -D_GLIBCXX_NO_ASSERTIONS to avoid depending on
// std::__glibcxx_assert_fail with gcc >= 15.
//
// TODO: Support builtin atomics. For example, https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
// DFSan instrumentation pass cannot identify builtin callsites yet.

Expand Down
17 changes: 17 additions & 0 deletions compiler-rt/test/lit.common.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,23 @@ def is_windows_lto_supported():
else:
config.available_features.add("memprof-shadow-scale-3")


def target_page_size():
try:
proc = subprocess.Popen(
f"{emulator or ''} python3",
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
)
out, err = proc.communicate(b'import os; print(os.sysconf("SC_PAGESIZE"))')
return int(out)
except:
return 4096


config.available_features.add(f"page-size-{target_page_size()}")

if config.expensive_checks:
config.available_features.add("expensive_checks")

Expand Down
1 change: 1 addition & 0 deletions compiler-rt/test/msan/dtls_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

// Reports use-of-uninitialized-value, not analyzed
XFAIL: target={{.*netbsd.*}}
UNSUPPORTED: aarch64-target-arch

*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clangxx -O1 %s -o %t && %run %t
// REQUIRES: page-size-4096
// UNSUPPORTED: android

// Fail on powerpc64 bots with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
// FIXME: This mode uses 32bit allocator without purge.
// UNSUPPORTED: hwasan-aliasing

// Page size is hardcoded below, but test still fails even if not hardcoded.
// REQUIRES: page-size-4096

#include <algorithm>
#include <assert.h>
#include <fcntl.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
// FIXME: Investigate
// UNSUPPORTED: target=powerpc64{{.*}}

// Fails because AArch64 uses TLSDESC instead of __tls_get_addr.
// UNSUPPORTED: aarch64-target-arch

#include <string.h>

#ifndef BUILD_DSO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
// FIXME: Fails for unknown reasons.
// UNSUPPORTED: powerpc64le-target-arch

// Fails because AArch64 uses TLSDESC instead of __tls_get_addr.
// UNSUPPORTED: aarch64-target-arch

#ifndef BUILD_SO
# include <assert.h>
# include <dlfcn.h>
Expand Down
Loading