From 1e80b6b14a4344c934395b6036c094f0e38d7af2 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 13 May 2024 08:11:10 +0800 Subject: [PATCH] tools/ceph-dencoder: unregister dencoders in dtor we have leak reports from ASan like ``` Direct leak of 512 byte(s) in 1 object(s) allocated from: #0 0x557c5ca1aa88 in __interceptor_calloc (/home/jenkins-build/build/workspace/ceph-pull-requests/build/bin/ceph-dencoder+0xc0a88) (BuildId: 0431ba72332bcadbbda97c424e0d5e66a10e88d7) #1 0x7f3093a4e7e5 () Direct leak of 464 byte(s) in 1 object(s) allocated from: #0 0x557c5ca1aa88 in __interceptor_calloc (/home/jenkins-build/build/workspace/ceph-pull-requests/build/bin/ceph-dencoder+0xc0a88) (BuildId: 0431ba72332bcadbbda97c424e0d5e66a10e88d7) #1 0x7f3093a5de3e () Direct leak of 248 byte(s) in 1 object(s) allocated from: #0 0x557c5ca1aa88 in __interceptor_calloc (/home/jenkins-build/build/workspace/ceph-pull-requests/build/bin/ceph-dencoder+0xc0a88) (BuildId: 0431ba72332bcadbbda97c424e0d5e66a10e88d7) #1 0x7f30939e05a9 () Direct leak of 48 byte(s) in 1 object(s) allocated from: #0 0x557c5ca5566d in operator new(unsigned long) (/home/jenkins-build/build/workspace/ceph-pull-requests/build/bin/ceph-dencoder+0xfb66d) (BuildId: 0431ba72332bcadbbda97c424e0d5e66a10e88d7) #1 0x7f3094c27087 () #2 0x7f3094c21d64 () #3 0x557c5ca680bb in DencoderPlugin::register_dencoders[abi:cxx11]() /home/jenkins-build/build/workspace/ceph-pull-requests/src/tools/ceph-dencoder/denc_plugin.h:44:5 #4 0x557c5ca5f9ea in main /home/jenkins-build/build/workspace/ceph-pull-requests/src/tools/ceph-dencoder/ceph_dencoder.cc:100:38 #5 0x7f309f33ad8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16 Direct leak of 48 byte(s) in 1 object(s) allocated from: #0 0x557c5ca5566d in operator new(unsigned long) (/home/jenkins-build/build/workspace/ceph-pull-requests/build/bin/ceph-dencoder+0xfb66d) (BuildId: 0431ba72332bcadbbda97c424e0d5e66a10e88d7) #1 0x7f308c91f257 () #2 0x7f308c8fd0df () #3 0x557c5ca680bb in DencoderPlugin::register_dencoders[abi:cxx11]() /home/jenkins-build/build/workspace/ceph-pull-requests/src/tools/ceph-dencoder/denc_plugin.h:44:5 #4 0x557c5ca5f9ea in main /home/jenkins-build/build/workspace/ceph-pull-requests/src/tools/ceph-dencoder/ceph_dencoder.cc:100:38 #5 0x7f309f33ad8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16 ``` it turns out the dencoders allocated by `register_dencoders()` are never unregistered, so let's do the proper cleanup when done with the dencoders. Signed-off-by: Kefu Chai --- src/tools/ceph-dencoder/denc_plugin.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/ceph-dencoder/denc_plugin.h b/src/tools/ceph-dencoder/denc_plugin.h index e43ad26e174f6..c5eacce47cb43 100644 --- a/src/tools/ceph-dencoder/denc_plugin.h +++ b/src/tools/ceph-dencoder/denc_plugin.h @@ -23,6 +23,7 @@ class DencoderPlugin { other.dencoders.clear(); } ~DencoderPlugin() { + unregister_dencoders(); #if !defined(__FreeBSD__) if (mod) { dlclose(mod);