Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 566038 - sys-apps/install-xattr: memory leak
Summary: sys-apps/install-xattr: memory leak
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Anthony Basile
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-17 10:34 UTC by Agostino Sarubbo
Modified: 2017-03-15 10:52 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Agostino Sarubbo gentoo-dev 2015-11-17 10:34:58 UTC
If install-xattr is compiled with address sanitizer, every emerge ends with:


>>> Emerging (1 of 1) app-portage/eix-0.30.11::gentoo
 * eix-0.30.11.tar.bz2 SHA256 SHA512 size ;-) ...                                                                                                                                                                                                                       [ ok ]

=================================================================
==24888==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 4097 byte(s) in 1 object(s) allocated from:
    #0 0x4bc202 in __interceptor_malloc /var/tmp/portage/sys-devel/llvm-3.6.1/work/llvm-3.6.1.src/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:40:3
    #1 0x46607c in __interceptor_realpath /var/tmp/portage/sys-devel/llvm-3.6.1/work/llvm-3.6.1.src/projects/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc:2521:46
    #2 0x4db6ae in main /tmp/portage/sys-apps/install-xattr-0.5/work/install-xattr/install-xattr.c:245:17
    #3 0x7fdec8f02854 in __libc_start_main /tmp/portage/sys-libs/glibc-2.21-r1/work/glibc-2.21/csu/libc-start.c:289
Comment 1 Anthony Basile gentoo-dev 2015-11-17 11:44:02 UTC
(In reply to Agostino Sarubbo from comment #0)
> If install-xattr is compiled with address sanitizer, every emerge ends with:
> 
> 
> >>> Emerging (1 of 1) app-portage/eix-0.30.11::gentoo
>  * eix-0.30.11.tar.bz2 SHA256 SHA512 size ;-) ...                           
> [ ok ]
> 
> =================================================================
> ==24888==ERROR: LeakSanitizer: detected memory leaks
> 
> Direct leak of 4097 byte(s) in 1 object(s) allocated from:
>     #0 0x4bc202 in __interceptor_malloc
> /var/tmp/portage/sys-devel/llvm-3.6.1/work/llvm-3.6.1.src/projects/compiler-
> rt/lib/asan/asan_malloc_linux.cc:40:3
>     #1 0x46607c in __interceptor_realpath
> /var/tmp/portage/sys-devel/llvm-3.6.1/work/llvm-3.6.1.src/projects/compiler-
> rt/lib/sanitizer_common/sanitizer_common_interceptors.inc:2521:46
>     #2 0x4db6ae in main
> /tmp/portage/sys-apps/install-xattr-0.5/work/install-xattr/install-xattr.c:
> 245:17
>     #3 0x7fdec8f02854 in __libc_start_main
> /tmp/portage/sys-libs/glibc-2.21-r1/work/glibc-2.21/csu/libc-start.c:289

This is confusing because you are emerging eix but llvm's asan is pointing to install-xattr.  Can you give me steps to reproduce this when building outside of the portage environment?  Just unpack the tarball and run make.  See if you get the same problems at line 245.

Also, a memory leak in install-xattr is harmless.  It is a short lived process and even if we do identify it I may not fix it if it means extra coding gymnastics.  I would just add a comment.
Comment 2 Agostino Sarubbo gentoo-dev 2015-11-17 13:06:58 UTC
1) CC="clang" CFLAGS="-fsanitize=address" emerge -q install-xattr
2) type install-xattr and you will see the leak
Comment 3 SpanKY gentoo-dev 2017-03-14 18:07:24 UTC
just to be clear, not all leaks are bad.  if you allocated memory and then rely on exit() to free things, that's what we want.  doing a whole bunch of free() calls just before you exit is wasteful and needlessly slows things down.

that said, asan provides a define you can check for (__SANITIZE_ADDRESS__) so you can put all the free statements behind that to avoid slowing down the normal code path.
Comment 4 Agostino Sarubbo gentoo-dev 2017-03-15 08:10:05 UTC
if you think that it is not an issue, feel free to close.