运行 Valgrind:误报

问题描述 投票:0回答:1

我正在尝试设置 Valgrind 来检测应用程序本机部分可能存在的泄漏。

我已经成功地构建并让它在我的设备上运行,但我似乎遇到了一个错误,导致无论我在什么上使用它,都会检测到许多泄漏。

这是我在“ls”上使用 valgrind 的输出(应该出现 0 泄漏):

130|root@hwALE-H:/data/local/Inst/bin # ./valgrind ls
==16610== Memcheck, a memory error detector
==16610== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==16610== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==16610== Command: ls
==16610== 
WARNING: linker: /data/local/Inst/lib/valgrind/vgpreload_core-arm64-linux.so: unsupported flags DT_FLAGS_1=0x421
WARNING: linker: /data/local/Inst/lib/valgrind/vgpreload_memcheck-arm64-linux.so: unsupported flags DT_FLAGS_1=0x421
==16610== Invalid free() / delete / delete[] / realloc()
==16610==    at 0x487D7D4: free (vg_replace_malloc.c:530)
==16610==    by 0x40084FB: __dl__ZL12load_libraryilR10LinkedListI8LoadTask18TypeBasedAllocatorI15LinkedListEntryIS0_EEEPKciPK17android_dlextinfo (in /system/bin/linker64)
==16610==    by 0x40097AF: __dl__ZL14find_librariesP6soinfoPKPKcmPS0_PNSt3__16vectorIS0_NS6_9allocatorIS0_EEEEmiPK17android_dlextinfo (in /system/bin/linker64)
==16610==    by 0x400A883: __dl___linker_init (in /system/bin/linker64)
==16610==    by 0x40029EB: _start (in /system/bin/linker64)
==16610==    by 0x40029EB: _start (in /system/bin/linker64)
==16610==    by 0x40029EB: _start (in /system/bin/linker64)
==16610==    by 0x40029EB: _start (in /system/bin/linker64)
==16610==    by 0x40029EB: _start (in /system/bin/linker64)
==16610==    by 0x40029EB: _start (in /system/bin/linker64)
==16610==    by 0x40029EB: _start (in /system/bin/linker64)
==16610==    by 0x40029EB: _start (in /system/bin/linker64)
==16610==  Address 0x4039150 is in a rw- anonymous segment
==16610== 
==16610== Invalid free() / delete / delete[] / realloc()
==16610==    at 0x487D7D4: free (vg_replace_malloc.c:530)
==16610==    by 0x4009A43: __dl__ZL14find_librariesP6soinfoPKPKcmPS0_PNSt3__16vectorIS0_NS6_9allocatorIS0_EEEEmiPK17android_dlextinfo (in /system/bin/linker64)
==16610==    by 0x400A883: __dl___linker_init (in /system/bin/linker64)
==16610==    by 0x40029EB: _start (in /system/bin/linker64)
==16610==    by 0x40029EB: _start (in /system/bin/linker64)
==16610==    by 0x40029EB: _start (in /system/bin/linker64)
==16610==    by 0x40029EB: _start (in /system/bin/linker64)
==16610==    by 0x40029EB: _start (in /system/bin/linker64)
==16610==    by 0x40029EB: _start (in /system/bin/linker64)
==16610==    by 0x40029EB: _start (in /system/bin/linker64)
==16610==    by 0x40029EB: _start (in /system/bin/linker64)
==16610==    by 0x40029EB: _start (in /system/bin/linker64)
==16610==  Address 0x403e010 is in a rw- anonymous segment
==16610== 
callgrind_annotate
callgrind_control
cg_annotate
cg_diff
cg_merge
ms_print
valgrind
valgrind-di-server
valgrind-listener
vgdb
==16610== 
==16610== HEAP SUMMARY:
==16610==     in use at exit: 680 bytes in 12 blocks
==16610==   total heap usage: 58 allocs, 48 frees, 72,870 bytes allocated
==16610== 
==16610== LEAK SUMMARY:
==16610==    definitely lost: 352 bytes in 7 blocks
==16610==    indirectly lost: 0 bytes in 0 blocks
==16610==      possibly lost: 16 bytes in 1 blocks
==16610==    still reachable: 312 bytes in 4 blocks
==16610==         suppressed: 0 bytes in 0 blocks
==16610== Rerun with --leak-check=full to see details of leaked memory
==16610== 
==16610== For counts of detected and suppressed errors, rerun with: -v
==16610== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)

任何有助于解决此问题的建议将不胜感激!

编辑:这是启动“HelloJNI”类型应用程序的完整 logcat 输出,本机代码有 6 字节泄漏。 https://pastebin.com/j7TWC5Bu 痕迹几乎无法使用。

memory-leaks android-ndk valgrind arm64
1个回答
0
投票

我的猜测是,这是一次故意的“泄密”。

查看地址,链接加载器似乎正在使用基于全局内存块的“凹凸分配器”。由于此

malloc()
并未真正使用堆,因此无需释放内存。
    

© www.soinside.com 2019 - 2024. All rights reserved.