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 1763008 - net-snmp leaks memory from not shutting down librpm
Summary: net-snmp leaks memory from not shutting down librpm
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: net-snmp
Version: 8.0
Hardware: x86_64
OS: All
medium
unspecified
Target Milestone: rc
: 8.0
Assignee: Josef Ridky
QA Contact: Evgeny Fedin
URL:
Whiteboard:
Depends On:
Blocks: 1472458 1819712
TreeView+ depends on / blocked
 
Reported: 2019-10-18 03:40 UTC by andy.liang
Modified: 2020-11-04 02:10 UTC (History)
15 users (show)

Fixed In Version: net-snmp-5.8-15.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-11-04 02:06:39 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)
Valgrind Test Result (11.45 KB, application/zip)
2019-10-18 03:40 UTC, andy.liang
no flags Details
Valgrind logs for snmpd (90.64 KB, text/plain)
2019-11-26 07:24 UTC, andy.liang
no flags Details
This patch is for net-snmp 5.8 (1.07 KB, patch)
2019-12-04 07:06 UTC, andy.liang
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2020:4576 0 None None None 2020-11-04 02:07:13 UTC

Description andy.liang 2019-10-18 03:40:46 UTC
Created attachment 1627026 [details]
Valgrind Test Result

Description of problem:
Using the valgrind 3.15.0 with our Manageability software observer the memory leak. We verified the on the SLSE15SP1 which also uses the liblua 5.3.5 has the same observation. No leakage observed on RHEL7 and SLES12SP4 which use liblua 5.1.5. 

Version-Release number of selected component (if applicable):


How reproducible:
Manageability software package:
https://support.hpe.com/hpsc/swd/public/detail?swItemId=MTX_69f72d896167451a9e0a9d5f39

Valgrind:
http://valgrind.org/downloads/current.html#current

Steps to Reproduce:
1.Install the Manageability software package
2.Install Valgrind
3.Stop service: systemctl stop amsd
4.valgrind --leak-check=full /sbin/amsd -f

Actual results:
Please check the log files

Expected results:


Additional info:

Comment 1 Panu Matilainen 2019-11-05 13:58:44 UTC
These leaks are caused by the application not shutting down librpm at exit by calling rpmFreeRpmrc(). This is required to release various resources used by librpm in all rpm versions, that older Lua versions do not appear to leak memory when not properly shut down is an internal implementation detail of Lua.

Comment 2 andy.liang 2019-11-26 07:23:10 UTC
Using the default OS snmpd package will memory leak checking, I got a similar memory leak pattern.

Command:
valgrind --leak-check=full  /usr/sbin/snmpd -f 

Net-snmp packages:
net-snmp-agent-libs-5.8-7.el8.x86_64
net-snmp-libs-5.8-7.el8.x86_64
net-snmp-5.8-7.el8.x86_64
net-snmp-utils-5.8-7.el8.x86_64
net-snmp-devel-5.8-7.el8.x86_64

Comment 3 andy.liang 2019-11-26 07:24:08 UTC
Created attachment 1639713 [details]
Valgrind logs for snmpd

Comment 4 Panu Matilainen 2019-11-26 08:00:14 UTC
(In reply to andy.liang from comment #2)
> Using the default OS snmpd package will memory leak checking, I got a
> similar memory leak pattern.
> 

So that's a memory leak in snmpd then. And sure enough:

[pmatilai🎩︎lumikko-w net-snmp-5.8]$ find -name "*.c"|xargs grep rpmFreeRpmrc
[pmatilai🎩︎lumikko-w net-snmp-5.8]$

It doesn't shutdown librpm when done, so it leaks. This is an application error, whether it's in a distro component or 3rd party software.

Comment 5 andy.liang 2019-12-04 07:06:01 UTC
Created attachment 1641913 [details]
This patch is for net-snmp 5.8

By the Panu's comment, I made a patch that works fine ay my side, but I don't know is there any side effects. Please review the patch. Thanks.

Comment 6 Josef Ridky 2019-12-04 07:16:37 UTC
Thanks a lot for the patch. 

In agent/mibgroup/host/hr_swinst.c: rpmFreeRpmrc() method could be called even after line #223, similarly in agent/mibgroup/host/data_access/swinst_rpm.c: rpmFreeRpmrc() method could be called after line #70, but from functional point of view, it doesn't matter. By this change, we would just save two #ifdef conditions.

Let's wait for upstream acceptance to have it part of RHEL-8.

Comment 7 Josef Ridky 2019-12-10 12:42:52 UTC
Patch accepted by upstream.

@djez @ovasik may I ask for acks?

Comment 17 Trinh Dao 2020-08-12 16:58:51 UTC
HPE Andy Liang verified the rpm, net-snmp-5.8-15.el8 is in the RHEL8.3.  mark HPE verified.
this bug can be closed.

thank you RH!
trinh

Comment 20 errata-xmlrpc 2020-11-04 02:06:39 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 (net-snmp 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-2020:4576


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