“回溯停止:与该帧相同的前一帧(损坏的堆栈?)”在ARM linux上 [英] "Backtrace stopped: previous frame identical to this frame (corrupt stack?)" on ARM linux

查看:6224
本文介绍了“回溯停止:与该帧相同的前一帧(损坏的堆栈?)”在ARM linux上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

  $ arm-arago-linux-gnueabi -gdb test_slave6_slave核心
GNU gdb( GDB)7.4
版权所有(C)2012自由软件基金会,Inc.
许可证GPLv3 +:GNU GPL版本3或更高版本< http://gnu.org/licenses/gpl.html>
这是免费软件:您可以自由更改和重新分配它。
在法律允许的范围内,不存在任何担保。有关详细信息,请键入显示复制
和显示保修。
这个GDB被配置为--host = i686-oesdk-linux --target = arm-oe-linux-gnueabi。
有关错误报告的说明,请参阅:
< http://www.gnu.org/software/gdb/bugs/> ...
从/ home / dvdk中读取符号/test_slave6_slave...done。

警告:exec文件比核心文件更新。
[新LWP 6411]
[新LWP 6410]

警告:无法加载12个库的共享库符号,例如/lib/libjson-c.so.2。
使用info sharedlibrary命令查看完整列表。
您是否需要设置solib-search-path或set sysroot?
核心由`/ usr / bin / test_slave6_slave 5 111.111.111.111 1 2 1 2'生成。
程序终止于信号11,分段故障。
#0 0x47b61dd4在? ()
(gdb)bt
#0 0x47b61dd4在? ()
#1 0x47b2e0fc在? ()
#2 0x47b2e0fc在? ()
Backtrace停止:前一帧与此帧相同(损坏的堆栈?)
(gdb)

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



我不认为

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

为了后代的缘故:

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



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

似乎更现代的GDB版本只能找到每个库,如果它们全部收集到一个目录中,然后可以告诉GDB使用设置solib-absolute-prefix 设置solib-search-path 来指向这个目录。我有时候在第一次正常工作时仍然遇到一些麻烦,我必须从头开始重试几次,以正确的顺序得到所有咒语。



在这里,我使用更新的GDB构建,其中包含〜/ tmp / arm-lib 中的所有库。请注意,我没有将核心文件名放在命令行上!

  $ gdb ktest-arm 
GNU gdb (GDB)7.12.0.20161109-git
版权(C)2016自由软件基金会,Inc.
许可证GPLv3 +:GNU GPL版本3或更高版本< http://gnu.org/licenses/gpl。 HTML>
这是免费软件:您可以自由更改和重新分配它。
在法律允许的范围内,不存在任何担保。有关详细信息,请键入显示复制
和显示保修。
这个GDB被配置为x86_64-pc-linux-gnu。
输入显示配置以获取配置详细信息。
有关错误报告的说明,请参阅:
< http://www.gnu.org/software/gdb/bugs/> ;.
在线查找GDB手册和其他文档资源:
< http://www.gnu.org/software/gdb/documentation/> ;.
如需帮助,请输入help。
输入apropos word以搜索与word相关的命令...
从ktest-arm中读取符号...完成。
(gdb)show architecture
目标体系结构自动设置(当前为arm)
(gdb)设置solib-absolute-prefix〜/ tmp / arm-lib /
(gdb) )set solib-search-path〜/ tmp / arm-lib /
(gdb)core-file〜/ tmp / ktest-arm-core
警告:核心文件可能与指定的可执行文件不匹配。
[新建LWP 905]
核心由`./ktest'生成。
程序以信号SIGQUIT终止,退出。 $ /
#0 0x40134264 in nanosleep()from /home/woods/tmp/arm-lib/libc.so.6
(gdb)bt
#0 0x40134264 from nanosleep()from / home /home/woods/tmp/testing/ktest.c:9
(gdb)$ b $在main()中的/woods/tmp/arm-lib/libc.so.6
#1 0x00008c9c b


I am trying to debug a segfault while running an application on linux ( ARM architecture). I copied the core dump file and tried to get the backtrace using arm-gdb on x86_64 host. This is the 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)

(The timestamp warning might be because I copied the core file first )

I don't think this issue and my issue is same as I am getting valid address. I think it is still a stack corruption issue. But I am not sure how to debug this further. Should I use GDB or valgrind? Can some one point me towards the correct steps for debugging using these tools. For example, should I use memecheck with valgrind with leak_check?

UPDATE 1: I am using libcurl for https requests. I have noticed that the crash does not happen when another version of libcurl without ssl support is used. (query will fail ofcourse). The ssl enabled libcurl was custom compiled by me.

解决方案

For posterity's sake:

The problem here is most likely simply that the debugger is unable to examine the same shared libraries that the program was run using, just as it said in the messages it printed.

Older versions of GDB (e.g. 7.4 as used in the question) need the libraries to be arranged in exactly the same tree structure as they are on the target system. So for it you would need to copy all the libraries the binary used into a directory with a hierarchy exactly as it is on the target host. If you name this directory target then you can tell GDB to find the libraries in it with set sysroot ./target/

It seems as if more modern versions of GDB can only find every library if they are all collected into one directory and then you can tell GDB where you put them using set solib-absolute-prefix and set solib-search-path to both point at this directory. I sometimes still have some trouble getting this to work correctly the first time and I have to retry from the beginning several times to get all the incantations correct and in the correct order.

Here I use a more recent build of GDB with all the libraries in ~/tmp/arm-lib. Note that I did not put the core filename on the command-line!

$ 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) 

这篇关于“回溯停止:与该帧相同的前一帧(损坏的堆栈?)”在ARM linux上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