打印

记录一个SIGABRT错误的解决

[复制链接]
211|12
手机看帖
扫描二维码
随时随地手机跟帖
沙发
keer_zu|  楼主 | 2023-2-10 19:14 | 只看该作者
尝试把可执行文件一起生成的.so库替换后,出现错误:
# ./EM
unknown symbol: _ZN4nobo5infra2em8EMClient11getInstanceENS1_7FG_TYPEE referenced from EM
ldd:FATAL: Could not resolve all symbols


使用特权

评论回复
板凳
keer_zu|  楼主 | 2023-2-13 16:31 | 只看该作者
恢复了之前的.so文件,重新替换后没有上述问题,但是出现一下情况:
$ ntoaarch64-gdb EM EM.core
GNU gdb (GDB) 8.2.1 [qnx710 r1522] (STABLE)
Copyright (C) 2018 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=x86_64-pc-linux-gnu --target=aarch64-unknown-nto-qnx7.1.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.qnx.com/support/bugreports>.
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 EM...done.

warning: exec file is newer than core file.
[New pid 3760199 tid 1]
[New pid 3760199 tid 2]
[New pid 3760199 tid 3]
[New pid 3760199 tid 4]
[New pid 3760199 tid 5]

warning: Could not load shared library symbols for 9 libraries, e.g. /mnt/usr/lib64/libEMClient.so.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000000000000000 in ?? ()
[Current thread is 4 (pid 3760199 tid 4)]
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x0000000078003b0c in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)


怀疑是堆栈破坏增加堆栈保护, 用编译参数-fstack-protector-all为所有函数插入保护代码,编译版本,打算再次带符号查看崩溃dump

使用特权

评论回复
地板
keer_zu|  楼主 | 2023-2-13 16:34 | 只看该作者
带符号查看core文件的方法是:

$ gdb xxx.symbol core.xxx


