Skip to content

Fix memleak in glusterd mgmt handshake #4559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from

Conversation

chen1195585098
Copy link
Contributor

asan reports:

Direct leak of 4386 byte(s) in 34 object(s) allocated from:
    #0 0x7ff3b72efbb8 in __interceptor_malloc (/lib64/libasan.so.5+0xefbb8)
    #1 0x7ff3b6902420 in __gf_malloc (/lib64/libglusterfs.so.0+0x102420)
    #2 0x7ff3b6876e18 in dict_allocate_and_serialize (/lib64/libglusterfs.so.0+0x76e18)
    #3 0x7ff3aa5ec701 in glusterd_mgmt_handshake glusterd-handshake.c:2212
    #4 0x7ff3aa5ee2cc in __glusterd_peer_dump_version_cbk glusterd-handshake.c:2388
    #5 0x7ff3aa5b58ca in glusterd_big_locked_cbk glusterd-rpc-ops.c:217
    #6 0x7ff3b642ffcb in rpc_clnt_handle_reply rpc-clnt.c:780
    #7 0x7ff3b64307e9 in rpc_clnt_notify rpc-clnt.c:957
    #8 0x7ff3b6425c2c in rpc_transport_notify (/lib64/libgfrpc.so.0+0x25c2c)
    #9 0x7ff3a880d874 in socket_event_poll_in_async socket.c:2531
    #10 0x7ff3a882828e in socket_event_poll_in ../../../../libglusterfs/src/glusterfs/async.h:189
    #11 0x7ff3a882828e in socket_event_handler socket.c:2963
    #12 0x7ff3a882828e in socket_event_handler socket.c:2883
    #13 0x7ff3b69af776 in event_dispatch_epoll_handler event-epoll.c:640
    #14 0x7ff3b69af776 in event_dispatch_epoll_worker event-epoll.c:751
    #15 0x7ff3b48082fe in start_thread pthread_create.c:479
    #16 0x7ff3b3e39dd2 in __GI___clone (/lib64/libc.so.6+0x39dd2)

By the way, size in mem_acct data struct, which indicates total size allocated for data-type, is not updated correctly.
size will increase when GF_MALLOC is called, however, it never get a decreasement in GF_FREE.
Should fix it here, otherwise the wrong size may mislead mempool memleak anlysis.

chenjinhao added 2 commits June 9, 2025 14:43
asan reports:
Direct leak of 4386 byte(s) in 34 object(s) allocated from:
    #0 0x7ff3b72efbb8 in __interceptor_malloc (/lib64/libasan.so.5+0xefbb8)
    gluster#1 0x7ff3b6902420 in __gf_malloc (/lib64/libglusterfs.so.0+0x102420)
    gluster#2 0x7ff3b6876e18 in dict_allocate_and_serialize (/lib64/libglusterfs.so.0+0x76e18)
    gluster#3 0x7ff3aa5ec701 in glusterd_mgmt_handshake glusterd-handshake.c:2212
    gluster#4 0x7ff3aa5ee2cc in __glusterd_peer_dump_version_cbk glusterd-handshake.c:2388
    gluster#5 0x7ff3aa5b58ca in glusterd_big_locked_cbk glusterd-rpc-ops.c:217
    gluster#6 0x7ff3b642ffcb in rpc_clnt_handle_reply rpc-clnt.c:780
    gluster#7 0x7ff3b64307e9 in rpc_clnt_notify rpc-clnt.c:957
    gluster#8 0x7ff3b6425c2c in rpc_transport_notify (/lib64/libgfrpc.so.0+0x25c2c)
    gluster#9 0x7ff3a880d874 in socket_event_poll_in_async socket.c:2531
    gluster#10 0x7ff3a882828e in socket_event_poll_in ../../../../libglusterfs/src/glusterfs/async.h:189
    gluster#11 0x7ff3a882828e in socket_event_handler socket.c:2963
    gluster#12 0x7ff3a882828e in socket_event_handler socket.c:2883
    gluster#13 0x7ff3b69af776 in event_dispatch_epoll_handler event-epoll.c:640
    gluster#14 0x7ff3b69af776 in event_dispatch_epoll_worker event-epoll.c:751
    gluster#15 0x7ff3b48082fe in start_thread pthread_create.c:479
    gluster#16 0x7ff3b3e39dd2 in __GI___clone (/lib64/libc.so.6+0x39dd2)

Fixes: gluster#4558
Signed-off-by: chenjinhao <chen.jinhao@zte.com.cn>
size in mem_acct data struct, which indicates total size allocated
for data-type, is not updated correctly.

size will increase when GF_MALLOC is called, however, it never get
a decreasement in GF_FREE.

So fix it here, otherwise the wrong size may mislead mempool memleak anlysis.

Fixes: gluster#4558
Signed-off-by: chenjinhao <chen.jinhao@zte.com.cn>
@gluster-ant
Copy link
Collaborator

Can one of the admins verify this patch?

1 similar comment
@gluster-ant
Copy link
Collaborator

Can one of the admins verify this patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants