Bug 540472 - Leaks huge amounts of memory when opened unprivileged
Summary: Leaks huge amounts of memory when opened unprivileged
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: netcf
Version: 12
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: David Lutterkort
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 540330
TreeView+ depends on / blocked
 
Reported: 2009-11-23 13:42 UTC by Daniel Berrangé
Modified: 2013-04-30 23:41 UTC (History)
3 users (show)

Fixed In Version: 0.1.5-1.fc12
Clone Of:
Environment:
Last Closed: 2009-12-18 04:33:26 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Fix memory leak in ncf_open() cleanup path (535 bytes, patch)
2009-11-23 13:43 UTC, Daniel Berrangé
no flags Details | Diff

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.


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