Bug 1943415 - virsh: memory leak at invalid setmem subcommand
Summary: virsh: memory leak at invalid setmem subcommand
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libvirt
Version: 8.4
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.5
Assignee: Ján Tomko
QA Contact: Jing Qi
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-03-26 02:45 UTC by Han Han
Modified: 2021-11-16 08:22 UTC (History)
5 users (show)

Fixed In Version: libvirt-7.3.0-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-16 07:52:31 UTC
Type: Bug
Target Upstream Version: 7.3.0
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2021:4684 0 None None None 2021-11-16 07:53:15 UTC

Description Han Han 2021-03-26 02:45:13 UTC
Description of problem:
As subject

Version-Release number of selected component (if applicable):
libvirt-7.0.0-10.module+el8.4.0+10417+37f6984d.x86_64

How reproducible:
100%

Steps to Reproduce:
# valgrind --leak-check=full virsh setmem 100

Actual results:
==236992== 28 (24 direct, 4 indirect) bytes in 1 blocks are definitely lost in loss record 98 of 272
==236992==    at 0x4C3721A: calloc (vg_replace_malloc.c:760)
==236992==    by 0x5C6E2FD: g_malloc0 (gmem.c:129)
==236992==    by 0x17F40D: vshCommandParse (vsh.c:1471)
==236992==    by 0x17FF61: vshCommandArgvParse (vsh.c:1597)
==236992==    by 0x13AC63: virshParseArgv (virsh.c:782)
==236992==    by 0x13AC63: main (virsh.c:886)


Expected results:
No direct or indirect bytes of definitely lost

Additional info:

Comment 1 Ján Tomko 2021-04-07 15:30:39 UTC
Proposed upstream patch:
https://listman.redhat.com/archives/libvir-list/2021-April/msg00167.html

Comment 2 Jing Qi 2021-04-09 06:46:23 UTC
Tested the patch with libvirt upstream version v7.2.0-84-gafda589d05. No definitely lost any more.

valgrind --leak-check=full virsh set mem 100


==86243== LEAK SUMMARY:
==86243==    definitely lost: 0 bytes in 0 blocks
==86243==    indirectly lost: 0 bytes in 0 blocks
==86243==      possibly lost: 1,352 bytes in 18 blocks
==86243==    still reachable: 129,787 bytes in 926 blocks
==86243==                       of which reachable via heuristic:
==86243==                         newarray           : 1,536 bytes in 16 blocks
==86243==         suppressed: 0 bytes in 0 blocks
==86243== Reachable blocks (those to which a pointer was found) are not shown.
==86243== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==86243== 
==86243== For lists of detected and suppressed errors, rerun with: -s
==86243== ERROR SUMMARY: 18 errors from 18 contexts (suppressed: 0 from 0)

Comment 3 Ján Tomko 2021-04-09 11:14:14 UTC
Pushed as:
commit a131b8b517a88685ddb5f1b17c4d1a16b9a97b61
Author:     Ján Tomko <jtomko>
CommitDate: 2021-04-09 13:07:30 +0200

    vsh: fix memory leak in vshCommandParse
    
    One of the error branches used a plain free where vshCommandFree
    was required.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1943415
    
    Signed-off-by: Ján Tomko <jtomko>
    Reviewed-by: Erik Skultety <eskultet>

git describe: v7.2.0-85-ga131b8b517

Comment 6 Jing Qi 2021-05-14 12:37:59 UTC
Verified with libvirt-daemon-7.3.0-1.module+el8.5.0+11004+f4810536.x86_64  
& qemu-kvm-6.0.0-16.module+el8.5.0+10848+2dccc46d.x86_64

Steps as comment2.

Comment 8 errata-xmlrpc 2021-11-16 07:52:31 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 (virt:av bug fix and enhancement update), 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://access.redhat.com/errata/RHBA-2021:4684


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