ceph-mirror/qa/lsan.supp
Kefu Chai b827a7113a rgw/dbstore: fix memory leaks in unittest_dbstore_tests
Fix memory leaks detected by AddressSanitizer in unittest_dbstore_tests.
The test was failing with ASan enabled due to SQLObjectOp objects not
being properly cleaned up.

ASan reported the following leaks:

  Direct leak of 200 byte(s) in 1 object(s) allocated from:
    #0 operator new(unsigned long)
    #1 SQLGetBucket::Execute(DoutPrefixProvider const*, rgw::store::DBOpParams*)
       /src/rgw/driver/dbstore/sqlite/sqliteDB.cc:1689
    #2 rgw::store::DB::ProcessOp(DoutPrefixProvider const*, ...)
       /src/rgw/driver/dbstore/common/dbstore.cc:258

  Direct leak of 200 byte(s) in 1 object(s) allocated from:
    #0 operator new(unsigned long)
    #1 SQLInsertBucket::Execute(DoutPrefixProvider const*, rgw::store::DBOpParams*)
       /src/rgw/driver/dbstore/sqlite/sqliteDB.cc:1433
    #2 rgw::store::DB::ProcessOp(DoutPrefixProvider const*, ...)
       /src/rgw/driver/dbstore/common/dbstore.cc:258

  SUMMARY: AddressSanitizer: 460550 byte(s) leaked in 1823 allocation(s).

Root cause: The DB::Destroy() method had an early return when the db
pointer was NULL, preventing cleanup of the objectmap which stores
SQLObjectOp pointers. These objects were allocated during test execution
but never freed.

Changes:
- Modified DB::Destroy() to always clean up objectmap even when db is NULL
- Added explicit delete in objectmapDelete() for consistency
- Added lsan suppression for SQLite internal allocations (indirect leaks)

After the fix, all direct leaks are eliminated. Only indirect leaks from
SQLite's internal memory management remain, which are now suppressed.

Test results:
- Before: 460,550 bytes leaked (including 2 direct leaks of 200 bytes each)
- After: 0 direct leaks, unittest_dbstore_tests passes with ASan

Signed-off-by: Kefu Chai <k.chai@proxmox.com>
2026-01-09 13:20:29 +08:00

41 lines
1.1 KiB
Plaintext

# leak suppressions needed to run vstart.sh with WITH_ASAN=ON
# to enable, add this to the environment:
# LSAN_OPTIONS="suppressions=../qa/lsan.supp"
# export ASAN_OPTIONS="detect_odr_violation=0"
# gperftools allocates a singleton of MallocExtension and never frees it
leak:^MallocExtension::Initialize
# from perfglue/heap_profiler.cc
# gperftools allocates a singleton and never frees it
leak:^InitModule
# from src/ceph.in
# python3.6
leak:^_PyObject_Alloc
leak:^_PyObject_GC_Resize
leak:^PyBytes_FromStringAndSize
leak:^PyType_GenericAlloc
leak:^set_table_resize
# python3.7
leak:^_PyObject_Realloc
leak:^PyObject_Malloc
# python3.8
leak:^_PyBytes_FromSize
leak:^_PyObject_GC_Alloc
leak:^PyMem_Calloc
leak:^PyUnicode_New
# python3.9, 3.10, 3.11
leak:^PyMem_Malloc
# python3.12 doesn't leak anything
# python3.13
leak:^PyModule_ExecDef
# following suppression mirrors qa/valgrind.supp
# ignore ec plugin factory (FIXME SOMEDAY)
leak:^ceph::ErasureCodePluginRegistry::load
# SQLite internal allocations
# These are indirect leaks from SQLite's internal memory management
leak:libsqlite3.so