Bug 485473

Summary: Severe memory leak from attr_copy_file()
Product: [Fedora] Fedora Reporter: Ondrej Vasik <ovasik>
Component: attrAssignee: Zdenek Prikryl <zprikryl>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: high    
Version: rawhideCC: jim, kdudka, zprikryl
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-02-19 18:13:15 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Shell script which should provoke memory leak with rawhide coreutils cp...
none
proposed patch
none
up2date version of the patch none

Description Ondrej Vasik 2009-02-13 17:36:19 UTC
Created attachment 331848 [details]
Shell script which should provoke memory leak with rawhide coreutils cp...

Description of problem:
libattr function attr_copy_file() seems to be producing severe memory leak on x86_64 architecture. No matter if used as attr_copy_file (src_path, dst_path, 0, NULL); or attr_copy_file (src_path, dst_path, 0, &ctx);

Valgrind report (just the major leak, there seems to be other smaller leaks):

==9730== 24,508,254 bytes in 5,982 blocks are definitely lost in loss record 10 of 10
==9730==    at 0x4A0763E: malloc (vg_replace_malloc.c:207)
==9730==    by 0x4C27F61: attr_copy_action (attr_copy_action.c:67)
==9730==    by 0x4C27E48: attr_copy_check_permissions (attr_copy_check.c:27)
==9730==    by 0x4C279CA: attr_copy_file (attr_copy_file.c:108)
==9730==    by 0x4064F3: copy_internal (copy.c:246)
==9730==    by 0x4063C6: copy_internal (copy.c:317)
==9730==    by 0x4063C6: copy_internal (copy.c:317)
==9730==    by 0x407893: copy (copy.c:2257)
==9730==    by 0x4039B9: do_copy (cp.c:753)
==9730==    by 0x4040B0: main (cp.c:1129)

Version-Release number of selected component (if applicable):
libattr-2.4.43-1.fc1[01]

How reproducible:
Always on x86_64 arch, working on my i386

Steps to Reproduce:
1.Try to run attached script with rawhide coreutils (or at least cp ;) ) - I hope I modified it correctly, it is part of coreutils testsuite, I tried to make it work separately. Earlier versions of coreutils/cp will not recognize --preserve=xattr option.
  
Actual results:
Memory exhausted, Valgrind reports severe leak(s).

Expected results:
Test will pass without troubles.

Additional info:
This leak blocks enabling of non-mandatory copying xattrs in "preserve=all" and "cp -a" in upcoming upstream coreutils 7.1 release. Even suitable workaround would be nice :)

Comment 1 Ondrej Vasik 2009-02-13 18:06:53 UTC
As a side note - I was wrong with the architecture ... leak occurs even on i386 architecture - but is not present in libattr-2.4.32 - where attr_copy_action seems to be not present.

Comment 2 Kamil Dudka 2009-02-13 18:35:58 UTC
Created attachment 331854 [details]
proposed patch

seems not to be x86_64 dependent

Comment 3 Kamil Dudka 2009-12-27 00:20:06 UTC
Created attachment 380477 [details]
up2date version of the patch