Bug 540472

Summary: Leaks huge amounts of memory when opened unprivileged
Product: [Fedora] Fedora Reporter: Daniel Berrangé <berrange>
Component: netcfAssignee: David Lutterkort <lutter>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 12CC: hbrock, lutter, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 0.1.5-1.fc12 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-12-18 04:33:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 540330    
Attachments:
Description Flags
Fix memory leak in ncf_open() cleanup path none

Description Daniel Berrangé 2009-11-23 13:42:28 UTC
Description of problem:
Attempting to open use  netcf from an unprivileged user results in a huge memory leak. This in turns causes libvirtd to leak memory when run as a non-root user.

Version-Release number of selected component (if applicable):
0.1.4

How reproducible:
Always, when used as non-root

Steps to Reproduce:
1. Compile the following


#include <stdio.h>

int main(int argc, char **argv)
{
    for (int i = 0 ; i < 1000000 ; i++) {
        struct netcf *netcf = NULL;

        ncf_init(&netcf, NULL);

        if (netcf != NULL) {
            ncf_close(netcf);
        }
    }
    return 0;
}


2. Run it as non-root & watch it with 'top'
3.
  
Actual results:
Consumes 100's of MB 

Expected results:


Additional info:

Comment 1 Daniel Berrangé 2009-11-23 13:43:40 UTC
Created attachment 373113 [details]
Fix memory leak in ncf_open() cleanup path

Comment 2 David Lutterkort 2009-11-23 23:27:40 UTC
Thanks for the patch. Fixed upstream by commit 42fd804f (I still see a small leak ~300 bytes from libnl in valgrind, but the leak is orders of magnitute smaller now)

Comment 3 Daniel Berrangé 2009-11-24 10:41:28 UTC
Hmm, assuming you've already committed my other reported fix, would the remaining leaks you be these ones.... ?

==22396== 16 bytes in 1 blocks are possibly lost in loss record 526 of 1,826
==22396==    at 0x4004F1B: calloc (vg_replace_malloc.c:418)
==22396==    by 0x52CD887: add_routing_table_name (netlink-local.h:131)
==22396==    by 0x52CD96A: init_routing_table_names (route_utils.c:63)
==22396==    by 0x52DF63C: ??? (in /usr/lib/libnl.so.1.1)
==22396==    by 0x52B0843: ??? (in /usr/lib/libnl.so.1.1)
==22396==    by 0x20B8DB: call_init (dl-init.c:70)
==22396==    by 0x20BA40: _dl_init (dl-init.c:134)
==22396==    by 0x1FD88E: ??? (in /lib/ld-2.11.so)

if so, those are harmless since they're static variable initialization and not intended to be freed

Comment 4 David Lutterkort 2009-11-24 21:39:53 UTC
I get something slightly different (on F11):

==29719== 128 bytes in 4 blocks are possibly lost in loss record 13 of 23
==29719==    at 0x4A05414: calloc (vg_replace_malloc.c:397)
==29719==    by 0x31DEE2BCF7: (within /usr/lib64/libnl.so.1.1)
==29719==    by 0x31DEE2BDA1: (within /usr/lib64/libnl.so.1.1)
==29719==    by 0x31DEE3A6D5: (within /usr/lib64/libnl.so.1.1)
==29719==    by 0x31DEE13412: (within /usr/lib64/libnl.so.1.1)
==29719== 
==29719== 
==29719== 160 bytes in 5 blocks are possibly lost in loss record 15 of 23
==29719==    at 0x4A05414: calloc (vg_replace_malloc.c:397)
==29719==    by 0x31DEE2BF17: (within /usr/lib64/libnl.so.1.1)
==29719==    by 0x31DEE2BFC1: (within /usr/lib64/libnl.so.1.1)
==29719==    by 0x31DEE3A6D5: (within /usr/lib64/libnl.so.1.1)
==29719==    by 0x31DEE13412: (within /usr/lib64/libnl.so.1.1)

I haven't been able to get valgrind to use libnl debuginfo for more enlightening stacktraces - maybe once I upgrade to F12.

All I am doing is running
<pre>
valgrind --leak-check=full /data/share/bin/ncftool <<EOF
quit
EOF
</pre>

Comment 5 Fedora Update System 2009-11-30 21:51:05 UTC
netcf-0.1.5-1.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/netcf-0.1.5-1.fc12

Comment 6 Fedora Update System 2009-12-02 04:26:38 UTC
netcf-0.1.5-1.fc12 has been pushed to the Fedora 12 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update netcf'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F12/FEDORA-2009-12472

Comment 7 Fedora Update System 2009-12-18 04:33:16 UTC
netcf-0.1.5-1.fc12 has been pushed to the Fedora 12 stable repository.  If problems still persist, please make note of it in this bug report.