Skip to content

Commit

Permalink
DAOS-15799 build: Add libsanitize
Browse files Browse the repository at this point in the history
Add libsanitize for debugging stack smashing occuring on LRZ servers.

WARNIN: When libasan is activated the dlopen is not working properly,
	and the path of the libraries have to be explicitly defined.
	More details on tis can be found at
	https://sourceware.org/bugzilla/show_bug.cgi?id=25114

Skip-test: true
Required-githooks: true

Signed-off-by: Cedric Koch-Hofer <cedric.koch-hofer@intel.com>
  • Loading branch information
kanard38 authored and knard-intel committed Jun 6, 2024
1 parent bf9ac88 commit 855d80e
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 10 deletions.
2 changes: 2 additions & 0 deletions site_scons/prereq_tools/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ def __init__(self, env, opts):
opts.Add(('MPI_PKG', 'Specifies name of pkg-config to load for MPI', None))
opts.Add(BoolVariable('FIRMWARE_MGMT', 'Build in device firmware management.', 0))
opts.Add(BoolVariable('STACK_MMAP', 'Allocate ABT ULTs stacks with mmap()', 0))
opts.Add(BoolVariable('ADDRESS_SANITIZER',
'Instrument C code with the Address Sanitizer library', 0))
opts.Add(EnumVariable('BUILD_TYPE', "Set the build type", 'release',
['dev', 'debug', 'release'], ignorecase=1))
opts.Add(EnumVariable('TARGET_TYPE', "Set the prerequisite type", 'default',
Expand Down
22 changes: 22 additions & 0 deletions site_scons/site_tools/compiler_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ def _base_setup(env):
'-Wall',
'-fpic'])

if env["ADDRESS_SANITIZER"] == 1:
print('Enabling Address Sanitizer')
# Enable Address Sanitizer, a fast memory error detector.
env.Prepend(LINKFLAGS=['-fsanitize=address'])
env.Prepend(CCFLAGS=['-fsanitize=address'])

env.AppendIfSupported(CCFLAGS=DESIRED_FLAGS)

if build_type == 'debug':
Expand Down Expand Up @@ -160,10 +166,26 @@ def _append_if_supported(env, **kwargs):
config.Finish()


def _check_func(env, func_name):
"""Check if a function is usable"""
denv = env.Clone()
if denv["ADDRESS_SANITIZER"] == 1:
# NOTE Remove address sanitizer to not scramble the test output
denv["LINKFLAGS"].remove('-fsanitize=address')
denv["CCFLAGS"].remove('-fsanitize=address')

config = Configure(denv)
res = config.CheckFunc(func_name)
config.Finish()

return res


def generate(env):
"""Add daos specific method to environment"""
env.AddMethod(_base_setup, 'compiler_setup')
env.AddMethod(_append_if_supported, "AppendIfSupported")
env.AddMethod(_check_func, "CheckFunc")


def exists(_env):
Expand Down
4 changes: 1 addition & 3 deletions src/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,10 @@ def scons():
base_env_mpi.AppendUnique(CPPPATH=[Dir('include')])

if not env.GetOption('clean') and not env.GetOption('help'):
conf = env.Clone().Configure()
# Detect if we have explicit_bzero
if not conf.CheckFunc('explicit_bzero'):
if not env.CheckFunc('explicit_bzero'):
env.Append(CCFLAGS=['-DNEED_EXPLICIT_BZERO'])
base_env.Append(CCFLAGS=['-DNEED_EXPLICIT_BZERO'])
conf.Finish()

for header in HEADERS:
header_file = os.path.join('include', header)
Expand Down
2 changes: 1 addition & 1 deletion src/client/dfs/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def configure_lustre(denv):
print("No installed Lustre version detected")
else:
print("Installed Lustre version detected")
if not conf.CheckFunc('llapi_unlink_foreign'):
if not denv.CheckFunc('llapi_unlink_foreign'):
print("Lustre version is not compatible")
else:
print("Lustre version is compatible")
Expand Down
3 changes: 2 additions & 1 deletion src/control/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def get_build_flags(benv):
"""Return string of build flags"""
if is_release_build(benv):
return '-buildmode=pie'
# enable race detector for non-release builds
if benv["ADDRESS_SANITIZER"] == 1:
return '-asan'
return '-race'


