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

tests: Fix ASAN build on macOS #425

Merged
merged 1 commit into from
Jul 29, 2024
Merged
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
12 changes: 9 additions & 3 deletions tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ if get_option('b_sanitize') == 'address'
endif

# Avoids closing dlopened libraries for ASan to be able to print usable traces
fake_dlclose = shared_module(
fake_dlclose = shared_library(
'fake_dlclose',
'fake_dlclose.c',
name_prefix: '',
Expand All @@ -85,12 +85,18 @@ if get_option('b_sanitize') == 'address'
test_env.set('ASAN_OPTIONS', 'fast_unwind_on_malloc=0')
test_env.set('LSAN_OPTIONS', 'suppressions=@0@/lsan.supp'.format(meson.current_source_dir()))
test_env.set('FAKE_DLCLOSE', fake_dlclose.full_path())

preload_env_var = 'LD_PRELOAD'
if host_machine.system() == 'darwin'
preload_env_var = 'DYLD_INSERT_LIBRARIES'
endif

# LD_PRELOAD is needed before invoking openssl as it is not instrumented with
# asan and asan needs to be loaded as a first dynamic library of the process.
if preload_libasan != 'no'
test_env.set('CHECKER', 'env LD_PRELOAD=@0@:@1@'.format(preload_libasan, fake_dlclose.full_path()))
test_env.set('CHECKER', 'env @0@=@1@:@2@'.format(preload_env_var, preload_libasan, fake_dlclose.full_path()))
else
test_env.set('CHECKER', 'env LD_PRELOAD=@0@'.format(fake_dlclose.full_path()))
test_env.set('CHECKER', 'env @0@=@1@'.format(preload_env_var, fake_dlclose.full_path()))
endif
endif

Expand Down
Loading