Valgrind exitcode = 0 无论错误与 --error-exitcode 设置为非零
Valgrind exitcode = 0 regardles on errors with --error-exitcode set to nonzero
我正在使用 valgrind 3.15 和 3.17。
我是 运行 valgrind,在 gitlab-CI 管道中工作,如果有任何泄漏或内存问题,我希望管道失败。
我可以在 ls 上显示它,它有漏洞:
$ valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --error-exitcode=1 ls && echo no failure
==535364== Memcheck, a memory error detector
==535364== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==535364== Using Valgrind-3.17.0 and LibVEX; rerun with -h for copyright info
==535364== Command: ls
==535364==
25_s1.pcap.log
==535364==
==535364== HEAP SUMMARY:
==535364== in use at exit: 20,351 bytes in 8 blocks
==535364== total heap usage: 45 allocs, 37 frees, 59,906 bytes allocated
==535364==
==535364== 15 bytes in 1 blocks are still reachable in loss record 1 of 8
==535364== at 0x4843839: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==535364== by 0x11F4FE: ??? (in /usr/bin/ls)
==535364== by 0x1136D4: ??? (in /usr/bin/ls)
==535364== by 0x11586E: ??? (in /usr/bin/ls)
==535364== by 0x10D434: ??? (in /usr/bin/ls)
==535364== by 0x48E2FCF: __libc_start_call_main (libc_start_call_main.h:58)
==535364== by 0x48E307C: __libc_start_main@@GLIBC_2.34 (libc-start.c:409)
==535364== by 0x10E83D: ??? (in /usr/bin/ls)
==535364== by 0x1FFEFFFEE7: ???
==535364== by 0x1B: ???
==535364==
==535364== 24 bytes in 1 blocks are still reachable in loss record 2 of 8
==535364== at 0x4843839: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==535364== by 0x11F37C: ??? (in /usr/bin/ls)
==535364== by 0x110AF8: ??? (in /usr/bin/ls)
==535364== by 0x1156B8: ??? (in /usr/bin/ls)
==535364== by 0x10D434: ??? (in /usr/bin/ls)
==535364== by 0x48E2FCF: __libc_start_call_main (libc_start_call_main.h:58)
==535364== by 0x48E307C: __libc_start_main@@GLIBC_2.34 (libc-start.c:409)
==535364== by 0x10E83D: ??? (in /usr/bin/ls)
==535364== by 0x1FFEFFFEE7: ???
==535364== by 0x1B: ???
==535364==
==535364== 24 bytes in 1 blocks are still reachable in loss record 3 of 8
==535364== at 0x4843839: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==535364== by 0x11F37C: ??? (in /usr/bin/ls)
==535364== by 0x110765: ??? (in /usr/bin/ls)
==535364== by 0x11519F: ??? (in /usr/bin/ls)
==535364== by 0x10D434: ??? (in /usr/bin/ls)
==535364== by 0x48E2FCF: __libc_start_call_main (libc_start_call_main.h:58)
==535364== by 0x48E307C: __libc_start_main@@GLIBC_2.34 (libc-start.c:409)
==535364== by 0x10E83D: ??? (in /usr/bin/ls)
==535364== by 0x1FFEFFFEE7: ???
==535364== by 0x1B: ???
==535364==
==535364== 48 bytes in 1 blocks are still reachable in loss record 4 of 8
==535364== at 0x4843749: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==535364== by 0x11F3A9: ??? (in /usr/bin/ls)
==535364== by 0x110944: ??? (in /usr/bin/ls)
==535364== by 0x11519F: ??? (in /usr/bin/ls)
==535364== by 0x10D434: ??? (in /usr/bin/ls)
==535364== by 0x48E2FCF: __libc_start_call_main (libc_start_call_main.h:58)
==535364== by 0x48E307C: __libc_start_main@@GLIBC_2.34 (libc-start.c:409)
==535364== by 0x10E83D: ??? (in /usr/bin/ls)
==535364== by 0x1FFEFFFEE7: ???
==535364== by 0x1B: ???
==535364==
==535364== 56 bytes in 1 blocks are still reachable in loss record 5 of 8
==535364== at 0x4843839: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==535364== by 0x11F4B8: ??? (in /usr/bin/ls)
==535364== by 0x11DD00: ??? (in /usr/bin/ls)
==535364== by 0x10D201: ??? (in /usr/bin/ls)
==535364== by 0x48E2FCF: __libc_start_call_main (libc_start_call_main.h:58)
==535364== by 0x48E307C: __libc_start_main@@GLIBC_2.34 (libc-start.c:409)
==535364== by 0x10E83D: ??? (in /usr/bin/ls)
==535364== by 0x1FFEFFFEE7: ???
==535364== by 0x1B: ???
==535364==
==535364== 56 bytes in 1 blocks are still reachable in loss record 6 of 8
==535364== at 0x4843839: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==535364== by 0x11F4B8: ??? (in /usr/bin/ls)
==535364== by 0x11DD00: ??? (in /usr/bin/ls)
==535364== by 0x10D25D: ??? (in /usr/bin/ls)
==535364== by 0x48E2FCF: __libc_start_call_main (libc_start_call_main.h:58)
==535364== by 0x48E307C: __libc_start_main@@GLIBC_2.34 (libc-start.c:409)
==535364== by 0x10E83D: ??? (in /usr/bin/ls)
==535364== by 0x1FFEFFFEE7: ???
==535364== by 0x1B: ???
==535364==
==535364== 128 bytes in 1 blocks are still reachable in loss record 7 of 8
==535364== at 0x4843839: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==535364== by 0x1203C9: ??? (in /usr/bin/ls)
==535364== by 0x10D355: ??? (in /usr/bin/ls)
==535364== by 0x48E2FCF: __libc_start_call_main (libc_start_call_main.h:58)
==535364== by 0x48E307C: __libc_start_main@@GLIBC_2.34 (libc-start.c:409)
==535364== by 0x10E83D: ??? (in /usr/bin/ls)
==535364== by 0x1FFEFFFEE7: ???
==535364== by 0x1B: ???
==535364==
==535364== 20,000 bytes in 1 blocks are still reachable in loss record 8 of 8
==535364== at 0x4843839: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==535364== by 0x11F37C: ??? (in /usr/bin/ls)
==535364== by 0x10D3C6: ??? (in /usr/bin/ls)
==535364== by 0x48E2FCF: __libc_start_call_main (libc_start_call_main.h:58)
==535364== by 0x48E307C: __libc_start_main@@GLIBC_2.34 (libc-start.c:409)
==535364== by 0x10E83D: ??? (in /usr/bin/ls)
==535364== by 0x1FFEFFFEE7: ???
==535364== by 0x1B: ???
==535364==
==535364== LEAK SUMMARY:
==535364== definitely lost: 0 bytes in 0 blocks
==535364== indirectly lost: 0 bytes in 0 blocks
==535364== possibly lost: 0 bytes in 0 blocks
==535364== still reachable: 20,351 bytes in 8 blocks
==535364== suppressed: 0 bytes in 0 blocks
==535364==
==535364== For lists of detected and suppressed errors, rerun with: -s
==535364== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
no failure
我做错了什么?
我会错过任何配置吗?
它有什么潜规则吗? (就像应该显示泄漏一样,但它们确实存在)。
默认情况下,只有确定和可能的泄漏才被视为错误。
你可以使用例如--errors-for-leak-kinds=all 将所有泄漏类型视为错误:
--errors-for-leak-kinds=kind1,kind2,.. which leak kinds are errors?
[definite,possible]
where kind is one of:
definite indirect possible reachable all none
我正在使用 valgrind 3.15 和 3.17。 我是 运行 valgrind,在 gitlab-CI 管道中工作,如果有任何泄漏或内存问题,我希望管道失败。
我可以在 ls 上显示它,它有漏洞:
$ valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --error-exitcode=1 ls && echo no failure
==535364== Memcheck, a memory error detector
==535364== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==535364== Using Valgrind-3.17.0 and LibVEX; rerun with -h for copyright info
==535364== Command: ls
==535364==
25_s1.pcap.log
==535364==
==535364== HEAP SUMMARY:
==535364== in use at exit: 20,351 bytes in 8 blocks
==535364== total heap usage: 45 allocs, 37 frees, 59,906 bytes allocated
==535364==
==535364== 15 bytes in 1 blocks are still reachable in loss record 1 of 8
==535364== at 0x4843839: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==535364== by 0x11F4FE: ??? (in /usr/bin/ls)
==535364== by 0x1136D4: ??? (in /usr/bin/ls)
==535364== by 0x11586E: ??? (in /usr/bin/ls)
==535364== by 0x10D434: ??? (in /usr/bin/ls)
==535364== by 0x48E2FCF: __libc_start_call_main (libc_start_call_main.h:58)
==535364== by 0x48E307C: __libc_start_main@@GLIBC_2.34 (libc-start.c:409)
==535364== by 0x10E83D: ??? (in /usr/bin/ls)
==535364== by 0x1FFEFFFEE7: ???
==535364== by 0x1B: ???
==535364==
==535364== 24 bytes in 1 blocks are still reachable in loss record 2 of 8
==535364== at 0x4843839: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==535364== by 0x11F37C: ??? (in /usr/bin/ls)
==535364== by 0x110AF8: ??? (in /usr/bin/ls)
==535364== by 0x1156B8: ??? (in /usr/bin/ls)
==535364== by 0x10D434: ??? (in /usr/bin/ls)
==535364== by 0x48E2FCF: __libc_start_call_main (libc_start_call_main.h:58)
==535364== by 0x48E307C: __libc_start_main@@GLIBC_2.34 (libc-start.c:409)
==535364== by 0x10E83D: ??? (in /usr/bin/ls)
==535364== by 0x1FFEFFFEE7: ???
==535364== by 0x1B: ???
==535364==
==535364== 24 bytes in 1 blocks are still reachable in loss record 3 of 8
==535364== at 0x4843839: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==535364== by 0x11F37C: ??? (in /usr/bin/ls)
==535364== by 0x110765: ??? (in /usr/bin/ls)
==535364== by 0x11519F: ??? (in /usr/bin/ls)
==535364== by 0x10D434: ??? (in /usr/bin/ls)
==535364== by 0x48E2FCF: __libc_start_call_main (libc_start_call_main.h:58)
==535364== by 0x48E307C: __libc_start_main@@GLIBC_2.34 (libc-start.c:409)
==535364== by 0x10E83D: ??? (in /usr/bin/ls)
==535364== by 0x1FFEFFFEE7: ???
==535364== by 0x1B: ???
==535364==
==535364== 48 bytes in 1 blocks are still reachable in loss record 4 of 8
==535364== at 0x4843749: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==535364== by 0x11F3A9: ??? (in /usr/bin/ls)
==535364== by 0x110944: ??? (in /usr/bin/ls)
==535364== by 0x11519F: ??? (in /usr/bin/ls)
==535364== by 0x10D434: ??? (in /usr/bin/ls)
==535364== by 0x48E2FCF: __libc_start_call_main (libc_start_call_main.h:58)
==535364== by 0x48E307C: __libc_start_main@@GLIBC_2.34 (libc-start.c:409)
==535364== by 0x10E83D: ??? (in /usr/bin/ls)
==535364== by 0x1FFEFFFEE7: ???
==535364== by 0x1B: ???
==535364==
==535364== 56 bytes in 1 blocks are still reachable in loss record 5 of 8
==535364== at 0x4843839: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==535364== by 0x11F4B8: ??? (in /usr/bin/ls)
==535364== by 0x11DD00: ??? (in /usr/bin/ls)
==535364== by 0x10D201: ??? (in /usr/bin/ls)
==535364== by 0x48E2FCF: __libc_start_call_main (libc_start_call_main.h:58)
==535364== by 0x48E307C: __libc_start_main@@GLIBC_2.34 (libc-start.c:409)
==535364== by 0x10E83D: ??? (in /usr/bin/ls)
==535364== by 0x1FFEFFFEE7: ???
==535364== by 0x1B: ???
==535364==
==535364== 56 bytes in 1 blocks are still reachable in loss record 6 of 8
==535364== at 0x4843839: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==535364== by 0x11F4B8: ??? (in /usr/bin/ls)
==535364== by 0x11DD00: ??? (in /usr/bin/ls)
==535364== by 0x10D25D: ??? (in /usr/bin/ls)
==535364== by 0x48E2FCF: __libc_start_call_main (libc_start_call_main.h:58)
==535364== by 0x48E307C: __libc_start_main@@GLIBC_2.34 (libc-start.c:409)
==535364== by 0x10E83D: ??? (in /usr/bin/ls)
==535364== by 0x1FFEFFFEE7: ???
==535364== by 0x1B: ???
==535364==
==535364== 128 bytes in 1 blocks are still reachable in loss record 7 of 8
==535364== at 0x4843839: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==535364== by 0x1203C9: ??? (in /usr/bin/ls)
==535364== by 0x10D355: ??? (in /usr/bin/ls)
==535364== by 0x48E2FCF: __libc_start_call_main (libc_start_call_main.h:58)
==535364== by 0x48E307C: __libc_start_main@@GLIBC_2.34 (libc-start.c:409)
==535364== by 0x10E83D: ??? (in /usr/bin/ls)
==535364== by 0x1FFEFFFEE7: ???
==535364== by 0x1B: ???
==535364==
==535364== 20,000 bytes in 1 blocks are still reachable in loss record 8 of 8
==535364== at 0x4843839: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==535364== by 0x11F37C: ??? (in /usr/bin/ls)
==535364== by 0x10D3C6: ??? (in /usr/bin/ls)
==535364== by 0x48E2FCF: __libc_start_call_main (libc_start_call_main.h:58)
==535364== by 0x48E307C: __libc_start_main@@GLIBC_2.34 (libc-start.c:409)
==535364== by 0x10E83D: ??? (in /usr/bin/ls)
==535364== by 0x1FFEFFFEE7: ???
==535364== by 0x1B: ???
==535364==
==535364== LEAK SUMMARY:
==535364== definitely lost: 0 bytes in 0 blocks
==535364== indirectly lost: 0 bytes in 0 blocks
==535364== possibly lost: 0 bytes in 0 blocks
==535364== still reachable: 20,351 bytes in 8 blocks
==535364== suppressed: 0 bytes in 0 blocks
==535364==
==535364== For lists of detected and suppressed errors, rerun with: -s
==535364== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
no failure
我做错了什么? 我会错过任何配置吗? 它有什么潜规则吗? (就像应该显示泄漏一样,但它们确实存在)。
默认情况下,只有确定和可能的泄漏才被视为错误。 你可以使用例如--errors-for-leak-kinds=all 将所有泄漏类型视为错误:
--errors-for-leak-kinds=kind1,kind2,.. which leak kinds are errors? [definite,possible] where kind is one of: definite indirect possible reachable all none