Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Do not merge] CI test, cmake option to enable address santitizer. #2890

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions .buildkite/lib/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ function get_yaml_path(platform::Platform)
lib_dir = @__DIR__
buildkite_dir = dirname(lib_dir)
yaml_path = joinpath(buildkite_dir, "test-$(platform.arch).yml")
if platform.variant != ""
yaml_path = joinpath(buildkite_dir, "test-$(platform.arch)-$(platform.variant).yml")
end
return yaml_path
end
16 changes: 14 additions & 2 deletions .buildkite/lib/generate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import YAML
include(joinpath(@__DIR__, "common.jl"))

function generate(platform::Platform)
force32bit = occursin("force32bit", platform.variant)
commands = """
echo "--- Print kernel information"
uname -a
Expand All @@ -18,12 +19,19 @@ function generate(platform::Platform)
tar -C / -xf DebianGlibc.v2.33.0.aarch64-linux-gnu.tar.gz
fi

if [[ "$(force32bit)" == "true" ]]; then
echo "--- Installing i386 packages"
dpkg --add-architecture i386
apt update
apt install -y capnproto libcapnp-dev:i386 zlib1g-dev:i386 file
fi

echo "--- Generate build environment"
cmake --version
rm -rf obj
mkdir obj
cd obj
cmake ..
cmake $(platform.cmake_extra_arg) ..

echo "--- Build"
make --output-sync -j\$\${JULIA_CPU_THREADS:?}
Expand All @@ -41,12 +49,16 @@ function generate(platform::Platform)
"""
job_label = "Test $(platform.arch)"
job_key = "test-$(platform.arch)"
if platform.variant != ""
job_label = "Test $(platform.arch) $(platform.variant)"
job_key = "test-$(platform.arch)-$(platform.variant)"
end
yaml = Dict(
"steps" => [
Dict(
"label" => job_label,
"key" => job_key,
"timeout_in_minutes" => 45,
"timeout_in_minutes" => platform.timeout,
"agents" => Dict(
"sandbox_capable" => "true",
"queue" => "juliaecosystem",
Expand Down
49 changes: 49 additions & 0 deletions .buildkite/lib/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Base.@kwdef struct Platform
rootfs_treehash::String
allow_fail::Bool
commit_status::Bool
cmake_extra_arg::String
variant::String
timeout::Integer
end

struct Platforms
Expand All @@ -22,13 +25,59 @@ const platforms = Platforms(
rootfs_treehash = "1cd67e278881dcfeed695282256b26fad603e15d",
allow_fail = false,
commit_status = true,
cmake_extra_arg = "",
variant = "",
timeout = 45,
),
Platform(;
arch = "x86_64",
rootfs_tag = "v5.22",
rootfs_treehash = "1cd67e278881dcfeed695282256b26fad603e15d",
allow_fail = false,
commit_status = true,
cmake_extra_arg = "-Dasan=true",
variant = "asan",
timeout = 45,
),
Platform(;
arch = "aarch64",
rootfs_tag = "v5.22",
rootfs_treehash = "7a63218e46996b36aa108b55746a3d94a3e312c1",
allow_fail = false,
commit_status = true,
cmake_extra_arg = "",
variant = "",
timeout = 45,
),
Platform(;
arch = "aarch64",
rootfs_tag = "v5.22",
rootfs_treehash = "7a63218e46996b36aa108b55746a3d94a3e312c1",
allow_fail = false,
commit_status = true,
cmake_extra_arg = "-Dasan=true",
variant = "asan",
timeout = 55,
),
Platform(;
arch = "x86_64",
rootfs_tag = "v5.22",
rootfs_treehash = "1cd67e278881dcfeed695282256b26fad603e15d",
allow_fail = false,
commit_status = true,
cmake_extra_arg = "-Dforce32bit=true",
variant = "force32bit",
timeout = 55,
),
Platform(;
arch = "x86_64",
rootfs_tag = "v5.22",
rootfs_treehash = "1cd67e278881dcfeed695282256b26fad603e15d",
allow_fail = false,
commit_status = true,
cmake_extra_arg = "-Dforce32bit=true -Dasan=true",
variant = "force32bit-asan",
timeout = 55,
),
]
)
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,11 @@ if (asan)
set(RR_FLAGS "${ASAN_FLAGS} ${RR_FLAGS}")
endif()

file(REMOVE "${CMAKE_BINARY_DIR}/src/test/util_env.sh")
if (asan)
file(WRITE "${CMAKE_BINARY_DIR}/src/test/util_env.sh" "export RR_ASAN=true\n")
endif()

set_source_files_properties(${RR_SOURCES}
PROPERTIES COMPILE_FLAGS ${RR_FLAGS})

Expand Down Expand Up @@ -1671,6 +1676,18 @@ set(TESTS_WITHOUT_PROGRAM
when
)

if (asan)
if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
list(REMOVE_ITEM TESTS_WITH_PROGRAM "ignore_nested")
list(REMOVE_ITEM TESTS_WITHOUT_PROGRAM "nested_detach")
list(REMOVE_ITEM TESTS_WITHOUT_PROGRAM "nested_detach_kill") # depends on nested_detach_wait
list(REMOVE_ITEM TESTS_WITH_PROGRAM "nested_detach_kill_stuck") # depends on nested_detach_wait
list(REMOVE_ITEM TESTS_WITH_PROGRAM "nested_detach_wait")
list(REMOVE_ITEM TESTS_WITHOUT_PROGRAM "nested_release")
list(REMOVE_ITEM TESTS_WITHOUT_PROGRAM "record_replay")
endif()
endif()

if(BUILD_TESTS)
# Part of the installable testsuite (test files).
if(INSTALL_TESTSUITE)
Expand Down Expand Up @@ -1797,6 +1814,8 @@ if(BUILD_TESTS)
string(REGEX MATCH "^.*(Xeon Phi).*$" CPU_MODEL_PHI ${CPUINFO})
if(NOT "${CPU_MODEL_PHI}" STREQUAL "")
set(TEST_MONITOR_DEFAULT_TIMEOUT 480)
elseif(asan)
set(TEST_MONITOR_DEFAULT_TIMEOUT 240)
else()
set(TEST_MONITOR_DEFAULT_TIMEOUT 120)
endif()
Expand Down
12 changes: 12 additions & 0 deletions src/AddressSpace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2319,6 +2319,18 @@ remote_ptr<void> AddressSpace::chaos_mode_find_free_memory(RecordTask* t,
break;
}
addr = overlapping_range.end();

#ifdef __i386__
// Moving forward and hitting the end
if (addr > addr + ceil_page_size(len)) {
/*remote_ptr<void> end_ = addr + ceil_page_size(len);
if (addr > end_) {
fprintf(stderr, "addr[0x%x] > end_[0x%x], ceil_page_size(len)[0x%x], len[0x%x], start[0x%x], sizeof(uintptr_t)[%d], addr_space_start[0x%x], addr_space_end[0x%x], direction[%d]\n",
addr.as_int(), end_.as_int(), ceil_page_size(len), len, start.as_int(), sizeof(uintptr_t), addr_space_start.as_int(), addr_space_end.as_int(), direction);
}*/
break;
}
#endif
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/RecordSession.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2223,6 +2223,8 @@ static ExeInfo read_exe_info(const string& exe_file) {
ElfFileReader reader(fd);
ret.arch = reader.arch();

// Don't try to modifiy LD_PRELOAD when rr itself is built with ASan
#ifndef __SANITIZE_ADDRESS__
DynamicSection dynamic = reader.read_dynamic();
for (auto& entry : dynamic.entries) {
if (entry.tag == DT_NEEDED && entry.val < dynamic.strtab.size()) {
Expand All @@ -2236,6 +2238,7 @@ static ExeInfo read_exe_info(const string& exe_file) {
}
}
}
#endif

auto syms = reader.read_symbols(".dynsym", ".dynstr");
for (size_t i = 0; i < syms.size(); ++i) {
Expand Down
1 change: 1 addition & 0 deletions src/test/record_replay.run
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
source `dirname $0`/util.sh
if [ $TIMEOUT -lt 600 ]; then TIMEOUT=600; fi
if [ "$RR_ASAN" == "true" ]; then TIMEOUT=800; fi
record record_replay_subject$bitness
just_record rr "--suppress-environment-warnings replay -a $workdir/*-0"
replay
Expand Down
7 changes: 7 additions & 0 deletions src/test/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ if [[ "$NO_CHECK_CACHED_MMAP" == "" ]]; then
GLOBAL_OPTIONS="${GLOBAL_OPTIONS} --check-cached-mmaps"
fi

if [[ -f "${OBJDIR}/src/test/util_env.sh" ]]; then
source "${OBJDIR}/src/test/util_env.sh"
fi

SRCDIR=`dirname ${BASH_SOURCE[0]}`/../..
SRCDIR=`realpath $SRCDIR`

Expand Down Expand Up @@ -135,6 +139,9 @@ OBJDIR=`realpath $OBJDIR`
TIMEOUT=$4
if [[ "$TIMEOUT" == "" ]]; then
TIMEOUT=120
if [ "$RR_ASAN" == "true" ]; then
TIMEOUT=240
fi
fi

# The temporary directory we create for this test run.
Expand Down
4 changes: 4 additions & 0 deletions src/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2461,6 +2461,10 @@ int __lsan_is_turned_off(void)
{
return rr_lsan_is_turned_off;
}
#include <sanitizer/asan_interface.h>
const char *__asan_default_options() {
return "verify_asan_link_order=0";
}
#endif

bool coredumping_signal_takes_down_entire_vm() {
Expand Down