Bug 485473 - Severe memory leak from attr_copy_file()
Severe memory leak from attr_copy_file()
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: attr (Show other bugs)
rawhide
All Linux
high Severity high
: ---
: ---
Assigned To: Zdenek Prikryl
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-02-13 12:36 EST by Ondrej Vasik
Modified: 2009-12-26 19:20 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-02-19 13:13:15 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Shell script which should provoke memory leak with rawhide coreutils cp... (1.11 KB, text/plain)
2009-02-13 12:36 EST, Ondrej Vasik
no flags Details
proposed patch (648 bytes, patch)
2009-02-13 13:35 EST, Kamil Dudka
no flags Details | Diff
up2date version of the patch (1.14 KB, patch)
2009-12-26 19:20 EST, Kamil Dudka
no flags Details | Diff

  None (edit)
Description Ondrej Vasik 2009-02-13 12:36:19 EST
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 13:06:53 EST
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 13:35:58 EST
Created attachment 331854 [details]
proposed patch

seems not to be x86_64 dependent
Comment 3 Kamil Dudka 2009-12-26 19:20:06 EST
Created attachment 380477 [details]
up2date version of the patch

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