From 8e2a4e4adb27f2dd1480da0230c0671c2cbced75 Mon Sep 17 00:00:00 2001 From: Li Wei Date: Tue, 6 Aug 2024 20:22:13 +0900 Subject: [PATCH] DAOS-16251 misc: Debug memory access issues A messy hack (WIP)... Signed-off-by: Li Wei Required-githooks: true --- site_scons/site_tools/compiler_setup.py | 11 +++++++++-- src/control/SConscript | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/site_scons/site_tools/compiler_setup.py b/site_scons/site_tools/compiler_setup.py index 9f25ccace719..eb464ed248ba 100644 --- a/site_scons/site_tools/compiler_setup.py +++ b/site_scons/site_tools/compiler_setup.py @@ -3,6 +3,9 @@ from SCons.Script import Configure, Exit, GetOption DESIRED_FLAGS = ['-fstack-usage', + '-fsanitize=address', + '-Wl,-fsanitize=address', + '-fno-omit-frame-pointer', '-Wno-sign-compare', '-Wno-unused-parameter', '-Wno-missing-field-initializers', @@ -12,8 +15,8 @@ '-Wno-tautological-constant-out-of-range-compare', '-Wno-unused-command-line-argument', '-Wmismatched-dealloc', - '-Wfree-nonheap-object', - '-Wframe-larger-than=4096'] + '-Wfree-nonheap-object'] +# '-Wframe-larger-than=4096'] # Compiler flags to prevent optimizing out security checks DESIRED_FLAGS.extend(['-fno-strict-overflow', '-fno-delete-null-pointer-checks', '-fwrapv']) @@ -53,6 +56,10 @@ def _base_setup(env): env.Append(CCFLAGS=['-g', '-Wextra', '-Wshadow', '-Wall', '-fpic']) env.AppendIfSupported(CCFLAGS=DESIRED_FLAGS) + env.AppendIfSupported(LDFLAGS=['-fsanitize=address']) + env.AppendIfSupported(LINKFLAGS=['-fsanitize=address']) + env.AppendIfSupported(CGO_CFLAGS=['-fsanitize=address']) + env.AppendIfSupported(CGO_LDFLAGS=['-fsanitize=address']) if '-Wmismatched-dealloc' in env['CCFLAGS']: env.AppendUnique(CPPDEFINES={'HAVE_DEALLOC': '1'}) diff --git a/src/control/SConscript b/src/control/SConscript index 54ce6dd8b9dd..ca440ba2a39b 100644 --- a/src/control/SConscript +++ b/src/control/SConscript @@ -36,7 +36,7 @@ def get_build_flags(benv): if is_release_build(benv): return '-buildmode=pie' # enable race detector for non-release builds - return '-race' + return '' def gen_build_id(): @@ -127,6 +127,8 @@ def scons(): # Sets CGO_LDFLAGS for rpath options denv.d_add_rpaths("..", True, True) denv.AppendENVPath("CGO_CFLAGS", denv.subst("$_CPPINCFLAGS"), sep=" ") + denv.AppendENVPath("CGO_CFLAGS", "-fsanitize=address", sep=" ") + denv.AppendENVPath("CGO_LDFLAGS", "-fsanitize=address", sep=" ") if prereqs.client_requested(): install_go_bin(denv, "daos_agent") install_go_bin(denv, "dmg", install_man=True)