Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1438811

Summary: memory leak when creating hdr objects
Product: Red Hat Enterprise Linux 6 Reporter: Jan Blazek <jblazek>
Component: rpmAssignee: Packaging Maintenance Team <packaging-team-maint>
Status: CLOSED ERRATA QA Contact: Eva Mrakova <emrakova>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.10CC: emrakova, ffesti, jkurik, pmatilai, pmoravco, szidek, tbowling
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: rpm-4.8.0-58.el6 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1358467 Environment:
Last Closed: 2018-06-19 05:20:53 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:
Bug Depends On:    
Bug Blocks: 1494486, 1494504    
Attachments:
Description Flags
valgrind.log none

Description Jan Blazek 2017-04-04 13:19:46 UTC
Created attachment 1268650 [details]
valgrind.log

+++ This bug was initially created as a clone of Bug #1358467 +++

Description of problem:

I have a python script that calls rpm.readHeaderListFromFile() to check rpm headers. When calling this method iteratively over rpms in a yum repository, the python process' heap grows continuously. There appears to be a memory leak when creating the header object in librpm. A simple reproducer:

----
# cat rpm_hdr_test.py 
import rpm

for i in xrange(1000):
    hdr1 = rpm._rpm.hdr()
----

Running a memory leak test w/ valgrind:

----
# valgrind --leak-check=full --time-stamp=yes --log-file=rpm_hdr.log python rpm_hdr_test.py
----

shows the following:

----
==00:00:00:06.733 19733== 296,000 (40,000 direct, 256,000 indirect) bytes in 1,000 blocks are definitely lost in loss record 1,935 of 1,935
==00:00:00:06.733 19733==    at 0x4C2B974: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==00:00:00:06.733 19733==    by 0xDA8E2EE: rcalloc (rpmmalloc.c:55)
==00:00:00:06.733 19733==    by 0xCE38951: headerCreate (header.c:168)
==00:00:00:06.733 19733==    by 0xCC14FD4: hdr_new (header-py.c:394)
==00:00:00:06.733 19733==    by 0x4ED4E52: type_call (typeobject.c:729)
==00:00:00:06.733 19733==    by 0x4E7F0C2: PyObject_Call (abstract.c:2529)
==00:00:00:06.733 19733==    by 0x4F1338B: do_call (ceval.c:4316)
==00:00:00:06.733 19733==    by 0x4F1338B: call_function (ceval.c:4121)
==00:00:00:06.733 19733==    by 0x4F1338B: PyEval_EvalFrameEx (ceval.c:2740)
==00:00:00:06.733 19733==    by 0x4F171EC: PyEval_EvalCodeEx (ceval.c:3330)
==00:00:00:06.733 19733==    by 0x4F172F1: PyEval_EvalCode (ceval.c:689)
==00:00:00:06.733 19733==    by 0x4F3072E: run_mod (pythonrun.c:1374)
==00:00:00:06.733 19733==    by 0x4F318ED: PyRun_FileExFlags (pythonrun.c:1360)
==00:00:00:06.733 19733==    by 0x4F32B78: PyRun_SimpleFileExFlags (pythonrun.c:952)
----

Full log file is attached.


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

rpm-4.8.0-55.el6.x86_64
rpm-libs-4.8.0-55.el6.x86_64
rpm-python-4.8.0-55.el6.x86_64

How reproducible:

100%

Steps to Reproduce:
1.) Create and deallocate multiple hdr objects in python with rpm.readHeaderListFromFile().
2.) See increasing heap size throughout lifetime of process.


Actual results:

Memory leak when creating hdr objects.

Expected results:

No memory leak.

Additional info:

See attached valgrind log.

Comment 6 Panu Matilainen 2018-03-21 13:44:46 UTC
*** Bug 1558920 has been marked as a duplicate of this bug. ***

Comment 9 errata-xmlrpc 2018-06-19 05:20:53 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://access.redhat.com/errata/RHBA-2018:1909