Skip to content

Commit

Permalink
Merge pull request #2319 from AntelopeIO/merge-main-03-18-2024
Browse files Browse the repository at this point in the history
IF: Merge main 03-18-2024
  • Loading branch information
heifner authored Mar 18, 2024
2 parents 8635f39 + 98c08c3 commit 03ac11e
Show file tree
Hide file tree
Showing 16 changed files with 143 additions and 97 deletions.
42 changes: 42 additions & 0 deletions .cicd/platforms/ubsan.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# syntax=docker/dockerfile:1
FROM ubuntu:jammy
ENV TZ="America/New_York"
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y build-essential \
cmake \
git \
jq \
libcurl4-openssl-dev \
libgmp-dev \
llvm-11-dev \
lsb-release \
ninja-build \
python3-numpy \
software-properties-common \
file \
wget \
zlib1g-dev \
zstd

RUN yes | bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" llvm.sh 18

#make sure no confusion on what llvm library leap's cmake should pick up on
RUN rm -rf /usr/lib/llvm-18/lib/cmake

COPY <<-EOF /ubsan.supp
vptr:wasm_eosio_validation.hpp
vptr:wasm_eosio_injection.hpp
EOF

ENV LEAP_PLATFORM_HAS_EXTRAS_CMAKE=1
COPY <<-EOF /extras.cmake
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "" FORCE)

set(CMAKE_C_COMPILER "clang-18" CACHE STRING "")
set(CMAKE_CXX_COMPILER "clang++-18" CACHE STRING "")
set(CMAKE_C_FLAGS "-fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" CACHE STRING "")
set(CMAKE_CXX_FLAGS "-fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" CACHE STRING "")
EOF

ENV UBSAN_OPTIONS=print_stacktrace=1,suppressions=/ubsan.supp
3 changes: 3 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ jobs:
- cfg: {name: 'ubuntu20', base: 'ubuntu20', builddir: 'ubuntu20'}
- cfg: {name: 'ubuntu22', base: 'ubuntu22', builddir: 'ubuntu22'}
- cfg: {name: 'asserton', base: 'asserton', builddir: 'asserton'}
- cfg: {name: 'ubsan', base: 'ubsan', builddir: 'ubsan'}
- cfg: {name: 'ubuntu20repro', base: 'ubuntu20', builddir: 'reproducible'}
- cfg: {name: 'ubuntu22repro', base: 'ubuntu22', builddir: 'reproducible'}
runs-on: ["self-hosted", "enf-x86-hightier"]
Expand Down Expand Up @@ -176,6 +177,7 @@ jobs:
- cfg: {name: 'ubuntu20', base: 'ubuntu20', builddir: 'ubuntu20'}
- cfg: {name: 'ubuntu22', base: 'ubuntu22', builddir: 'ubuntu22'}
- cfg: {name: 'asserton', base: 'asserton', builddir: 'asserton'}
- cfg: {name: 'ubsan', base: 'ubsan', builddir: 'ubsan'}
- cfg: {name: 'ubuntu20repro', base: 'ubuntu20', builddir: 'reproducible'}
- cfg: {name: 'ubuntu22repro', base: 'ubuntu22', builddir: 'reproducible'}
runs-on: ["self-hosted", "enf-x86-midtier"]
Expand Down Expand Up @@ -216,6 +218,7 @@ jobs:
- cfg: {name: 'ubuntu20', base: 'ubuntu20', builddir: 'ubuntu20'}
- cfg: {name: 'ubuntu22', base: 'ubuntu22', builddir: 'ubuntu22'}
- cfg: {name: 'asserton', base: 'asserton', builddir: 'asserton'}
- cfg: {name: 'ubsan', base: 'ubsan', builddir: 'ubsan'}
- cfg: {name: 'ubuntu20repro', base: 'ubuntu20', builddir: 'reproducible'}
- cfg: {name: 'ubuntu22repro', base: 'ubuntu22', builddir: 'reproducible'}
runs-on: ["self-hosted", "enf-x86-lowtier"]
Expand Down
2 changes: 1 addition & 1 deletion libraries/appbase
25 changes: 25 additions & 0 deletions libraries/chain/include/eosio/chain/chainbase_environment.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

#include <chainbase/environment.hpp>

// reflect chainbase::environment for --print-build-info option
FC_REFLECT_ENUM(chainbase::environment::os_t,
(OS_LINUX) (OS_MACOS) (OS_WINDOWS) (OS_OTHER))
FC_REFLECT_ENUM(chainbase::environment::arch_t,
(ARCH_X86_64) (ARCH_ARM) (ARCH_RISCV) (ARCH_OTHER))

