Public bug reported: Hello, today I found strange mamory leak in tail today.
Description: Ubuntu 16.04.1 LTS Release: 16.04 coreutils: Установлен: 8.25-2ubuntu2 Кандидат: 8.25-2ubuntu2 Таблица версий: *** 8.25-2ubuntu2 500 500 http://ru.archive.ubuntu.com/ubuntu xenial/main amd64 Packages 100 /var/lib/dpkg/status In such small test I have got report about memory leak. valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --trace-children=yes bash -c "echo A | tail -n 1" ==11802== Memcheck, a memory error detector ==11802== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==11802== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==11802== Command: bash -c echo\ A\ |\ tail\ -n\ 1 ==11802== ==11803== ==11803== HEAP SUMMARY: ==11803== in use at exit: 0 bytes in 0 blocks ==11803== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==11803== ==11803== All heap blocks were freed -- no leaks are possible ==11803== ==11803== For counts of detected and suppressed errors, rerun with: -v ==11803== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) ==11804== Memcheck, a memory error detector ==11804== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==11804== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==11804== Command: /usr/bin/tail -n 1 ==11804== A ==11804== ==11804== HEAP SUMMARY: ==11804== in use at exit: 96 bytes in 1 blocks ==11804== total heap usage: 101 allocs, 100 frees, 47,390 bytes allocated ==11804== ==11804== 96 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==11804== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==11804== by 0x409718: ??? (in /usr/bin/tail) ==11804== by 0x4022C8: ??? (in /usr/bin/tail) ==11804== by 0x4E5A82F: (below main) (libc-start.c:291) ==11804== ==11804== LEAK SUMMARY: ==11804== definitely lost: 96 bytes in 1 blocks ==11804== indirectly lost: 0 bytes in 0 blocks ==11804== possibly lost: 0 bytes in 0 blocks ==11804== still reachable: 0 bytes in 0 blocks ==11804== suppressed: 0 bytes in 0 blocks ==11804== ==11804== For counts of detected and suppressed errors, rerun with: -v ==11804== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) ==11802== ==11802== HEAP SUMMARY: ==11802== in use at exit: 0 bytes in 0 blocks ==11802== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==11802== ==11802== All heap blocks were freed -- no leaks are possible ==11802== ==11802== For counts of detected and suppressed errors, rerun with: -v ==11802== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) After it I rebuild coreutils from sources and retry my test. I got this report log. valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --trace-children=yes /bin/bash -c "echo A | ./src/tail" ==18178== Memcheck, a memory error detector ==18178== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==18178== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==18178== Command: /bin/bash -c echo\ A\ |\ ./src/tail ==18178== ==18180== Memcheck, a memory error detector ==18180== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==18180== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==18180== Command: ./src/tail ==18180== ==18179== ==18179== HEAP SUMMARY: ==18179== in use at exit: 0 bytes in 0 blocks ==18179== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==18179== ==18179== All heap blocks were freed -- no leaks are possible ==18179== ==18179== For counts of detected and suppressed errors, rerun with: -v ==18179== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) A ==18180== ==18180== HEAP SUMMARY: ==18180== in use at exit: 96 bytes in 1 blocks ==18180== total heap usage: 99 allocs, 98 frees, 47,249 bytes allocated ==18180== ==18180== 96 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==18180== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==18180== by 0x409738: xmalloc (xmalloc.c:41) ==18180== by 0x4022C8: xnmalloc (xalloc.h:108) ==18180== by 0x4022C8: main (tail.c:2301) ==18180== ==18180== LEAK SUMMARY: ==18180== definitely lost: 96 bytes in 1 blocks ==18180== indirectly lost: 0 bytes in 0 blocks ==18180== possibly lost: 0 bytes in 0 blocks ==18180== still reachable: 0 bytes in 0 blocks ==18180== suppressed: 0 bytes in 0 blocks ==18180== ==18180== For counts of detected and suppressed errors, rerun with: -v ==18180== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) ==18178== ==18178== HEAP SUMMARY: ==18178== in use at exit: 0 bytes in 0 blocks ==18178== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==18178== ==18178== All heap blocks were freed -- no leaks are possible ==18178== ==18178== For counts of detected and suppressed errors, rerun with: -v ==18178== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) I checked the source code of tail.c and at line 2400 found this instruction IF_LINT (free (F)); I found that this line not compiled by default. Use this make CFLAGS="-Dlint" define I turned on this option and problem was resolved. It's my final report after last recompile. valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --trace-children=yes /bin/bash -c "echo A | ./src/tail" ==25043== Memcheck, a memory error detector ==25043== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==25043== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==25043== Command: /bin/bash -c echo\ A\ |\ ./src/tail ==25043== ==25045== Memcheck, a memory error detector ==25045== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==25045== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==25045== Command: ./src/tail ==25045== ==25044== ==25044== HEAP SUMMARY: ==25044== in use at exit: 0 bytes in 0 blocks ==25044== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==25044== ==25044== All heap blocks were freed -- no leaks are possible ==25044== ==25044== For counts of detected and suppressed errors, rerun with: -v ==25044== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) A ==25045== ==25045== HEAP SUMMARY: ==25045== in use at exit: 0 bytes in 0 blocks ==25045== total heap usage: 99 allocs, 99 frees, 47,249 bytes allocated ==25045== ==25045== All heap blocks were freed -- no leaks are possible ==25045== ==25045== For counts of detected and suppressed errors, rerun with: -v ==25045== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) ==25043== ==25043== HEAP SUMMARY: ==25043== in use at exit: 0 bytes in 0 blocks ==25043== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==25043== ==25043== All heap blocks were freed -- no leaks are possible ==25043== ==25043== For counts of detected and suppressed errors, rerun with: -v ==25043== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) So this macros really help to resolve problem. Can anyone fix this problem for package from distro? ** Affects: coreutils (Ubuntu) Importance: Undecided Status: New -- You received this bug notification because you are a member of Ubuntu Touch seeded packages, which is subscribed to coreutils in Ubuntu. https://bugs.launchpad.net/bugs/1649296 Title: tail memory leak Status in coreutils package in Ubuntu: New Bug description: Hello, today I found strange mamory leak in tail today. Description: Ubuntu 16.04.1 LTS Release: 16.04 coreutils: Установлен: 8.25-2ubuntu2 Кандидат: 8.25-2ubuntu2 Таблица версий: *** 8.25-2ubuntu2 500 500 http://ru.archive.ubuntu.com/ubuntu xenial/main amd64 Packages 100 /var/lib/dpkg/status In such small test I have got report about memory leak. valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --trace-children=yes bash -c "echo A | tail -n 1" ==11802== Memcheck, a memory error detector ==11802== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==11802== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==11802== Command: bash -c echo\ A\ |\ tail\ -n\ 1 ==11802== ==11803== ==11803== HEAP SUMMARY: ==11803== in use at exit: 0 bytes in 0 blocks ==11803== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==11803== ==11803== All heap blocks were freed -- no leaks are possible ==11803== ==11803== For counts of detected and suppressed errors, rerun with: -v ==11803== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) ==11804== Memcheck, a memory error detector ==11804== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==11804== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==11804== Command: /usr/bin/tail -n 1 ==11804== A ==11804== ==11804== HEAP SUMMARY: ==11804== in use at exit: 96 bytes in 1 blocks ==11804== total heap usage: 101 allocs, 100 frees, 47,390 bytes allocated ==11804== ==11804== 96 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==11804== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==11804== by 0x409718: ??? (in /usr/bin/tail) ==11804== by 0x4022C8: ??? (in /usr/bin/tail) ==11804== by 0x4E5A82F: (below main) (libc-start.c:291) ==11804== ==11804== LEAK SUMMARY: ==11804== definitely lost: 96 bytes in 1 blocks ==11804== indirectly lost: 0 bytes in 0 blocks ==11804== possibly lost: 0 bytes in 0 blocks ==11804== still reachable: 0 bytes in 0 blocks ==11804== suppressed: 0 bytes in 0 blocks ==11804== ==11804== For counts of detected and suppressed errors, rerun with: -v ==11804== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) ==11802== ==11802== HEAP SUMMARY: ==11802== in use at exit: 0 bytes in 0 blocks ==11802== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==11802== ==11802== All heap blocks were freed -- no leaks are possible ==11802== ==11802== For counts of detected and suppressed errors, rerun with: -v ==11802== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) After it I rebuild coreutils from sources and retry my test. I got this report log. valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --trace-children=yes /bin/bash -c "echo A | ./src/tail" ==18178== Memcheck, a memory error detector ==18178== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==18178== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==18178== Command: /bin/bash -c echo\ A\ |\ ./src/tail ==18178== ==18180== Memcheck, a memory error detector ==18180== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==18180== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==18180== Command: ./src/tail ==18180== ==18179== ==18179== HEAP SUMMARY: ==18179== in use at exit: 0 bytes in 0 blocks ==18179== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==18179== ==18179== All heap blocks were freed -- no leaks are possible ==18179== ==18179== For counts of detected and suppressed errors, rerun with: -v ==18179== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) A ==18180== ==18180== HEAP SUMMARY: ==18180== in use at exit: 96 bytes in 1 blocks ==18180== total heap usage: 99 allocs, 98 frees, 47,249 bytes allocated ==18180== ==18180== 96 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==18180== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==18180== by 0x409738: xmalloc (xmalloc.c:41) ==18180== by 0x4022C8: xnmalloc (xalloc.h:108) ==18180== by 0x4022C8: main (tail.c:2301) ==18180== ==18180== LEAK SUMMARY: ==18180== definitely lost: 96 bytes in 1 blocks ==18180== indirectly lost: 0 bytes in 0 blocks ==18180== possibly lost: 0 bytes in 0 blocks ==18180== still reachable: 0 bytes in 0 blocks ==18180== suppressed: 0 bytes in 0 blocks ==18180== ==18180== For counts of detected and suppressed errors, rerun with: -v ==18180== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) ==18178== ==18178== HEAP SUMMARY: ==18178== in use at exit: 0 bytes in 0 blocks ==18178== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==18178== ==18178== All heap blocks were freed -- no leaks are possible ==18178== ==18178== For counts of detected and suppressed errors, rerun with: -v ==18178== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) I checked the source code of tail.c and at line 2400 found this instruction IF_LINT (free (F)); I found that this line not compiled by default. Use this make CFLAGS="-Dlint" define I turned on this option and problem was resolved. It's my final report after last recompile. valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --trace-children=yes /bin/bash -c "echo A | ./src/tail" ==25043== Memcheck, a memory error detector ==25043== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==25043== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==25043== Command: /bin/bash -c echo\ A\ |\ ./src/tail ==25043== ==25045== Memcheck, a memory error detector ==25045== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==25045== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==25045== Command: ./src/tail ==25045== ==25044== ==25044== HEAP SUMMARY: ==25044== in use at exit: 0 bytes in 0 blocks ==25044== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==25044== ==25044== All heap blocks were freed -- no leaks are possible ==25044== ==25044== For counts of detected and suppressed errors, rerun with: -v ==25044== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) A ==25045== ==25045== HEAP SUMMARY: ==25045== in use at exit: 0 bytes in 0 blocks ==25045== total heap usage: 99 allocs, 99 frees, 47,249 bytes allocated ==25045== ==25045== All heap blocks were freed -- no leaks are possible ==25045== ==25045== For counts of detected and suppressed errors, rerun with: -v ==25045== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) ==25043== ==25043== HEAP SUMMARY: ==25043== in use at exit: 0 bytes in 0 blocks ==25043== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==25043== ==25043== All heap blocks were freed -- no leaks are possible ==25043== ==25043== For counts of detected and suppressed errors, rerun with: -v ==25043== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) So this macros really help to resolve problem. Can anyone fix this problem for package from distro? To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/1649296/+subscriptions -- Mailing list: https://launchpad.net/~touch-packages Post to : touch-packages@lists.launchpad.net Unsubscribe : https://launchpad.net/~touch-packages More help : https://help.launchpad.net/ListHelp