这就需要.symbol文件,查找.symbol文件的生成方式:
$ objcopy --only-keep-debug EM EM.symbol
objcopy: Unable to recognise the format of the input file `EM'

使用特权

评论回复
5
keer_zu|  楼主 | 2023-2-13 16:37 | 只看该作者
本帖最后由 keer_zu 于 2023-2-13 17:03 编辑

继而尝试解决:

解决objcopy: Unable to recognise the format of the input file问题


的问题:

参考文章:
https://www.codeprj.com/blog/5b4bb01.html
https://www.cnblogs.com/water-moon/p/5983152.html

而我遇到的情况和上面不同,是用错了命令导致的,因为我的可执行文件是交叉编译的,所以:

ntoaarch64-objcopy --only-keep-debug EM EM.symbol
即可

使用特权

评论回复
6
keer_zu|  楼主 | 2023-2-13 17:07 | 只看该作者
上述步骤抽取调试符号后:

$ ntoaarch64-gdb EM.symbol EM.core
GNU gdb (GDB) 8.2.1 [qnx710 r1522] (STABLE)
Copyright (C) 2018 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=x86_64-pc-linux-gnu --target=aarch64-unknown-nto-qnx7.1.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.qnx.com/support/bugreports>.
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 EM.symbol...(no debugging symbols found)...done.

warning: exec file is newer than core file.
[New pid 3760199 tid 1]
[New pid 3760199 tid 2]
[New pid 3760199 tid 3]
[New pid 3760199 tid 4]
[New pid 3760199 tid 5]

warning: Could not load shared library symbols for 9 libraries, e.g. /mnt/usr/lib64/libEMClient.so.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000000000000000 in ?? ()
[Current thread is 4 (pid 3760199 tid 4)]
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x0000000078003b0c in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)


还是一样,看来从栈已经破坏的文件中抽取符号还是老样子,这样做没有任何意义,尝试其他方式。

使用特权

评论回复
7
keer_zu|  楼主 | 2023-2-13 17:09 | 只看该作者




此处插入知识点:
gdb加载调试符号(符号表)
  • 抽取调试符号:
    objcopy --only-keep-debug DEBUG版可执行文件 符号表文件名.symbol

  • 在gdb中加载符号表
    gdb --symbol=符号表文件名.symbol -exec=RELEASE版可执行文件

  • 也可以不抽取符号表,直接使用DEBUG版可执行文件作为符号表来源:
    gdb --symbol=DEBUG版可执行文件 -exec=RELEASE版可执行文件







使用特权

评论回复
8
keer_zu|  楼主 | 2023-2-13 17:35 | 只看该作者
尝试加了-fstack-protector-all,希望栈能尽可能被保全




结果依然是:



是不是应该从
(no debugging symbols found)
这里找一下原因?可能因为没有符号,所以才看不到栈信息,继续吧

使用特权

评论回复
9
keer_zu|  楼主 | 2023-2-13 18:20 | 只看该作者

加上如下编译参数:


得到新的编译结果,包含可执行文件和库,把可执行文件和两个动态库替换到目标板,运行,得到core文件。

然后把最新编译的可执行文件,库文件,和刚刚得到core文件放在host的某个目录下:

$ ntoaarch64-gdb EM EM.core
GNU gdb (GDB) 8.2.1 [qnx710 r1522] (STABLE)
Copyright (C) 2018 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=x86_64-pc-linux-gnu --target=aarch64-unknown-nto-qnx7.1.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.qnx.com/support/bugreports>.
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 EM...done.

warning: exec file is newer than core file.
[New pid 4239431 tid 1]
[New pid 4239431 tid 2]
[New pid 4239431 tid 3]
[New pid 4239431 tid 4]
[New pid 4239431 tid 5]

warning: Could not load shared library symbols for 7 libraries, e.g. /mnt/usr/lib64/libvxlog.so.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000000000000000 in ?? ()
[Current thread is 4 (pid 4239431 tid 4)]
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x0000000078004e54 in nobo::infra::em::EMClient::CommProxyListener::onAlive (this=0x110d6b28, alive=true)
    at /home/zukeqiang/src/basic_service/EM/src/EMClient/EMClient.cpp:13
#2  0x000000007802fff4 in nobo::infra::em::EMCommProxy::messageCallback (this=0x110efa08, msgid=65535, msg=0xffbc780)
    at /home/zukeqiang/src/basic_service/EM/src/EMCommAPI/EMCommProxy.cpp:77
#3  0x000000007803394c in std::__1::__invoke<void (nobo::infra::em::EMCommProxy::*&)(unsigned int, CFdbMessage*), nobo::infra::em::EMCommProxy*&, unsigned int, CFdbMessage*, void> (__a0=@0x110d7b80: 0x110efa08, __f=
    @0x110d7b70: (void (nobo::infra::em::EMCommProxy::*)(nobo::infra::em::EMCommProxy * const, unsigned int, CFdbMessage *)) 0x7802fef8 <nobo::infra::em::EMCommProxy::messageCallback(unsigned int, CFdbMessage*)>)
    at /home/zukeqiang/src/qnx/qnx710_host/target/qnx7/usr/include/c++/v1/type_traits:4294
#4  std::__1::__apply_functor<void (nobo::infra::em::EMCommProxy::*)(unsigned int, CFdbMessage*), std::__1::tuple<nobo::infra::em::EMCommProxy*, std::__1::placeholders::__ph<1>, std::__1::placeholders::__ph<2> >, 0ul, 1ul, 2ul, std::__1::tuple<unsigned int&&, CFdbMessage*&&> > (__args=..., __bound_args=..., __f=
    @0x110d7b70: (void (nobo::infra::em::EMCommProxy::*)(nobo::infra::em::EMCommProxy * const, unsigned int, CFdbMessage *)) 0x7802fef8 <nobo::infra::em::EMCommProxy::messageCallback(unsigned int, CFdbMessage*)>)
    at /home/zukeqiang/src/qnx/qnx710_host/target/qnx7/usr/include/c++/v1/functional:2644
#5  std::__1::__bind<void (nobo::infra::em::EMCommProxy::*)(unsigned int, CFdbMessage*), nobo::infra::em::EMCommProxy*, std::__1::placeholders::__ph<1> const&, std::__1::placeholders::__ph<2> const&>::operator()<unsigned int, CFdbMessage*> (
    this=0x110d7b70) at /home/zukeqiang/src/qnx/qnx710_host/target/qnx7/usr/include/c++/v1/functional:2677
#6  std::__1::__invoke<std::__1::__bind<void (nobo::infra::em::EMCommProxy::*)(unsigned int, CFdbMessage*), nobo::infra::em::EMCommProxy*, std::__1::placeholders::__ph<1> const&, std::__1::placeholders::__ph<2> const&>&, unsigned int, CFdbMessage*> (
    __f=...) at /home/zukeqiang/src/qnx/qnx710_host/target/qnx7/usr/include/c++/v1/type_traits:4353
#7  std::__1::__invoke_void_return_wrapper<void>::__call<std::__1::__bind<void (nobo::infra::em::EMCommProxy::*)(unsigned int, CFdbMessage*), nobo::infra::em::EMCommProxy*, std::__1::placeholders::__ph<1> const&, std::__1::placeholders::__ph<2> const&>&, unsigned int, CFdbMessage*> (__args#0=..., __args#1=@0xffbc5b4: 65535, __args#2=@0xffbc5a8: 0xffbc780)
    at /home/zukeqiang/src/qnx/qnx710_host/target/qnx7/usr/include/c++/v1/__functional_base:349
#8  0x00000000780330e8 in std::__1::__function::__alloc_func<std::__1::__bind<void (nobo::infra::em::EMCommProxy::*)(unsigned int, CFdbMessage*), nobo::infra::em::EMCommProxy*, std::__1::placeholders::__ph<1> const&, std::__1::placeholders::__ph<2> const&>, std::__1::allocator<std::__1::__bind<void (nobo::infra::em::EMCommProxy::*)(unsigned int, CFdbMessage*), nobo::infra::em::EMCommProxy*, std::__1::placeholders::__ph<1> const&, std::__1::placeholders::__ph<2> const&> >, void (unsigned int, CFdbMessage*)>::operator()(unsigned int&&, CFdbMessage*&&) (__arg#1=@0xffbc5a8: 0xffbc780, __arg#0=@0xffbc5b4: 65535, this=0x110d7b70)
    at /home/zukeqiang/src/qnx/qnx710_host/target/qnx7/usr/include/c++/v1/functional:1527
--Type <RET> for more, q to quit, c to continue without paging--
#9  std::__1::__function::__policy_invoker<void (unsigned int, CFdbMessage*)>::__call_impl<std::__1::__function::__alloc_func<std::__1::__bind<void (nobo::infra::em::EMCommProxy::*)(unsigned int, CFdbMessage*), nobo::infra::em::EMCommProxy*, std::__1::placeholders::__ph<1> const&, std::__1::placeholders::__ph<2> const&>, std::__1::allocator<std::__1::__bind<void (nobo::infra::em::EMCommProxy::*)(unsigned int, CFdbMessage*), nobo::infra::em::EMCommProxy*, std::__1::placeholders::__ph<1> const&, std::__1::placeholders::__ph<2> const&> >, void (unsigned int, CFdbMessage*)> >(std::__1::__function::__policy_storage const*, unsigned int, CFdbMessage*) (__buf=0x110d30c0, __args#0=65535, __args#1=0xffbc780)
    at /home/zukeqiang/src/qnx/qnx710_host/target/qnx7/usr/include/c++/v1/functional:2010
#10 0x000000007803af60 in std::__1::__function::__policy_func<void (unsigned int, CFdbMessage*)>::operator()(unsigned int&&, CFdbMessage*&&) const (__args#1=@0xffbc628: 0xffbc780, __args#0=@0xffbc634: 65535, this=0x110d30c0)
    at /home/zukeqiang/src/qnx/qnx710_host/target/qnx7/usr/include/c++/v1/functional:2123
#11 std::__1::function<void (unsigned int, CFdbMessage*)>::operator()(unsigned int, CFdbMessage*) const (this=0x110d30c0,
    __arg#0=65535, __arg#1=0xffbc780) at /home/zukeqiang/src/qnx/qnx710_host/target/qnx7/usr/include/c++/v1/functional:2347
#12 0x0000000078038ecc in nobo::infra::em::FdbusCommProxy::onOnline (this=0x110d2f68, sid=1, is_first=true)
    at /home/zukeqiang/src/basic_service/EM/src/EMCommAPI/FdbusCommProxy.cpp:37
#13 0x00000000788887a8 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)
此时可以看到大部分栈的信息了,找不到符号的提示也不见了。

使用特权

评论回复
评论
keer_zu 2023-2-13 18:21 回复TA
有进展了,继续努力,再接再厉 
10
keer_zu|  楼主 | 2023-2-14 13:26 | 只看该作者
有了这个相对完整的栈,对着代码从栈顶开始看。
首先
FdbusCommProxy.cpp:37

使用特权

评论回复
11
keer_zu|  楼主 | 2023-2-14 13:30 | 只看该作者
第37行:



这个回调是类的private成员:


它的类型是CommProxyCallback:



使用特权

评论回复
12
keer_zu|  楼主 | 2023-2-14 13:39 | 只看该作者
找到初始化的地方,看看具体调用的是哪里:

在函数
::messageCallback

中,低77行:
EMCommProxy.cpp:77
和栈#2对上了。这一行内容:
mHandler->onAlive(true);

调用的就是EMClient.cpp的::onAlive(),在这个文件的13行:
EMClient.cpp:13
内容是:
mClient->mPrint(...)
到这里我应该知道是怎么回事了,八成应该是mPrint没初始化,为空。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:qq群:49734243 Email:zukeqiang@gmail.com

1332

主题

12328

帖子

53

粉丝