Hi, yubiao hu <huyubi...@gmail.com> writes:
> Package: coreutils > Version: 9.4 > Severity: normal > > I was trying to build coreutils with ASan, and found a memory leak in expr. > > When running: > expr length "hello" > > Output: > ================================================================= > ==755058==ERROR: LeakSanitizer: detected memory leaks > > Direct leak of 24 byte(s) in 1 object(s) allocated from: > #0 0xffff7f7a2524 in __interceptor_malloc > ../../../../libsanitizer/asan/asan_malloc_linux.cpp:69 > #1 0xaaaacd31f4c8 in xmalloc ../lib/xmalloc.c:45 > #2 0xaaaacd2a0dd4 in int_value ../src/expr.c:369 > #3 0xaaaacd2a0dd4 in eval6 ../src/expr.c:714 > #4 0xaaaacd2a0dd4 in eval6 ../src/expr.c:694 > #5 0xaaaacd2a4f44 in eval5 ../src/expr.c:786 > #6 0xaaaacd2a5320 in eval4 ../src/expr.c:817 > #7 0xaaaacd2a595c in eval3 ../src/expr.c:856 > #8 0xaaaacd2a5dbc in eval2 ../src/expr.c:886 > #9 0xaaaacd2a72e0 in eval1 ../src/expr.c:965 > #10 0xaaaacd2a7874 in eval ../src/expr.c:996 > #11 0xaaaacd29d3e0 in main ../src/expr.c:352 I recommend running the following in your shell before testing with address sanitizer: $ export ASAN_OPTIONS="detect_leaks=0 Most (all?) of the programs in Coreutils will not free memory before exit, since it just takes extra time for no benefit. Also, I expect most other GNU programs to behave this way. Since it is the behavior recommended in the GNU Coding Standards [1]. Thanks, Collin [1] https://www.gnu.org/prep/standards/standards.html#Memory-Usage