RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 767488 - [libvirt]memleak when "run virsh console guest".
Summary: [libvirt]memleak when "run virsh console guest".
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.3
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Alex Jia
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-12-14 07:52 UTC by zhpeng
Modified: 2013-09-09 00:03 UTC (History)
9 users (show)

Fixed In Version: libvirt-0.9.9-1.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-06-20 06:39:05 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
valgrind full log (20.09 KB, text/plain)
2011-12-15 07:53 UTC, zhpeng
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2012:0748 0 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2012-06-19 19:31:38 UTC

Description zhpeng 2011-12-14 07:52:16 UTC
Description of problem:
Memleak when "run virsh console guest".

Version-Release number of selected component (if applicable):
libvirt-0.9.8-1.el6.x86_64

How reproducible:
always

Steps to Reproduce:
1. make sure have a working serial on guest like:
   <serial type='pty'>
      <source path='/dev/pts/12'/>
      <target port='0'/>
      <alias name='serial0'/>
    </serial>
2. add "console=tty0 console=ttyS0" to the kernel line of guest.
3. reboot the guest
4. valgrind -v --leak-check=full virsh console kvm1
5. login in the guest on step5 and do some operation.
6. leave the console with "Ctrl + ]"


Actual results:

==800== 1,024 bytes in 1 blocks are definitely lost in loss record 26 of 33
==800==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==800==    by 0x4A06167: realloc (vg_replace_malloc.c:525)
==800==    by 0x4C6A6EB: virReallocN (in /usr/lib64/libvirt.so.0.9.8)
==800==    by 0x40A867: ??? (in /usr/bin/virsh)
==800==    by 0x4C62EDE: ??? (in /usr/lib64/libvirt.so.0.9.8)
==800==    by 0x4C61C86: virEventRunDefaultImpl (in /usr/lib64/libvirt.so.0.9.8)
==800==    by 0x41C031: ??? (in /usr/bin/virsh)
==800==    by 0x4C73BD1: ??? (in /usr/lib64/libvirt.so.0.9.8)
==800==    by 0x32E64077F0: start_thread (in /lib64/libpthread-2.12.so)
==800==    by 0x32E5CE570C: clone (in /lib64/libc-2.12.so)
==800==
==800== 1,024 bytes in 1 blocks are definitely lost in loss record 27 of 33
==800==    at 0x4A0610F: realloc (vg_replace_malloc.c:525)
==800==    by 0x4C6A6EB: virReallocN (in /usr/lib64/libvirt.so.0.9.8)
==800==    by 0x40A729: ??? (in /usr/bin/virsh)
==800==    by 0x4C62EDE: ??? (in /usr/lib64/libvirt.so.0.9.8)
==800==    by 0x4C61C86: virEventRunDefaultImpl (in /usr/lib64/libvirt.so.0.9.8)
==800==    by 0x41C031: ??? (in /usr/bin/virsh)
==800==    by 0x4C73BD1: ??? (in /usr/lib64/libvirt.so.0.9.8)
==800==    by 0x32E64077F0: start_thread (in /lib64/libpthread-2.12.so)
==800==    by 0x32E5CE570C: clone (in /lib64/libc-2.12.so)
==800==
==800== LEAK SUMMARY:
==800==    definitely lost: 2,048 bytes in 2 blocks
==800==    indirectly lost: 0 bytes in 0 blocks
==800==      possibly lost: 0 bytes in 0 blocks
==800==    still reachable: 127,073 bytes in 1,344 blocks
==800==         suppressed: 0 bytes in 0 blocks
==800== Reachable blocks (those to which a pointer was found) are not shown.


Expected results:
avoid memory leak.

Comment 2 Alex Jia 2011-12-14 10:06:56 UTC
It exists a quite big leaks on virConsoleEventOnStdin and virConsoleEventOnStdout.

Comment 3 zhpeng 2011-12-15 07:53:47 UTC
Created attachment 547113 [details]
valgrind full log

Comment 4 Dave Allan 2011-12-19 22:12:21 UTC
(In reply to comment #2)
> It exists a quite big leaks on virConsoleEventOnStdin and
> virConsoleEventOnStdout.

Do you know where the leak is?

Comment 5 Alex Jia 2011-12-20 08:14:12 UTC
(In reply to comment #4)
> (In reply to comment #2)
> > It exists a quite big leaks on virConsoleEventOnStdin and
> > virConsoleEventOnStdout.
> 
> Do you know where the leak is?

I tried to avoid memory leaks on functions virConsoleEventOnStdin, virConsoleEventOnStdout and virConsoleEventOnStream, but my change
has effect on actual 'virsh console' function, it must be my mistake,
so I need to check my modification again.

Comment 6 Alex Jia 2011-12-20 09:34:25 UTC
Patch for upstream:
http://www.redhat.com/archives/libvir-list/2011-December/msg00872.html

Comment 7 Eric Blake 2011-12-20 20:37:48 UTC
commit 2b603dcb6c2b8d07044241c9feaf0dfafecad09d
Author: Alex Jia <ajia>
Date:   Tue Dec 20 17:40:13 2011 +0800

    console: plug memory leaks
    
    Using 'virReallocN' to allocate memory on virConsoleEventOnStdin,
    virConsoleEventOnStdout and virConsoleEventOnStream, however, the
    cleanup function virConsoleShutdown hasn't released these memory.
    
    * tools/console.c: fix memory leaks on virConsoleShutdown.

Comment 9 xhu 2012-01-10 08:33:22 UTC
Reproduce it with libvirt-0.9.8-1.el6.x86_64.
Verify it with libvirt-0.9.9-1.el6 and it passed.

Comment 11 errata-xmlrpc 2012-06-20 06:39:05 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/RHSA-2012-0748.html


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