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>
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)