Skip to content

Commit 32c4cdd

Browse files
Use libstdc++ in ASAN (#6753)
Co-authored-by: Amaury Chamayou <[email protected]>
1 parent ae481ce commit 32c4cdd

File tree

8 files changed

+19
-32
lines changed

8 files changed

+19
-32
lines changed

.azure-pipelines-templates/daily-matrix.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ parameters:
3333
cmake_args: "-DCMAKE_BUILD_TYPE=Debug"
3434
cmake_env: ""
3535
ASAN:
36-
cmake_args: "-DSAN=ON"
36+
cmake_args: "-DSAN=ON -DUSE_LIBCXX=OFF"
3737
cmake_env: ""
3838
TSAN:
3939
cmake_args: "-DTSAN=ON -DWORKER_THREADS=2"

.github/workflows/long-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
git config --global --add safe.directory "$GITHUB_WORKSPACE"
5454
mkdir build
5555
cd build
56-
cmake -GNinja -DCOMPILE_TARGET=virtual -DCMAKE_BUILD_TYPE=Debug -DLONG_TESTS=ON -DSAN=ON ..
56+
cmake -GNinja -DCOMPILE_TARGET=virtual -DCMAKE_BUILD_TYPE=Debug -DLONG_TESTS=ON -DSAN=ON -DUSE_LIBCXX=OFF ..
5757
ninja
5858
5959
- name: "Test"

CMakeLists.txt

-7
Original file line numberDiff line numberDiff line change
@@ -929,13 +929,6 @@ if(BUILD_TESTS)
929929
PROPERTY LABELS unit_test
930930
)
931931

932-
# https://github.com/microsoft/CCF/issues/5198
933-
set_property(
934-
TEST csr_test
935-
APPEND
936-
PROPERTY ENVIRONMENT "ASAN_OPTIONS=alloc_dealloc_mismatch=0"
937-
)
938-
939932
add_test(NAME versionifier_test
940933
COMMAND ${PYTHON}
941934
${CMAKE_SOURCE_DIR}/python/src/ccf/_versionifier.py

cmake/common.cmake

-7
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ function(add_unit_test name)
2626
"TSAN_OPTIONS=suppressions=${CCF_DIR}/tsan_env_suppressions"
2727
)
2828

29-
# https://github.com/microsoft/CCF/issues/5198
30-
set_property(
31-
TEST ${name}
32-
APPEND
33-
PROPERTY ENVIRONMENT "ASAN_OPTIONS=alloc_dealloc_mismatch=0"
34-
)
35-
3629
endfunction()
3730

3831
# Test binary wrapper

include/ccf/http_accept.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace ccf::http
4646
bool operator<(const AcceptHeaderField& other) const
4747
{
4848
static constexpr auto float_comp_epsilon = 0.0000001f;
49-
if (abs(q_factor - other.q_factor) > float_comp_epsilon)
49+
if (std::abs(q_factor - other.q_factor) > float_comp_epsilon)
5050
{
5151
return q_factor < other.q_factor;
5252
}

src/ds/ring_buffer.h

+14-9
Original file line numberDiff line numberDiff line change
@@ -145,19 +145,24 @@ namespace ringbuffer
145145
{
146146
static inline uint64_t read64_impl(const BufferDef& bd, size_t index)
147147
{
148+
auto src = bd.data + index;
149+
auto src_64 = reinterpret_cast<uint64_t*>(src);
150+
148151
#ifdef __cpp_lib_atomic_ref
149-
auto& ref = *(reinterpret_cast<uint64_t*>(bd.data + index));
150-
std::atomic_ref<uint64_t> slot(ref);
151-
return slot.load(std::memory_order_acquire);
152-
#else
153-
// __atomic_load is used instead of std::atomic_ref since it's not
154-
// supported by libc++ yet.
152+
if (Const::is_aligned(src, 8))
153+
{
154+
auto& ref = *src_64;
155+
std::atomic_ref<uint64_t> slot(ref);
156+
return slot.load(std::memory_order_acquire);
157+
}
158+
#endif
159+
160+
// __atomic_load is used instead of std::atomic_ref when std::atomic_ref
161+
// is unavailable, or the src pointer is not aligned
155162
// https://en.cppreference.com/w/Template:cpp/compiler_support/20
156163
uint64_t r = 0;
157-
__atomic_load(
158-
reinterpret_cast<uint64_t*>(bd.data + index), &r, __ATOMIC_ACQUIRE);
164+
__atomic_load(src_64, &r, __ATOMIC_ACQUIRE);
159165
return r;
160-
#endif
161166
}
162167

163168
static inline Message message(uint64_t header)

tests/e2e_operations.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,6 @@ def run_config_timeout_check(args):
495495
env = {}
496496
if args.enclave_platform == "snp":
497497
env = snp.get_aci_env()
498-
env["ASAN_OPTIONS"] = "alloc_dealloc_mismatch=0"
499498

500499
proc = subprocess.Popen(
501500
[
@@ -566,7 +565,7 @@ def run_configuration_file_checks(args):
566565
for config in config_files_to_check:
567566
cmd = [bin_path, f"--config={config}", "--check"]
568567
rc = infra.proc.ccall(
569-
*cmd, env={"ASAN_OPTIONS": "alloc_dealloc_mismatch=0"}
568+
*cmd,
570569
).returncode
571570
assert rc == 0, f"Failed to check configuration: {rc}"
572571
LOG.success(f"Successfully check sample configuration file {config}")

tests/infra/remote.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,7 @@ def __init__(
362362
if ubsan_opts:
363363
env["UBSAN_OPTIONS"] += ":" + ubsan_opts
364364
env["TSAN_OPTIONS"] = os.environ.get("TSAN_OPTIONS", "")
365-
# https://github.com/microsoft/CCF/issues/5198
366-
env["ASAN_OPTIONS"] = os.environ.get(
367-
"ASAN_OPTIONS", "alloc_dealloc_mismatch=0"
368-
)
365+
env["ASAN_OPTIONS"] = os.environ.get("ASAN_OPTIONS", "")
369366
elif enclave_platform == "snp":
370367
env = snp.get_aci_env()
371368
snp_security_context_directory_envvar = (

0 commit comments

Comments
 (0)