Bug 1036102

Summary: glusterfsd: memory leak in glusterfs_volfile_fetch()
Product: [Community] GlusterFS Reporter: Kaleb KEITHLEY <kkeithle>
Component: coreAssignee: Kaleb KEITHLEY <kkeithle>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: mainlineCC: gluster-bugs
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: glusterfs-3.4.3 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-04-17 13:15:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Kaleb KEITHLEY 2013-11-29 12:52:24 UTC
found with valgrind

diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c
index bbfc505..0484779 100644
--- a/glusterfsd/src/glusterfsd-mgmt.c
+++ b/glusterfsd/src/glusterfsd-mgmt.c
@@ -1456,7 +1456,12 @@ glusterfs_volfile_fetch (glusterfs_ctx_t *ctx)
         ret = mgmt_submit_request (&req, frame, ctx, &clnt_handshake_prog,
                                    GF_HNDSK_GETSPEC, mgmt_getspec_cbk,
                                    (xdrproc_t)xdr_gf_getspec_req);
+
 out:
+        GF_FREE (req.xdata.xdata_val);
+        if (dict)
+                dict_unref (dict);
+
         return ret;
 }

Comment 1 Anand Avati 2013-11-29 12:54:11 UTC
REVIEW: http://review.gluster.org/6363 (glusterfsd: fix small memory leaks in glusterfsd-mgmt.c) posted (#5) for review on master by Kaleb KEITHLEY (kkeithle)

Comment 2 Anand Avati 2013-11-29 13:09:12 UTC
REVIEW: http://review.gluster.org/6381 (glusterfsd: fix small memory leaks in glusterfsd-mgmt.c) posted (#1) for review on release-3.4 by Kaleb KEITHLEY (kkeithle)

Comment 3 Anand Avati 2013-11-29 13:14:27 UTC
REVIEW: http://review.gluster.org/6382 (glusterfsd: fix small memory leaks in glusterfsd-mgmt.c) posted (#1) for review on master by Kaleb KEITHLEY (kkeithle)

Comment 4 Anand Avati 2013-11-29 13:18:27 UTC
REVIEW: http://review.gluster.org/6383 (glusterfsd: fix small memory leak in glusterfsd-mgmt.c) posted (#1) for review on master by Kaleb KEITHLEY (kkeithle)

Comment 5 Anand Avati 2013-11-29 13:24:37 UTC
REVIEW: http://review.gluster.org/6384 (glusterfsd: fix small memory leaks in glusterfsd-mgmt.c) posted (#1) for review on release-3.5 by Kaleb KEITHLEY (kkeithle)

Comment 6 Anand Avati 2013-11-30 18:12:50 UTC
COMMIT: http://review.gluster.org/6363 committed in master by Vijay Bellur (vbellur) 
------
commit 72f733a64abeffee23fb87a3cb397baea1dc22a4
Author: Kaleb S. KEITHLEY <kkeithle>
Date:   Tue Nov 26 14:23:08 2013 -0500

    glusterfsd: fix small memory leaks in glusterfsd-mgmt.c
    
    E.g. In glusterfs_volfile_fetch(), req.xdata.xdata_val is allocated
    in dict_allocate_and_serialize() but not freed after mgmt_submit_request().
    
    A survey of dict_allocate_and_serialize/_submit_request in
    glusterfsd-mgmt.c shows no consistent pattern of freeing the xdata_val
    and also the dict, which is a little disturbing. (Yes, clearly not
    every place this occurs needs to be freed the same way.)
    
    Change-Id: Ic306d60b157e97c822a562bfdf21896e40db632a
    BUG: 1036102
    Signed-off-by: Kaleb S. KEITHLEY <kkeithle>
    Reviewed-on: http://review.gluster.org/6363
    Tested-by: Gluster Build System <jenkins.com>
    Reviewed-by: Vijay Bellur <vbellur>

Comment 7 Anand Avati 2013-11-30 18:16:36 UTC
COMMIT: http://review.gluster.org/6384 committed in release-3.5 by Vijay Bellur (vbellur) 
------
commit 20c5d47ef62b94330f1335a1c403406e9ad636d4
Author: Kaleb S. KEITHLEY <kkeithle>
Date:   Fri Nov 29 08:23:47 2013 -0500

    glusterfsd: fix small memory leaks in glusterfsd-mgmt.c
    
    E.g. In glusterfs_volfile_fetch(), req.xdata.xdata_val is allocated
    in dict_allocate_and_serialize() but not freed after mgmt_submit_request().
    
    A survey of dict_allocate_and_serialize/_submit_request in
    glusterfsd-mgmt.c shows no consistent pattern of freeing the xdata_val
    and also the dict, which is a little disturbing. (Yes, clearly not
    every place this occurs needs to be freed the same way.)
    
    Change-Id: Id3f81346c0c863fa06c7b780a634e9b4ed68e453
    BUG: 1036102
    Signed-off-by: Kaleb S. KEITHLEY <kkeithle>
    Reviewed-on: http://review.gluster.org/6384
    Reviewed-by: Santosh Pradhan <spradhan>
    Tested-by: Gluster Build System <jenkins.com>
    Reviewed-by: Vijay Bellur <vbellur>

Comment 8 Anand Avati 2013-12-02 04:38:11 UTC
COMMIT: http://review.gluster.org/6381 committed in release-3.4 by Vijay Bellur (vbellur) 
------
commit ec60ca1061574f7c28a5ec226fb2553d2a0c8326
Author: Kaleb S. KEITHLEY <kkeithle>
Date:   Fri Nov 29 08:03:30 2013 -0500

    glusterfsd: fix small memory leaks in glusterfsd-mgmt.c
    
    E.g. In glusterfs_volfile_fetch(), req.xdata.xdata_val is allocated
    in dict_allocate_and_serialize() but not freed after mgmt_submit_request().
    
    A survey of dict_allocate_and_serialize/_submit_request in
    glusterfsd-mgmt.c shows no consistent pattern of freeing the xdata_val
    and also the dict, which is a little disturbing. (Yes, clearly not
    every place this occurs needs to be freed the same way.)
    
    Change-Id: I8f31179ae12c05c9b5406d8e9e28110fcbfac1c7
    BUG: 1036102
    Signed-off-by: Kaleb S. KEITHLEY <kkeithle>
    Reviewed-on: http://review.gluster.org/6381
    Tested-by: Gluster Build System <jenkins.com>
    Reviewed-by: Vijay Bellur <vbellur>

Comment 9 Niels de Vos 2014-04-17 13:15:07 UTC
This bug is getting closed because a release has been made available that should address the reported issue. In case the problem is still not fixed with glusterfs-3.4.3, please reopen this bug report.

glusterfs-3.4.3 has been announced on the Gluster Developers mailinglist [1], packages for several distributions should already be or become available in the near future. Keep an eye on the Gluster Users mailinglist [2] and the update infrastructure for your distribution.

The fix for this bug likely to be included in all future GlusterFS releases i.e. release > 3.4.3. In the same line the recent release i.e. glusterfs-3.5.0 [3] likely to have the fix. You can verify this by reading the comments in this bug report and checking for comments mentioning "committed in release-3.5".

[1] http://thread.gmane.org/gmane.comp.file-systems.gluster.devel/5978
[2] http://news.gmane.org/gmane.comp.file-systems.gluster.user
[3] http://thread.gmane.org/gmane.comp.file-systems.gluster.devel/6137