Expand Down
8 changes: 4 additions & 4 deletions utils/ansible/ftest/templates/daos-make.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ run $CLUSH_EXE $CLUSH_OPTS -l root -w $CLIENTS_LIST chmod 755 /usr/bin/dfuse
info "Updating dynamic linker configuration"
{% if "daos_clients" in groups and groups["daos_clients"] | length > 0 %}
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST rm -f /etc/ld.so.cache
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST ldconfig
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST ldconfig $DAOS_INSTALL_DIR/lib64 $DAOS_INSTALL_DIR/lib64/daos_srv
{% else %}
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST rm -f /etc/ld.so.cache
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST ldconfig
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST ldconfig $DAOS_INSTALL_DIR/lib64 $DAOS_INSTALL_DIR/lib64/daos_srv
{% endif %}

if [[ $MPICH_PATH ]] ; then
Expand Down Expand Up @@ -542,8 +542,8 @@ fi
info "Updating dynamic linker configuration"
{% if "daos_clients" in groups and groups["daos_clients"] | length > 0 %}
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST rm -f /etc/ld.so.cache
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST ldconfig
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST -w $CLIENTS_LIST ldconfig $DAOS_INSTALL_DIR/lib64 $DAOS_INSTALL_DIR/lib64/daos_srv
{% else %}
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST rm -f /etc/ld.so.cache
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST ldconfig
run $CLUSH_EXE $CLUSH_OPTS -l root -w $SERVERS_LIST ldconfig $DAOS_INSTALL_DIR/lib64 $DAOS_INSTALL_DIR/lib64/daos_srv
{% endif %}
13 changes: 12 additions & 1 deletion utils/rpms/daos.spec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

Name: daos
Version: 2.4.2
Release: 4%{?relval}%{?dist}
Release: 5%{?relval}%{?dist}
Summary: DAOS Storage Engine

License: BSD-2-Clause-Patent
Expand Down Expand Up @@ -114,6 +114,14 @@ BuildRequires: libuct-devel
BuildRequires: ucx-devel
%endif

# Needed for support tasks
%if (0%{?rhel} >= 8)
BuildRequires: libasan
%endif
%if (0%{?suse_version} > 0)
BuildRequires: libasan8
%endif

Requires: openssl
# This should only be temporary until we can get a stable upstream release
# of mercury, at which time the autoprov shared library version should
Expand Down Expand Up @@ -555,6 +563,9 @@ getent passwd daos_agent >/dev/null || useradd -s /sbin/nologin -r -g daos_agent
# No files in a shim package

%changelog
* Fri May 31 2024 Cedric Koch-Hofer <cedric.koch-hofer@intel.com> 2.4.2-5
- Support release candidate for 2.4.2

* Mon Mar 04 2024 Phillip Henderson <phillip.henderson@intel.com> 2.4.2-4
- Third release candidate for 2.4.2

Expand Down
1 change: 1 addition & 0 deletions utils/scripts/install-el8.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dnf --nodocs install \
java-1.8.0-openjdk \
json-c-devel \
libaio-devel \
libasan \
libcmocka-devel \
libevent-devel \
libiscsi-devel \
Expand Down
1 change: 1 addition & 0 deletions utils/scripts/install-el9.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dnf --nodocs install \
java-1.8.0-openjdk \
json-c-devel \
libaio-devel \
libasan \
libcmocka-devel \
libevent-devel \
libipmctl-devel \
Expand Down
1 change: 1 addition & 0 deletions utils/scripts/install-leap15.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dnf --nodocs install \
hwloc-devel \
java-1_8_0-openjdk-devel \
libaio-devel \
libasan8 \
libcmocka-devel \
libcapstone-devel \
libevent-devel \
Expand Down
1 change: 1 addition & 0 deletions utils/scripts/install-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ apt-get install \
golang-go \
kmod \
libaio-dev \
libasan8 \
libboost-dev \
libcapstone-dev \
libcmocka-dev \
Expand Down
4 changes: 4 additions & 0 deletions utils/sl/fake_scons/SCons/Script/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ def require(self, env, *kw, headers_only=False):
"""Fake require"""
return

def CheckFunc(self, func_name):
"""Fake CheckFunc"""
return


class Variables():
"""Fake variables"""
Expand Down

0 comments on commit 855d80e

Please sign in to comment.