]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/osd: add embedded suppression ruleset for LSan
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 15 Mar 2023 09:40:15 +0000 (09:40 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Wed, 11 Oct 2023 10:52:05 +0000 (10:52 +0000)
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 <rzarzyns@redhat.com>
(cherry picked from commit 6ed8d839b421442a64410444ca8f88f157ae28b3)

src/crimson/osd/CMakeLists.txt
src/crimson/osd/lsan_suppressions.cc [new file with mode: 0644]

index 4b24b5a654ca9fb036e2703264d345b2d5c17baa..f521e0244d7a3e6afd1c0506b577498a8b0fb323 100644 (file)
@@ -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 (file)
index 0000000..19ad4ec
--- /dev/null
@@ -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