在aarch64板valgrind不给予c++文件或函数名的地方是内存丢失

kzipqqlq  于 2022-12-24  发布在  其他
关注(0)|答案(1)|浏览(179)

Valgrind报告x86机器中的内存以及文件和函数名肯定会丢失。

    • x86计算机**

联阿援助团a:
第一个月
==8975== 30 bytes in 1 blocks are definitely lost in loss record 1 of 1
==8975== at 0x4C3289F: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
一个月三个月一次一个月四个月一次
==8975==
==8975== LEAK SUMMARY:
但是同样的代码在aarch64机器上运行时,valgrind不报告任何信息,比如文件名或函数名,尽管内存肯定丢失了。

    • aarch64委员会**

联阿援助团a:
Linux ds4 4.9.253-tegra #1 SMP PREEMPT Thu Feb 24 11:50:52 EST 2022 aarch64 aarch64 aarch64 GNU/Linux
==19468== 30 bytes in 1 blocks are definitely lost in loss record 1 of 1
==19468== at 0x48468F4: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-arm64-linux.so)
x1米10英寸1x
x1米11米1x
有人在aarch64中遇到过这个问题吗?如何在aarch64或任何类似的板的valgrind报告中获得函数,文件名,行号?
注:valgrind和编译器版本在x86和aarch64中是相同的。

8xiog9wr

8xiog9wr1#

这可能是因为程序是用不同的选项编译的。
我的测试设置:

uname -a
Linux nanopia64 5.15.80-sunxi64 #22.11.1 SMP Wed Nov 30 11:23:00 UTC 2022 aarch64 GNU/Linux

valgrind --version
valgrind-3.16.1

g++ --version
g++ (Debian 10.2.1-6) 10.2.1 20210110

不使用-g选项进行编译:

g++ -o test test.cpp
file test
test: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=5f8e07fd758a15c778106316219c916ce25f01b1, for GNU/Linux 3.7.0, not stripped

valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./test
    ==1621== Memcheck, a memory error detector
    ==1621== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
    ==1621== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
    ==1621== Command: ./test
    ==1621==
    Enter name
    name
    Hi name
    ==1621==
    ==1621== HEAP SUMMARY:
    ==1621==     in use at exit: 30 bytes in 1 blocks
    ==1621==   total heap usage: 4 allocs, 3 frees, 80,926 bytes allocated
    ==1621==
    ==1621== 30 bytes in 1 blocks are definitely lost in loss record 1 of 1
    ==1621==    at 0x484AB64: operator new[](unsigned long) (in /usr/lib/aarch64-linux-gnu/valgrind/vgpreload_memcheck-arm64-linux.so)
    ==1621==    by 0x108AF3: main (in /tmp/test)
    ==1621==
    ==1621== LEAK SUMMARY:
    ==1621==    definitely lost: 30 bytes in 1 blocks
    ==1621==    indirectly lost: 0 bytes in 0 blocks
    ==1621==      possibly lost: 0 bytes in 0 blocks
    ==1621==    still reachable: 0 bytes in 0 blocks
    ==1621==         suppressed: 0 bytes in 0 blocks
    ==1621==
    ==1621== For lists of detected and suppressed errors, rerun with: -s
    ==1621== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

使用-g选项编译:

g++ -o test test.cpp
file test
test: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=3933cca46b1e736fa497c658936c41c9bec603c9, for GNU/Linux 3.7.0, with debug_info, not stripped

valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./test
==1631== Memcheck, a memory error detector
==1631== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1631== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==1631== Command: ./test
==1631==
Enter name
name
Hi name
==1631==
==1631== HEAP SUMMARY:
==1631==     in use at exit: 30 bytes in 1 blocks
==1631==   total heap usage: 4 allocs, 3 frees, 80,926 bytes allocated
==1631==
==1631== 30 bytes in 1 blocks are definitely lost in loss record 1 of 1
==1631==    at 0x484AB64: operator new[](unsigned long) (in /usr/lib/aarch64-linux-gnu/valgrind/vgpreload_memcheck-arm64-linux.so)
==1631==    by 0x108AF3: main (test.cpp:6)
==1631==
==1631== LEAK SUMMARY:
==1631==    definitely lost: 30 bytes in 1 blocks
==1631==    indirectly lost: 0 bytes in 0 blocks
==1631==      possibly lost: 0 bytes in 0 blocks
==1631==    still reachable: 0 bytes in 0 blocks
==1631==         suppressed: 0 bytes in 0 blocks
==1631==
==1631== For lists of detected and suppressed errors, rerun with: -s
==1631== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

泄漏被正确地定位在main.cpp:6中,其中包含使用调试信息编译的可执行文件。

相关问题