diff --git a/.azure-pipelines-templates/daily-matrix.yml b/.azure-pipelines-templates/daily-matrix.yml index 23c80aa1010..74a4c1389a0 100644 --- a/.azure-pipelines-templates/daily-matrix.yml +++ b/.azure-pipelines-templates/daily-matrix.yml @@ -33,7 +33,7 @@ parameters: cmake_args: "-DCMAKE_BUILD_TYPE=Debug" cmake_env: "" ASAN: - cmake_args: "-DSAN=ON" + cmake_args: "-DSAN=ON -DUSE_LIBCXX=OFF" cmake_env: "" TSAN: cmake_args: "-DTSAN=ON -DWORKER_THREADS=2" diff --git a/.github/workflows/long-test.yml b/.github/workflows/long-test.yml index e9ed0d72333..ba5984f6875 100644 --- a/.github/workflows/long-test.yml +++ b/.github/workflows/long-test.yml @@ -53,7 +53,7 @@ jobs: git config --global --add safe.directory "$GITHUB_WORKSPACE" mkdir build cd build - cmake -GNinja -DCOMPILE_TARGET=virtual -DCMAKE_BUILD_TYPE=Debug -DLONG_TESTS=ON -DSAN=ON .. + cmake -GNinja -DCOMPILE_TARGET=virtual -DCMAKE_BUILD_TYPE=Debug -DLONG_TESTS=ON -DSAN=ON -DUSE_LIBCXX=OFF .. ninja - name: "Test" diff --git a/CMakeLists.txt b/CMakeLists.txt index d81dc186bcb..8a4bfd0063f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -929,13 +929,6 @@ if(BUILD_TESTS) PROPERTY LABELS unit_test ) - # https://github.com/microsoft/CCF/issues/5198 - set_property( - TEST csr_test - APPEND - PROPERTY ENVIRONMENT "ASAN_OPTIONS=alloc_dealloc_mismatch=0" - ) - add_test(NAME versionifier_test COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/python/src/ccf/_versionifier.py diff --git a/cmake/common.cmake b/cmake/common.cmake index ac50801edb9..877ca7fd346 100644 --- a/cmake/common.cmake +++ b/cmake/common.cmake @@ -26,13 +26,6 @@ function(add_unit_test name) "TSAN_OPTIONS=suppressions=${CCF_DIR}/tsan_env_suppressions" ) - # https://github.com/microsoft/CCF/issues/5198 - set_property( - TEST ${name} - APPEND - PROPERTY ENVIRONMENT "ASAN_OPTIONS=alloc_dealloc_mismatch=0" - ) - endfunction() # Test binary wrapper diff --git a/include/ccf/http_accept.h b/include/ccf/http_accept.h index fc5f175e5f2..53093bfde33 100644 --- a/include/ccf/http_accept.h +++ b/include/ccf/http_accept.h @@ -46,7 +46,7 @@ namespace ccf::http bool operator<(const AcceptHeaderField& other) const { static constexpr auto float_comp_epsilon = 0.0000001f; - if (abs(q_factor - other.q_factor) > float_comp_epsilon) + if (std::abs(q_factor - other.q_factor) > float_comp_epsilon) { return q_factor < other.q_factor; } diff --git a/src/ds/ring_buffer.h b/src/ds/ring_buffer.h index ea662a403c4..eb7536298c7 100644 --- a/src/ds/ring_buffer.h +++ b/src/ds/ring_buffer.h @@ -145,19 +145,24 @@ namespace ringbuffer { static inline uint64_t read64_impl(const BufferDef& bd, size_t index) { + auto src = bd.data + index; + auto src_64 = reinterpret_cast(src); + #ifdef __cpp_lib_atomic_ref - auto& ref = *(reinterpret_cast(bd.data + index)); - std::atomic_ref slot(ref); - return slot.load(std::memory_order_acquire); -#else - // __atomic_load is used instead of std::atomic_ref since it's not - // supported by libc++ yet. + if (Const::is_aligned(src, 8)) + { + auto& ref = *src_64; + std::atomic_ref slot(ref); + return slot.load(std::memory_order_acquire); + } +#endif + + // __atomic_load is used instead of std::atomic_ref when std::atomic_ref + // is unavailable, or the src pointer is not aligned // https://en.cppreference.com/w/Template:cpp/compiler_support/20 uint64_t r = 0; - __atomic_load( - reinterpret_cast(bd.data + index), &r, __ATOMIC_ACQUIRE); + __atomic_load(src_64, &r, __ATOMIC_ACQUIRE); return r; -#endif } static inline Message message(uint64_t header) diff --git a/tests/e2e_operations.py b/tests/e2e_operations.py index 48344d4138c..7526817c227 100644 --- a/tests/e2e_operations.py +++ b/tests/e2e_operations.py @@ -495,7 +495,6 @@ def run_config_timeout_check(args): env = {} if args.enclave_platform == "snp": env = snp.get_aci_env() - env["ASAN_OPTIONS"] = "alloc_dealloc_mismatch=0" proc = subprocess.Popen( [ @@ -566,7 +565,7 @@ def run_configuration_file_checks(args): for config in config_files_to_check: cmd = [bin_path, f"--config={config}", "--check"] rc = infra.proc.ccall( - *cmd, env={"ASAN_OPTIONS": "alloc_dealloc_mismatch=0"} + *cmd, ).returncode assert rc == 0, f"Failed to check configuration: {rc}" LOG.success(f"Successfully check sample configuration file {config}") diff --git a/tests/infra/remote.py b/tests/infra/remote.py index 2bf52563363..df8244822ec 100644 --- a/tests/infra/remote.py +++ b/tests/infra/remote.py @@ -362,10 +362,7 @@ def __init__( if ubsan_opts: env["UBSAN_OPTIONS"] += ":" + ubsan_opts env["TSAN_OPTIONS"] = os.environ.get("TSAN_OPTIONS", "") - # https://github.com/microsoft/CCF/issues/5198 - env["ASAN_OPTIONS"] = os.environ.get( - "ASAN_OPTIONS", "alloc_dealloc_mismatch=0" - ) + env["ASAN_OPTIONS"] = os.environ.get("ASAN_OPTIONS", "") elif enclave_platform == "snp": env = snp.get_aci_env() snp_security_context_directory_envvar = (