Bug 736258

Summary: Use "ctrl+c" to close libvirtMib_subagent will lead to memory leak
Product: Red Hat Enterprise Linux 6 Reporter: xhu
Component: libvirt-snmpAssignee: Martin Kletzander <mkletzan>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: high    
Version: 6.2CC: ajia, areis, bili, cwei, dallan, dyuan, jmiao, lnovich, mprivozn, mshao, mzhan
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-snmp-0.0.2-4.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-11-21 21:40:22 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 896690, 960054    
Attachments:
Description Flags
memory leak info none

Description xhu 2011-09-07 07:53:19 UTC
Created attachment 521807 [details]
memory leak info

Description of problem:
Use "ctrl+c" to close libvirtMib_subagent will lead to memory leak

Version-Release number of selected component (if applicable):
libvirt-snmp-0.0.2-1.el6.x86_64
libvirt-snmp-debuginfo-0.0.2-1.el6.x86_64
libvirt-0.9.4-7.el6.x86_64
qemu-kvm-0.12.1.2-2.185.el6.x86_64

How reproducible:
everytimes

Steps to Reproduce:
1. install libvirt-snmp libvirt-snmp-debuginfo valgrind
# sudo yum install libvirt-snmp libvirt-snmp-debuginfo valgrind
	
2. prepare /etc/snmp/snmpd.conf as follows:
# cat /etc/snmp/snmpd.conf
rwcommunity public
master agentx
trapcommunity public
trap2sink  localhost

3. append the following lines to /etc/snmp/snmptrapd.conf
# Example configuration file for snmptrapd
authCommunity log,execute,net public
logOption f /var/log/snmptraps.log

4. add the following lines to /etc/sysconfig/snmptrapd:
OPTIONS="-m ALL -p /var/run/snmptrapd.pid"

5. restart snmpd and snmptrapd service
# service snmpd restart
# service snmptrapd restart

6. run libvirt snmp agent daemon
LIBVIRT_DEFAULT_URI="qemu:///system" valgrind --leak-check=full libvirtMib_subagent -f -L >& tmp.log 2>&1

7. use "ctrl+c" twice to close libvirtMib_subagent
 
Actual results:
There is memory leak and the details can be seen in the "tmp.log" attachment.

Expected results:
There is no memory leak

Additional info:
Sometimes the libvirtd will die

Comment 2 Martin Kletzander 2012-02-03 10:22:27 UTC
I confirm the bug, it's easy to reproduce but I haven't seen the libvirt daemon affected in any way.

Comment 4 Martin Kletzander 2012-05-30 15:31:18 UTC
Two fixes have been needed to do this, one was fixed earlier in the library, the second one was pushed into the snmp code now:

commit 22c2f5fd91a63d817199b42e695a87dab28ad0c1
Author: Martin Kletzander <mkletzan>
Date:   Wed May 30 14:30:02 2012 +0200

    Stop event thread on server stop

Comment 6 RHEL Program Management 2012-09-07 04:58:15 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unable to address this
request at this time.

Red Hat invites you to ask your support representative to
propose this request, if appropriate, in the next release of
Red Hat Enterprise Linux.

Comment 13 Ademar Reis 2013-06-04 18:05:36 UTC
(In reply to Laura Novich from comment #12)
> While this bug fix probably only needs to be included in the RN, I am
> marking this as docs_scoped ? just to make sure it doesn't need to be
> considered for the Virt. Admin. Guide
> Ademar?

Documentation isn't necessary.

Comment 15 Jincheng Miao 2013-08-20 04:51:55 UTC
# cat /etc/snmp/snmpd.conf 
rwcommunity public
master agentx
trapcommunity public
trap2sink  localhost

# cat /etc/sysconfig/snmptrapd 
OPTIONS="-m ALL -p /var/run/snmptrapd.pid"

# service snmpd restart
Stopping snmpd:                                            [FAILED]
Starting snmpd:                                            [  OK  ]

# service snmptrapd restart
Stopping snmptrapd:                                        [FAILED]
Starting snmptrapd:                                        [  OK  ]

# LIBVIRT_DEFAULT_URI="qemu:///system" valgrind --leak-check=full libvirtMib_subagent -f -L >& tmp.log 2>&1

# cat tmp.log
==18947== Memcheck, a memory error detector
==18947== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==18947== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==18947== Command: libvirtMib_subagent -f -L
==18947==
NET-SNMP version 5.5 AgentX subagent connected
==18947==
==18947== HEAP SUMMARY:
==18947==     in use at exit: 143,700 bytes in 1,575 blocks
==18947==   total heap usage: 32,788 allocs, 31,213 frees, 27,425,111 bytes allocated
==18947==
==18947== LEAK SUMMARY:
==18947==    definitely lost: 0 bytes in 0 blocks
==18947==    indirectly lost: 0 bytes in 0 blocks
==18947==      possibly lost: 0 bytes in 0 blocks
==18947==    still reachable: 143,700 bytes in 1,575 blocks
==18947==         suppressed: 0 bytes in 0 blocks
==18947== Reachable blocks (those to which a pointer was found) are not shown.
==18947== To see them, rerun with: --leak-check=full --show-reachable=yes
==18947==
==18947== For counts of detected and suppressed errors, rerun with: -v
==18947== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 18 from 6)

No memory leak in valgrind report, so I change the status to VERIFIED.

Comment 16 errata-xmlrpc 2013-11-21 21:40:22 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-1666.html