Bug 1329046

Summary: "virsh perf $guest --enable '' " has memory leak.
Product: Red Hat Enterprise Linux 7 Reporter: Fangge Jin <fjin>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: dyuan, mzhan, pkrempa, rbalakri, yafu, zpeng
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.3.4-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-03 18:43:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Fangge Jin 2016-04-21 02:49:11 UTC
Description of problem:
"virsh perf $guest --enable '' " has memory leak.

Version-Release number of selected component:
libvirt-1.3.3-2.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
# valgrind --leak-check=full virsh perf rhel7.2-1030 --enable ''
==28057== Memcheck, a memory error detector
==28057== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==28057== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==28057== Command: virsh perf rhel7.2-1030 --enable
==28057==
error: Failed to get option 'enable': Option argument is empty

error: One or more references were leaked after disconnect from the hypervisor
==28057==
==28057== HEAP SUMMARY:
==28057==     in use at exit: 104,702 bytes in 1,088 blocks
==28057==   total heap usage: 2,008 allocs, 920 frees, 824,661 bytes allocated
==28057==
==28057== 69 (56 direct, 13 indirect) bytes in 1 blocks are definitely lost in loss record 129 of 183
==28057==    at 0x4C2B974: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==28057==    by 0x54E9214: virAllocVar (viralloc.c:560)
==28057==    by 0x5533005: virObjectNew (virobject.c:193)
==28057==    by 0x55D516A: virGetDomain (datatypes.c:279)
==28057==    by 0x563FC7E: get_nonnull_domain (remote_driver.c:7462)
==28057==    by 0x563FC7E: remoteDomainLookupByName (remote_client_bodies.h:2972)
==28057==    by 0x55DFC3D: virDomainLookupByName (libvirt-domain.c:425)
==28057==    by 0x12EF30: virshLookupDomainInternal (virsh-domain.c:116)
==28057==    by 0x133707: virshCommandOptDomainBy (virsh-domain.c:153)
==28057==    by 0x139FEC: cmdPerf (virsh-domain.c:8619)
==28057==    by 0x16262F: vshCommandRun (vsh.c:1274)
==28057==    by 0x12D997: main (virsh.c:984)
==28057==
==28057== LEAK SUMMARY:
==28057==    definitely lost: 56 bytes in 1 blocks
==28057==    indirectly lost: 13 bytes in 1 blocks
==28057==      possibly lost: 0 bytes in 0 blocks
==28057==    still reachable: 104,633 bytes in 1,086 blocks
==28057==         suppressed: 0 bytes in 0 blocks
==28057== Reachable blocks (those to which a pointer was found) are not shown.
==28057== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==28057==
==28057== For counts of detected and suppressed errors, rerun with: -v
==28057== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 1 from 1)


Expected results:
No memory leak.

Comment 2 Peter Krempa 2016-04-21 08:01:59 UTC
Fixed upstream:

commit f4f916a9e35d50fe423443e95ca02b28fb2d0e0b
Author: Peter Krempa <pkrempa>
Date:   Thu Apr 21 09:51:08 2016 +0200

    virsh: perf: Don't leak domain
    
    After failing to parse the perf event list, the code would return
    failure without freeing the previously acquired object. Rearrange the
    code to avoid the problem.

Comment 4 yafu 2016-05-06 09:00:17 UTC
Verify the bug with libvirt-1.3.4-1.el7.x86_64.

Steps:
1.# valgrind --leak-check=full virsh perf rhel7.1 --enable ''
==25443== Memcheck, a memory error detector
==25443== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==25443== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==25443== Command: virsh perf rhel7.1 --enable 
==25443== 
error: Failed to get option 'enable': Option argument is empty

==25443== 
==25443== HEAP SUMMARY:
==25443==     in use at exit: 102,877 bytes in 1,067 blocks
==25443==   total heap usage: 1,965 allocs, 898 frees, 818,846 bytes allocated
==25443== 
==25443== LEAK SUMMARY:
==25443==    definitely lost: 0 bytes in 0 blocks
==25443==    indirectly lost: 0 bytes in 0 blocks
==25443==      possibly lost: 0 bytes in 0 blocks
==25443==    still reachable: 102,877 bytes in 1,067 blocks
==25443==         suppressed: 0 bytes in 0 blocks
==25443== Reachable blocks (those to which a pointer was found) are not shown.
==25443== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==25443== 
==25443== For counts of detected and suppressed errors, rerun with: -v
==25443== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 1 from 1)


No memory leak. So mark this bug verified.

Comment 6 errata-xmlrpc 2016-11-03 18:43:38 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.

https://rhn.redhat.com/errata/RHSA-2016-2577.html