You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

已配置debuginfod但GDB仍不显示符号的问题求助

问题描述

调试服务启动时触发SIGSEGV错误,已配置debuginfod且GDB成功下载了系统库的调试信息,但堆栈跟踪中仍出现?? ()的无符号条目。启动GDB的命令为:

sudo DEBUGINFOD_URLS=https://debuginfod.archlinux.org gdb --args ./build/dns-wrapper --config-file config/config.ini

GDB相关输出如下:

GNU gdb (GDB) 15.1
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./build/dns-wrapper...
(gdb) r
Starting program: /home/ncd/git/dns-wrapper/build/dns-wrapper --config-file config/config.ini
Downloading separate debug info for /lib64/ld-linux-x86-64.so.2
Downloading separate debug info for system-supplied DSO at 0x7ffff7fc5000
Downloading separate debug info for /usr/lib/libboost_system.so.1.86.0
Downloading separate debug info for /usr/lib/libboost_program_options.so.1.86.0
Downloading separate debug info for /usr/lib/libboost_log_setup.so.1.86.0
Downloading separate debug info for /usr/lib/libboost_log.so.1.86.0
Downloading separate debug info for /usr/lib/libboost_thread.so.1.86.0
Downloading separate debug info for /usr/lib/libboost_atomic.so.1.86.0
Downloading separate debug info for /usr/lib/libboost_chrono.so.1.86.0
Downloading separate debug info for /usr/lib/libboost_filesystem.so.1.86.0
Downloading separate debug info for /usr/lib/libm.so.6
Downloading separate debug info for /usr/lib/libc.so.6
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Upstream server identified as: udp://1.1.1.1:53
Upstream server identified as: udp://8.8.8.8:53
[2024-09-28 18:53:39.662405] [0x00007ffff7d39940] [trace] [0x0008a1ea] [1] Dns Wrapper v0.0.0.1
[2024-09-28 18:53:39.662521] [0x00007ffff7d39940] [trace] [0x0008a1ea] [2] Git branch: win_raw_socket, Version: 01b16b2e-dirty, Commit: 01b16b2e-dirty, Date: 2024-09-28 10:24:37 +0530
[2024-09-28 18:53:39.662533] [0x00007ffff7d39940] [trace] [0x0008a1ea] [3] Current User: root
[2024-09-28 18:53:39.662540] [0x00007ffff7d39940] [trace] [0x0008a1ea] [4] Compiled for x86_64 (compiled locally) using cc (GCC) 14.2.1 20240910
[2024-09-28 18:53:39.662760] [0x00007ffff7d39940] [info] [0x0008a1ea] [5] Successfully read rules from file: ./rules.txt
[2024-09-28 18:53:39.662997] [0x00007ffff7d39940] [debug] [0x0008a1ea] [6] Skipping entering into daemon mode as per user request
[2024-09-28 18:53:39.663053] [0x00007ffff7d39940] [trace] [0x0008a1ea] [7] Daemon started on port: 10053

Program received signal SIGSEGV, Segmentation fault.
0x00005555555f43ed in boost::asio::detail::socket_ops::call_recvfrom<unsigned int> (s=8, data=0x7ffffffeab80, size=65535, flags=0, addr=0x7fffffffa740, 
    addrlen=0x7fffffffa890) at /usr/include/boost/asio/detail/impl/socket_ops.ipp:1130
1130    }
(gdb) where
#0  0x00005555555f43ed in boost::asio::detail::socket_ops::call_recvfrom<unsigned int> (s=8, data=0x7ffffffeab80, size=65535, flags=0, addr=0x7fffffffa740, 
    addrlen=0x7fffffffa890) at /usr/include/boost/asio/detail/impl/socket_ops.ipp:1130
#1  0x2851232006040001 in ?? ()
#2  0x00007fff0000fe51 in ?? ()
#3  0x0000000000000000 in ?? ()
(gdb) show debuginfod enabled
Debuginfod functionality is currently set to "on".
(gdb) show debuginfod urls
Debuginfod URLs are currently set to:
https://debuginfod.archlinux.org
(gdb) bt full
#0  0x00005555555f43ed in boost::asio::detail::socket_ops::call_recvfrom<unsigned int> (s=8, data=0x7ffffffeab80, size=65535, flags=0, addr=0x7fffffffa740, 
    addrlen=0x7fffffffa890) at /usr/include/boost/asio/detail/impl/socket_ops.ipp:1130
        tmp_addrlen = 20
        result = 561
#1  0x2851232006040001 in ?? ()
No symbol table info available.
#2  0x00007fff0000fe51 in ?? ()
No symbol table info available.
#3  0x0000000000000000 in ?? ()
No symbol table info available.
解决思路与步骤

首先明确:堆栈中的?? ()不是因为符号未加载,而是程序崩溃时栈帧已被破坏——#1的地址0x2851232006040001不属于x86_64合法用户空间地址范围(通常为0x555555554000~0x7fffffffffff),说明栈内存已被非法写入篡改。

可按以下步骤排查:

  • 检查崩溃点参数合法性:当前崩溃在boost::asio::detail::socket_ops::call_recvfrom,先验证参数:
    • 用info fd命令查看进程打开的文件描述符,确认s=8对应的是合法的UDP/TCP socket,且未被关闭。
    • 用x/x 0x7fffffffa890查看addrlen指针指向的内存值,确认是有效的sockaddr长度(如sockaddr_in对应16,sockaddr_in6对应28),且该内存区域未被越界覆盖。
  • 生成并分析core dump:
    1. 在启动GDB的终端执行ulimit -c unlimited,设置core dump大小无限制。
    2. 程序崩溃后生成core文件,用gdb ./build/dns-wrapper core.xxx加载core文件,尝试获取更完整的栈信息(若core未被破坏)。
  • 调整编译选项:确保编译程序时添加-g -O0参数,禁用优化并保留完整调试符号——优化编译会打乱栈帧结构,导致GDB无法正确解析调用栈。
  • 排查多线程内存问题:若程序使用多线程,检查是否存在线程安全问题:
    • 确认socket资源未被多个线程同时读写。
    • 检查栈上变量是否被其他线程非法访问(如指针越界写入栈内存)。
  • 启用GDB栈保护检查:在GDB中执行set canary on,启用栈金丝雀检查帮助定位栈溢出问题;也可用checksec ./build/dns-wrapper查看程序是否开启了栈保护编译选项。

内容的提问来源于stack exchange,提问作者slb

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 21:44:53