namespace fc {

void to_variant(const chainbase::environment& bi, variant& v) {
// the variant conversion ultimately binds a reference to each member, but chainbase::environment is packed making
// a reference to an unaligned variable UB. The boost_version is the only offender
unsigned aligned_boost_version = bi.boost_version;
v = fc::mutable_variant_object()("debug", bi.debug)
("os", bi.os)
("arch", bi.arch)
("boost_version", aligned_boost_version)
("compiler", bi.compiler);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

#include <sys/resource.h>

#ifndef __has_feature
#define __has_feature(x) 0
#endif

namespace eosio { namespace chain { namespace eosvmoc {

struct config {
Expand All @@ -20,7 +24,11 @@ struct config {
// libtester disables the limits in all tests, except enforces the limits
// in the tests in unittests/eosvmoc_limits_tests.cpp.
std::optional<rlim_t> cpu_limit {20u};
#if __has_feature(undefined_behavior_sanitizer) || __has_feature(address_sanitizer)
std::optional<rlim_t> vm_limit; // UBSAN & ASAN can add massive virtual memory usage; don't enforce vm limits when either of them are enabled
#else
std::optional<rlim_t> vm_limit {512u*1024u*1024u};
#endif
std::optional<uint64_t> stack_size_limit {16u*1024u};
std::optional<size_t> generated_code_size_limit {16u*1024u*1024u};
};
Expand Down
5 changes: 1 addition & 4 deletions libraries/chain/snapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,7 @@ void istream_snapshot_reader::validate() const {
("expected", expected_version)("actual", actual_version));

while (validate_section()) {}
} catch( const std::exception& e ) { \
snapshot_exception fce(FC_LOG_MESSAGE( warn, "Binary snapshot validation threw IO exception (${what})",("what",e.what())));
throw fce;
}
} FC_LOG_AND_RETHROW()
}

bool istream_snapshot_reader::validate_section() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ void run_compile(wrapped_fd&& response_sock, wrapped_fd&& wasm_code, uint64_t st

if(base_offset + data_segment.data.size() > initial_mem.size())
initial_mem.resize(base_offset + data_segment.data.size(), 0x00);
memcpy(initial_mem.data() + base_offset, data_segment.data.data(), data_segment.data.size());
if(data_segment.data.size())
memcpy(initial_mem.data() + base_offset, data_segment.data.data(), data_segment.data.size());
}

result_message.initdata_prologue_size = prologue.end() - prologue_it;
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/webassembly/runtimes/eos-vm-oc/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ memory::memory(uint64_t sliced_pages) {
uintptr_t* const intrinsic_jump_table = reinterpret_cast<uintptr_t* const>(zeropage_base - first_intrinsic_offset);
const intrinsic_map_t& intrinsics = get_intrinsic_map();
for(const auto& intrinsic : intrinsics)
intrinsic_jump_table[-intrinsic.second.ordinal] = (uintptr_t)intrinsic.second.function_ptr;
intrinsic_jump_table[-(int)intrinsic.second.ordinal] = (uintptr_t)intrinsic.second.function_ptr;
}

memory::~memory() {
Expand Down
2 changes: 1 addition & 1 deletion libraries/eos-vm
2 changes: 1 addition & 1 deletion libraries/libfc/libraries/bn256
Submodule bn256 updated 1 files
+6 −0 src/CMakeLists.txt
10 changes: 1 addition & 9 deletions plugins/chain_plugin/chain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
#include <eosio/chain_plugin/trx_finality_status_processing.hpp>
#include <eosio/chain/permission_link_object.hpp>
#include <eosio/chain/global_property_object.hpp>
#include <eosio/chain/chainbase_environment.hpp>

#include <eosio/resource_monitor_plugin/resource_monitor_plugin.hpp>

#include <chainbase/environment.hpp>

#include <boost/signals2/connection.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
Expand All @@ -28,13 +27,6 @@
#include <fc/variant.hpp>
#include <cstdlib>

// reflect chainbase::environment for --print-build-info option
FC_REFLECT_ENUM( chainbase::environment::os_t,
(OS_LINUX)(OS_MACOS)(OS_WINDOWS)(OS_OTHER) )
FC_REFLECT_ENUM( chainbase::environment::arch_t,
(ARCH_X86_64)(ARCH_ARM)(ARCH_RISCV)(ARCH_OTHER) )
FC_REFLECT(chainbase::environment, (debug)(os)(arch)(boost_version)(compiler) )

const std::string deep_mind_logger_name("deep-mind");
eosio::chain::deep_mind_handler _deep_mind_log;

Expand Down
Loading

0 comments on commit 03ac11e

Please sign in to comment.