Bug 540472 - Leaks huge amounts of memory when opened unprivileged
Leaks huge amounts of memory when opened unprivileged
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: netcf (Show other bugs)
12
All Linux
low Severity medium
: ---
: ---
Assigned To: David Lutterkort
Fedora Extras Quality Assurance
:
Depends On:
Blocks: 540330
  Show dependency treegraph
 
Reported: 2009-11-23 08:42 EST by Daniel Berrange
Modified: 2013-04-30 19:41 EDT (History)
3 users (show)

See Also:
Fixed In Version: 0.1.5-1.fc12
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-12-17 23:33:26 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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

  None (edit)
Description Daniel Berrange 2009-11-23 08:42:28 EST
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 Berrange 2009-11-23 08:43:40 EST
Created attachment 373113 [details]
Fix memory leak in ncf_open() cleanup path
Comment 2 David Lutterkort 2009-11-23 18:27:40 EST
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 Berrange 2009-11-24 05:41:28 EST
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 16:39:53 EST
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 16:51:05 EST
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-01 23:26:38 EST
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-17 23:33:16 EST
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.