Bug 485473 - Severe memory leak from attr_copy_file()
Summary: Severe memory leak from attr_copy_file()
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: attr
Version: rawhide
Hardware: All
OS: Linux
high
high
Target Milestone: ---
Assignee: Zdenek Prikryl
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-02-13 17:36 UTC by Ondrej Vasik
Modified: 2009-12-27 00:20 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-02-19 18:13:15 UTC
Type: ---


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

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


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