From 11a2ae1822bee56e40ee3151c3a7da9bbadef25b Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Wed, 15 Mar 2023 09:40:15 +0000 Subject: [PATCH] crimson/osd: add embedded suppression ruleset for LSan This commit, basing the idea from the Chromium browser, embdeds the suppression rules directly into the crimson executable. The benefit is simplicity and no need to modify the teuthology code to ship a file across all involved nodes like already happens for `valgrind.supp`. From `teuthology/task/install/util.py`: ``` def _ship_utilities(ctx): """ Write a copy of valgrind.supp to each of the remote sites. Set executables used by Ceph in /usr/local/bin. When finished (upon exit of the teuthology run), remove these files. :param ctx: Context """ testdir = teuthology.get_testdir(ctx) filenames = [] log.info('Shipping valgrind.supp...') assert 'suite_path' in ctx.config try: with open( os.path.join(ctx.config['suite_path'], 'valgrind.supp'), 'rb' ) as f: fn = os.path.join(testdir, 'valgrind.supp') filenames.append(fn) for rem in ctx.cluster.remotes.keys(): teuthology.sudo_write_file( remote=rem, path=fn, data=f, ) f.seek(0) except IOError as e: log.info('Cannot ship supression file for valgrind: %s...', e.strerror) ``` With these suppressions `--mkfs` with crimson, BlueStore and tcmalloc starts returning the proper exit code: ``` [rzarzynski@o06 build]$ /home/rzarzynski/ceph1/build/bin/crimson-osd -i 0 -c /home/rzarzynski/ceph1/build/ceph.conf --mkfs --key AQCZsRBkM5CPIBAACmCbEiP3DPh+x9iiaRDZmA== --osd-uuid c3d4aea0-02de-459b-ad00-fe943906a9a8 --cpuset 0-0 ... created object store /home/rzarzynski/ceph1/build/dev/osd0 for osd.0 fsid 8c9aa852-1ba2-4800-9695-e0be4bf877dc ----------------------------------------------------- Suppressions used: count bytes template 1 8 InitModule ----------------------------------------------------- [rzarzynski@o06 build]$ echo $? 0 ``` Signed-off-by: Radoslaw Zarzynski (cherry picked from commit 6ed8d839b421442a64410444ca8f88f157ae28b3) --- src/crimson/osd/CMakeLists.txt | 1 + src/crimson/osd/lsan_suppressions.cc | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/crimson/osd/lsan_suppressions.cc diff --git a/src/crimson/osd/CMakeLists.txt b/src/crimson/osd/CMakeLists.txt index 4b24b5a654c..f521e0244d7 100644 --- a/src/crimson/osd/CMakeLists.txt +++ b/src/crimson/osd/CMakeLists.txt @@ -2,6 +2,7 @@ add_executable(crimson-osd backfill_state.cc ec_backend.cc heartbeat.cc + lsan_suppressions.cc main.cc main_config_bootstrap_helpers.cc osd.cc diff --git a/src/crimson/osd/lsan_suppressions.cc b/src/crimson/osd/lsan_suppressions.cc new file mode 100644 index 00000000000..19ad4ece59f --- /dev/null +++ b/src/crimson/osd/lsan_suppressions.cc @@ -0,0 +1,18 @@ +#ifndef _NDEBUG +// The callbacks we define here will be called from the sanitizer runtime, but +// aren't referenced from the Chrome executable. We must ensure that those +// callbacks are not sanitizer-instrumented, and that they aren't stripped by +// the linker. +#define SANITIZER_HOOK_ATTRIBUTE \ + extern "C" \ + __attribute__((no_sanitize("address", "thread", "undefined"))) \ + __attribute__((visibility("default"))) \ + __attribute__((used)) + +static char kLSanDefaultSuppressions[] = + "leak:InitModule\n"; + +SANITIZER_HOOK_ATTRIBUTE const char *__lsan_default_suppressions() { + return kLSanDefaultSuppressions; +} +#endif // ! _NDEBUG -- 2.39.5