链接ArmPL与Pthread时Valgrind出现readdwarf.c断言失败求助
Valgrind在Jetson平台同时链接ArmPL与Pthread时触发断言失败
问题现象
在Nvidia Jetson平台使用Valgrind调试程序,只要同时链接ArmPL(Arm性能库)和Pthread库,程序启动就会触发断言失败。单独链接其中任意一个库则无异常。
最小复现代码
#include <iostream> int main(int argc, char *argv[]) { std::cout << "Hello, world!" << std::endl; }
编译命令
g++ -g -O0 main.cpp -L/mnt/data/opt/lib -larmpl -lpthread
运行命令
valgrind ./a.out
错误输出
==8903== Memcheck, a memory error detector ==8903== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==8903== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info ==8903== Command: ./a.out ==8903== --8903-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x11 --8903-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x11 --8903-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x11 --8903-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x11 --8903-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x11 --8903-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x11 --8903-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x11 --8903-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x11 --8903-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x11 --8903-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x11 --8903-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x11 --8903-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x11 --8903-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x11 --8903-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x11 --8903-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x11 --8903-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x11 --8903-- Warning: DWARF2 CFI reader: unhandled DW_OP_ opcode 0x11 valgrind: m_debuginfo/readdwarf.c:2396 (copy_convert_CfiExpr_tree): Assertion 'srcix >= 0 && srcix < VG_(sizeXA)(srcxa)' failed. host stacktrace: ==8903== at 0x5803DBA0: ??? (in /usr/lib/valgrind/memcheck-arm64-linux) sched status: running_tid=1 Thread 1: status = VgTs_Runnable (lwpid 8903) ==8903== at 0x4016D44: mmap (mmap64.c:59) ==8903== by 0x4005627: _dl_map_segments (dl-map-segments.h:94) ==8903== by 0x4005627: _dl_map_object_from_fd (dl-load.c:1181) ==8903== by 0x4007C5F: _dl_map_object (dl-load.c:2460) ==8903== by 0x400BCE7: openaux (dl-deps.c:63) ==8903== by 0x4015A53: _dl_catch_exception (dl-error-skeleton.c:196) ==8903== by 0x400C057: _dl_map_object_deps (dl-deps.c:249) ==8903== by 0x40037EF: dl_main (rtld.c:1726) ==8903== by 0x4014D6F: _dl_sysdep_start (dl-sysdep.c:253) ==8903== by 0x40018C3: _dl_start_final (rtld.c:414) ==8903== by 0x4001B47: _dl_start (rtld.c:523) ==8903== by 0x40011C7: ??? (in /lib/aarch64-linux-gnu/ld-2.27.so) Note: see also the FAQ in the source distribution. It contains workarounds to several common problems. In particular, if Valgrind aborted or crashed after identifying problems in your program, there's a good chance that fixing those problems will prevent Valgrind aborting or crashing, especially if it happened in m_mallocfree.c. If that doesn't help, please report this bug to: www.valgrind.org In the bug report, send all the above text, the valgrind version, and what OS and version you are using. Thanks.
系统环境
Nvidia Jetson AGX Xavier Ubuntu 18.04 gcc version 7.5.0 valgrind version 3.13.0 ArmPL version 21.1_Ubuntu-18.04_gcc-7.5
可行的排查与解决方向
- 升级Valgrind版本:当前使用的3.13.0版本较旧,后续版本大概率修复了DWARF2调试信息解析的兼容问题,建议升级到最新稳定版。
- 调整链接顺序:交换
-larmpl和-lpthread的位置,改为g++ -g -O0 main.cpp -L/mnt/data/opt/lib -lpthread -larmpl,链接顺序会影响库依赖的解析逻辑。 - 去除ArmPL的调试符号:用
strip工具清理ArmPL库的调试信息,命令示例:strip /mnt/data/opt/lib/libarmpl.so,再重新编译链接。 - 跳过有问题的调试信息解析:启动Valgrind时添加
--debuginfo=0参数,强制跳过调试信息解析,但会影响调试时的符号显示。
内容的提问来源于stack exchange,提问作者Wolfy
相关产品推荐
相关产品推荐

