]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/objectstore: hold split_blob cache shards in unique_ptr 69457/head
authorKefu Chai <k.chai@proxmox.com>
Sun, 14 Jun 2026 08:47:59 +0000 (16:47 +0800)
committerKefu Chai <k.chai@proxmox.com>
Tue, 16 Jun 2026 10:10:21 +0000 (18:10 +0800)
ExtentMap.split_blob, added in be93e121a98, creates the onode and buffer cache
shards as raw pointers and never frees them. once we build with ASan,
LeakSanitizer reports them (and the structures they own):

  Direct leak of 9928 byte(s) ... BlueStore::OnodeCacheShard::create
  Direct leak of 224 byte(s) ... BlueStore::BufferCacheShard::create
  SUMMARY: AddressSanitizer: 10288 byte(s) leaked in 8 allocation(s).

every other test in this file already wraps these shards in a unique_ptr,
declared before the collection that borrows them so they outlive it. do
the same here.

Signed-off-by: Kefu Chai <k.chai@proxmox.com>
src/test/objectstore/test_bluestore_types.cc

index 23f7b847f838571e4e4d44acb46caf1bb1aa3e06..c2025a25e1f55589c86cc98d659d475bae3c695e 100644 (file)
@@ -1078,12 +1078,12 @@ TEST(Blob, split) {
 
 TEST(ExtentMap, split_blob) {
   BlueStore store(g_ceph_context, "", 4096);
-  BlueStore::OnodeCacheShard *oc =
-      BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL);
-  BlueStore::BufferCacheShard *bc =
-      BlueStore::BufferCacheShard::create(&store, "lru", NULL);
+  std::unique_ptr<BlueStore::OnodeCacheShard> oc{
+      BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL)};
+  std::unique_ptr<BlueStore::BufferCacheShard> bc{
+      BlueStore::BufferCacheShard::create(&store, "lru", NULL)};
 
-  auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc, bc, coll_t());
+  auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc.get(), bc.get(), coll_t());
   BlueStore::Onode onode(coll.get(), ghobject_t(), "");
   size_t shard_size =
     g_ceph_context->_conf->bluestore_extent_map_inline_shard_prealloc_size;