Bug 765199 (GLUSTER-3467) - memory leak in stat-prefetch
Summary: memory leak in stat-prefetch
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: GLUSTER-3467
Product: GlusterFS
Classification: Community
Component: stat-prefetch
Version: pre-release
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Raghavendra G
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-08-22 19:55 UTC by Raghavendra Bhat
Modified: 2015-12-01 16:45 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:


Attachments (Terms of Use)

Description Raghavendra Bhat 2011-08-22 19:55:43 UTC
There is a memleak in stat-prefetch reported by valgrind.

 8,140 bytes in 100 blocks are definitely lost in loss record 192 of 222
==17137==    at 0x4A05140: calloc (vg_replace_malloc.c:418)
==17137==    by 0x4C53EA7: __gf_calloc (mem-pool.c:142)
==17137==    by 0xB236717: gf_strdup (mem-pool.h:129)
==17137==    by 0xB2374E0: sp_get_ancestors (stat-prefetch.c:943)
==17137==    by 0xB2375D4: sp_cache_remove_parent_entry (stat-prefetch.c:981)
==17137==    by 0xB2470FD: sp_rename (stat-prefetch.c:3075)
==17137==    by 0xB464128: io_stats_rename (io-stats.c:1888)
==17137==    by 0x62F643D: fuse_rename_resume (fuse-bridge.c:1374)
==17137==    by 0x62EE426: fuse_resolve_and_resume (fuse-resolve.c:739)
==17137==    by 0x62F67C8: fuse_rename (fuse-bridge.c:1422)
==17137==    by 0x62FFE55: fuse_thread_proc (fuse-bridge.c:3220)
==17137==    by 0x3971A0673C: start_thread (in /lib64/libpthread-2.5.so)
==17137== 
==17137== 8,170 bytes in 100 blocks are definitely lost in loss record 193 of 222
==17137==    at 0x4A05140: calloc (vg_replace_malloc.c:418)
==17137==    by 0x4C53EA7: __gf_calloc (mem-pool.c:142)
==17137==    by 0xB236717: gf_strdup (mem-pool.h:129)
==17137==    by 0xB2374E0: sp_get_ancestors (stat-prefetch.c:943)
==17137==    by 0xB2375D4: sp_cache_remove_parent_entry (stat-prefetch.c:981)
==17137==    by 0xB247062: sp_rename (stat-prefetch.c:3066)
==17137==    by 0xB464128: io_stats_rename (io-stats.c:1888)
==17137==    by 0x62F643D: fuse_rename_resume (fuse-bridge.c:1374)
==17137==    by 0x62EE426: fuse_resolve_and_resume (fuse-resolve.c:739)
==17137==    by 0x62F67C8: fuse_rename (fuse-bridge.c:1422)
==17137==    by 0x62FFE55: fuse_thread_proc (fuse-bridge.c:3220)
==17137==    by 0x3971A0673C: start_thread (in /lib64/libpthread-2.5.so)


sp_get_ancestors (char *path, char **parent, char **grand_parent)
{
        int32_t  ret = -1, i = 0;
	char    *cpy = NULL;

        if (!path || !parent || !grand_parent) {
		ret = 0;
                goto out;
    	}

        for (i = 0; i < 2; i++) {
                if (!strcmp (path, "/")) {
			break;
                }

		cpy = gf_strdup (path);
		if (cpy == NULL) {
                        ret = -errno;
                        goto out;
                }

	        path = dirname (cpy);
	        switch (i)
                {
	        case 0:
                        *parent = path;
                        break;
		case 1:
                        *grand_parent = path;
	                break;
	        }
	}

	ret = 0;
out:
        return ret;

In the above function we are not freeing cpy while returning.

Comment 1 Anand Avati 2011-08-23 05:59:26 UTC
CHANGE: http://review.gluster.com/307 (Change-Id: I84580e297ba93a9a093c2e3432ea52e3c0db4a1a) merged in master by Vijay Bellur (vijay)

Comment 2 Anand Avati 2011-08-24 05:17:09 UTC
CHANGE: http://review.gluster.com/309 (BUG: 3467) merged in release-3.2 by Vijay Bellur (vijay)


Note You need to log in before you can comment on or make changes to this bug.