Bug 885993

Summary: Memory leak in _parse_mirror_status
Product: Red Hat Enterprise Linux 6 Reporter: Zdenek Kabelac <zkabelac>
Component: lvm2Assignee: Zdenek Kabelac <zkabelac>
Status: CLOSED ERRATA QA Contact: Cluster QE <mspqa-list>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.4CC: agk, cmarthal, dwysocha, heinzm, jbrassow, msnitzer, nperic, prajnoha, prockai, thornber, zkabelac
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: lvm2-2.02.98-5.el6 Doc Type: Bug Fix
Doc Text:
Testing of mirror health status caused minor memory leak. Fix is releasing all resources taken in the function and should not cause any memory leaks for longterm living processes like dmeventd.
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-21 08:15:23 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: 888457    

Description Zdenek Kabelac 2012-12-11 09:28:56 UTC
Description of problem:

Running 2 lvcreate mirror commands lead to internal memory leak,
in the function _parse_mirror_status, where device is tested for
usability. Allocated log and image strings are not released
after their use.

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


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Zdenek Kabelac 2012-12-11 09:32:34 UTC
For testing the only way how to detect this leak is to use valgrind and run 2 commands like    'lvcreate -m2 -L10M vg'

Current code results in leak like:

 16544== 7 bytes in 1 blocks are indirectly lost in loss record 3 of 5
 16544==    at 0x4C2C87C: malloc (vg_replace_malloc.c:270)
 16544==    by 0x5BBAFC1: strdup (strdup.c:42)
 16544==    by 0x483498: dev_create_file (dev-cache.c:84)
 16544==    by 0x53106D: _ignore_blocked_mirror_devices (dev_manager.c:257)
 16544==    by 0x531B1E: device_is_usable (dev_manager.c:359)
 16544==    by 0x492024: _lookup_p (filter-persistent.c:297)
 16544==    by 0x48791B: dev_iter_get (dev-cache.c:1009)
 16544==    by 0x47324E: lvmcache_label_scan (lvmcache.c:692)
 16544==    by 0x4E120F: _vg_read (metadata.c:2981)
 16544==    by 0x4E3407: vg_read_internal (metadata.c:3397)
 16544==    by 0x4E5E3C: _vg_lock_and_read (metadata.c:4033)
 16544==    by 0x4E65D7: vg_read (metadata.c:4137)
 16544==    by 0x4E6633: vg_read_for_update (metadata.c:4148)
 16544==    by 0x42DE9D: lvcreate (lvcreate.c:1028)
 16544==    by 0x4364CE: lvm_run_command (lvmcmdline.c:1120)
 16544==    by 0x43867F: lvm2_main (lvmcmdline.c:1554)
 16544==    by 0x4679C1: main (lvm.c:21)

Comment 2 Zdenek Kabelac 2012-12-11 10:33:29 UTC
Fixed by upstream patch:

https://www.redhat.com/archives/lvm-devel/2012-December/msg00018.html

Comment 4 Zdenek Kabelac 2012-12-11 11:14:51 UTC
While the leak does not look huge, it is in the range of hundred bytes per command and per mirror, we have long-term running commands like  dmeventd which should not leak memory, since the memory may accumulate over the time, and such memory is non-swappable and permanently locked in RAM - so leaving such leak may increase risk of getting OOM killer in action - so setting exception because of this risk.

Comment 5 Nenad Peric 2012-12-11 11:43:22 UTC
Adding QA ACK as SanityOnly since no easy reproducer (in a normal amount of given time) is viable. 
(it would probably accumulate in time as stated in Comment #4, but SanityOnly should suffice in this case I believe)

Comment 7 errata-xmlrpc 2013-02-21 08:15:23 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/RHBA-2013-0501.html