linux - ARM Linux 上的 "Backtrace stopped: previous frame identical to this frame (corrupt stack?)"

标签 linux gdb arm valgrind stack-corruption

我正在尝试在 Linux(ARM 架构)上运行应用程序时调试段错误。我复制了核心转储文件并尝试在 x86_64 主机上使用arm-gdb 获取回溯。这是o/p:

$ arm-arago-linux-gnueabi-gdb test_slave6_slave core
GNU gdb (GDB) 7.4
Copyright (C) 2012 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 "--host=i686-oesdk-linux --target=arm-oe-linux-gnueabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/dvdk/test_slave6_slave...done.

warning: exec file is newer than core file.
[New LWP 6411]
[New LWP 6410]

warning: Could not load shared library symbols for 12 libraries, e.g. /lib/libjson-c.so.2.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
Core was generated by `/usr/bin/test_slave6_slave 5 111.111.111.111 1 2 1 2'.
Program terminated with signal 11, Segmentation fault.
#0  0x47b61dd4 in ?? ()
(gdb) bt
#0  0x47b61dd4 in ?? ()
#1  0x47b2e0fc in ?? ()
#2  0x47b2e0fc in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)

(时间戳警告可能是因为我先复制了核心文件)

我不认为this问题和我的问题与我获得有效地址相同。我认为这仍然是一个堆栈损坏问题。但我不确定如何进一步调试。我应该使用 GDB 还是 valgrind?有人可以指出我使用这些工具进行调试的正确步骤吗?例如,我应该将 memecheck 与 valgrind 以及 Leak_check 一起使用吗?

更新 1: 我正在使用 libcurl 进行 https 请求。我注意到,当使用不带 ssl 支持的另一个版本的 libcurl 时,不会发生崩溃。 (查询当然会失败)。启用 ssl 的 libcurl 是我自定义编译的。

最佳答案

为了子孙后代:

这里的问题很可能只是调试器无法检查程序运行时使用的相同共享库,正如它在打印的消息中所说的那样。

旧版本的 GDB(例如问题中使用的 7.4)需要将库排列在与目标系统上完全相同的树结构中。因此,为此,您需要将二进制文件使用的所有库复制到一个目录中,其层次结构与目标主机上的层次结构完全相同。如果您将此目录命名为 target,那么您可以使用 set sysroot ./target/

告诉 GDB 在其中查找库

似乎更现代版本的 GDB 只能找到所有库,如果它们都收集到一个目录中,然后您可以使用 set solib-absolute-prefix 告诉 GDB 将它们放在哪里将 solib-search-path 设置为指向此目录。有时我在第一次让它正常工作时仍然遇到一些麻烦,我必须从头开始重试几次才能使所有咒语正确并按正确的顺序。

在这里,我使用更新版本的 GDB 以及 ~/tmp/arm-lib 中的所有库。请注意,我没有将核心文件名放在命令行上!

$ gdb ktest-arm 
GNU gdb (GDB) 7.12.0.20161109-git
Copyright (C) 2016 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:
<http://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 ktest-arm...done.
(gdb) show architecture 
The target architecture is set automatically (currently arm)
(gdb) set solib-absolute-prefix ~/tmp/arm-lib/ 
(gdb) set solib-search-path ~/tmp/arm-lib/
(gdb) core-file ~/tmp/ktest-arm-core 
warning: core file may not match specified executable file.
[New LWP 905]
Core was generated by `./ktest'.
Program terminated with signal SIGQUIT, Quit.
#0  0x40134264 in nanosleep () from /home/woods/tmp/arm-lib/libc.so.6
(gdb) bt
#0  0x40134264 in nanosleep () from /home/woods/tmp/arm-lib/libc.so.6
#1  0x00008c9c in main () at /home/woods/tmp/testing/ktest.c:9
(gdb) 

关于linux - ARM Linux 上的 "Backtrace stopped: previous frame identical to this frame (corrupt stack?)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32023492/

相关文章:

c++ - 在分析代码时,我应该使用匹配的 (gcc) 编译器优化标志吗?

gdb - gdb(MinGW)中的输入重定向

arm - 如何让qemu产生外部中断并跳转到isr(裸机代码)

asp.net - 在 Ubuntu 20.04 服务器上部署 Blazor Webassembly : cant connect

linux - 匹配 IPTables 规则时运行系统命令

linux - 如何有效地循环 Bash 中的文件行?

linux - Ncat 连接并立即在 Windows 上执行命令

c - GDB 无法在共享库上设置断点

arrays - 如何在ARM汇编中转置矩阵

交叉编译内核模块ARM