]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph.in: load asan/lsan suppressions on WITH_ASAN builds
authorKefu Chai <k.chai@proxmox.com>
Tue, 23 Jun 2026 08:14:19 +0000 (16:14 +0800)
committerKefu Chai <k.chai@proxmox.com>
Tue, 23 Jun 2026 15:02:05 +0000 (23:02 +0800)
bin/ceph from a WITH_ASAN build aborts at exit, with LeakSanitizer reporting
CPython and Cython module-init allocations as leaks:

  ==2577940==ERROR: LeakSanitizer: detected memory leaks
  Direct leak ... in PyObject_Malloc (/usr/bin/python3.12+...)
    #4 __pyx_pymod_exec_rados rados_processed.c
  SUMMARY: AddressSanitizer: 32113 byte(s) leaked in 30 allocation(s).

These are interpreter globals that live for the process lifetime.  qa/lsan.supp
already suppresses them, but bin/ceph never loaded it: vstart.sh sets
LSAN_OPTIONS for the daemons it spawns, while a bin/ceph invoked separately
(ceph-api runs ./bin/ceph fsid once vstart.sh returns) inherits none and exits
non-zero.  It stayed hidden until radosgw-admin stopped crashing in vstart and
the run reached that call.

ceph.in already re-execs with the ASan runtime preloaded under WITH_ASAN.  Set
ASAN_OPTIONS and LSAN_OPTIONS first, from the CEPH_ASAN_OPTIONS and
CEPH_LSAN_OPTIONS that CMake also feeds add_ceph_test(), so the re-exec'd
interpreter starts with the suppressions loaded.  Use setdefault so a value
from the caller still wins.

Signed-off-by: Kefu Chai <k.chai@proxmox.com>
src/ceph.in

index 4694da29db5fea32f5f6e7986920b60037d710d1..069888422c020ce5dd8eb0a81459362ad44172fe 100755 (executable)
@@ -140,6 +140,13 @@ if os.path.exists(os.path.join(MYPDIR, "CMakeCache.txt")) \
         pythonlib_path = os.path.join(lib_path,
                                       "cython_modules",
                                       get_pythonlib_dir())
+        if with_asan:
+            # respawn_in_path() below re-execs with the ASan runtime preloaded.
+            # Load the same suppression options add_ceph_test() uses (configured
+            # by CMake) first, so the re-exec'd interpreter does not report
+            # CPython/Cython module-init allocations as leaks at exit.
+            os.environ.setdefault("ASAN_OPTIONS", "@CEPH_ASAN_OPTIONS@")
+            os.environ.setdefault("LSAN_OPTIONS", "@CEPH_LSAN_OPTIONS@")
         respawn_in_path(lib_path, pybind_path, pythonlib_path,
                         asan_lib_path if with_asan else None)