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 :)
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.
Created attachment 331854 [details] proposed patch seems not to be x86_64 dependent
Created attachment 380477 [details] up2date version of the patch