您如何阅读 segfault 内核日志消息 [英] How do you read a segfault kernel log message

查看:12
本文介绍了您如何阅读 segfault 内核日志消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个非常简单的问题,我正在尝试调试在 kern.log

This can be a very simple question, I'm am attempting to debug an application which generates the following segfault error in the kern.log

kernel: myapp[15514]: segfault at 794ef0 ip 080513b sp 794ef0 error 6 in myapp[8048000+24000]

这是我的问题:

  1. 是否有任何文档说明 segfault 上的 diff 错误编号是什么,在这种情况下是错误 6,但我看到了错误 4、5

  1. Is there any documentation as to what are the diff error numbers on segfault, in this instance it is error 6, but i've seen error 4, 5

bf794ef0 ip 0805130b sp bf794ef0和myapp[8048000+24000]处的信息是什么意思?

What is the meaning of the information at bf794ef0 ip 0805130b sp bf794ef0 and myapp[8048000+24000]?

到目前为止,我能够使用符号进行编译,当我执行 x 0x8048000+24000 时,它会返回一个符号,这是正确的做法吗?到目前为止,我的假设如下:

So far i was able to compile with symbols, and when i do a x 0x8048000+24000 it returns a symbol, is that the correct way of doing it? My assumptions thus far are the following:

  • sp = 堆栈指针?
  • ip = 指令指针
  • 在 = ????
  • myapp[8048000+24000] = 符号地址?

推荐答案

当报告指向一个程序,而不是一个共享库时

运行 addr2line -e myapp 080513b (并重复给定的其他指令指针值)以查看错误发生的位置.更好的是,获取带有调试工具的构建,然后在 gdb 等调试器下重现问题.

When the report points to a program, not a shared library

Run addr2line -e myapp 080513b (and repeat for the other instruction pointer values given) to see where the error is happening. Better, get a debug-instrumented build, and reproduce the problem under a debugger such as gdb.

libfoo.so[NNNNNN+YYYY] 部分中,NNNNNN 是加载库的位置.从指令指针 (ip) 中减去它,您将获得到违规指令的 .so 的偏移量.然后您可以使用 objdump -DCgl libfoo.so 并在该偏移处搜索指令.您应该能够很容易地从 asm 标签中找出它是哪个函数.如果 .so 没有优化,您也可以尝试使用 addr2line -e libfoo.so <offset>.

In the libfoo.so[NNNNNN+YYYY] part, the NNNNNN is where the library was loaded. Subtract this from the instruction pointer (ip) and you'll get the offset into the .so of the offending instruction. Then you can use objdump -DCgl libfoo.so and search for the instruction at that offset. You should easily be able to figure out which function it is from the asm labels. If the .so doesn't have optimizations you can also try using addr2line -e libfoo.so <offset>.

以下是字段的细分:

  • address - 代码试图访问的内存位置(可能 1011 是我们期望的指针的偏移量设置为有效值,但指向 0)
  • ip - 指令指针,即.尝试执行此操作的代码所在的位置
  • sp - 堆栈指针
  • error - 特定于架构的标志;请参阅适合您平台的 arch/*/mm/fault.c.
  • address - the location in memory the code is trying to access (it's likely that 10 and 11 are offsets from a pointer we expect to be set to a valid value but which is instead pointing to 0)
  • ip - instruction pointer, ie. where the code which is trying to do this lives
  • sp - stack pointer
  • error - Architecture-specific flags; see arch/*/mm/fault.c for your platform.

这篇关于您如何阅读 segfault 内核日志消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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