有时用valgrind定位内存泄露问题时当内存泄露的位置在动态库(so)中时, 输出的调用栈为问号"???"并且没有指明源码的行号.即使尝试了加 -g 的编译参数并且程序退出前不执行dlclose,也无济于事.
==29941== 17 bytes in 1 blocks are definitely lost in loss record 29 of 197
==29941== at 0x402A185: malloc (vg_replace_malloc.c:292)
==29941== by 0x4048585: ??? (in /home/xxx/ElastosRDKforDevice/Targets/rdk/x86.gnu.linux.dbg/bin/Elastos.Runtime.so)
==29941== by 0x40799F9: ??? (in /home/xxx/ElastosRDKforDevice/Targets/rdk/x86.gnu.linux.dbg/bin/Elastos.Runtime.so)
==29941== by 0x407AE2A: ??? (in /home/xxx/ElastosRDKforDevice/Targets/rdk/x86.gnu.linux.dbg/bin/Elastos.Runtime.so)
==29941== by 0x407ACC0: ??? (in /home/xxx/ElastosRDKforDevice/Targets/rdk/x86.gnu.linux.dbg/bin/Elastos.Runtime.so)
==29941== by 0x407ACF9: ??? (in /home/xxx/ElastosRDKforDevice/Targets/rdk/x86.gnu.linux.dbg/bin/Elastos.Runtime.so)
==29941== by 0x400ED76: call_init.part.

当valgrind在动态库中无法显示内存泄露的具体行号时,可以通过查找进程ID,分析maps文件,计算偏移地址,并利用addr2line工具确定源码行号,如在elstring/elsharedbuf.cpp的第9行。
最低0.47元/天 解锁文章
2万+

被折叠的 条评论
为什么被折叠?



