简体   繁体   English

Python崩溃了; 如何在dmesg日志中解码段错误?

[英]Python crashed; how to decode segfault in dmesg log?

I have a Python daemon running on a 64-bit Linux box. 我有一个在64位Linux机器上运行的Python守护程序。 It is crashing. 它崩溃了。 Not a friendly, straightforward to debug, Python exception stack trace sort of crash, either-- this is a segmentation fault. Python异常堆栈跟踪也不是一种友好,易于调试的崩溃,这是分段错误。 Linux's dmesg log has a succinct post-mortem: Linux的dmesg日志有一个简短的验尸报告:

python2.7[27509]: segfault at 7fe500000008 ip 00007fe56644a891 sp 00007fe54e1fa230 error 4 in libpython2.7.so.1.0[7fe566359000+193000]
python2.7[23517]: segfault at 7f5600000008 ip 00007f568bb45891 sp 00007f5678e55230 error 4 in libpython2.7.so.1.0[7f568ba54000+193000]

libpython2.7.so.1.0 on this system has symbols and I can run objdump -d to get an assembly language dump. 这个系统上的libpython2.7.so.1.0有符号,我可以运行objdump -d来获取汇编语言转储。 So I'm curious to know which function is causing the segfault. 因此,我很想知道哪个功能导致了段错误。

How can I decode one of these dmesg segfault notices and find the errant function? 如何解码这些dmesg segfault通知之一并找到错误的功能? One line says "7fe566359000+193000" and the next says "7f568ba54000+193000". 一行显示“ 7fe​​566359000 + 193000”,下一行显示“ 7f568ba54000 + 193000”。 I'm guessing this means both segfaults come from the same location. 我猜这意味着两个段错误都来自同一位置。 193000 = 0x2f1e8. 193000 = 0x2f1e8。 I thought that 0x2f1e8 would lead to an instruction in the Python library assembly dump, but it didn't; 我以为0x2f1e8会在Python库汇编转储中导致一条指令,但事实并非如此。 0x2f1e8 is well out of range of the disassembly. 0x2f1e8超出了拆卸范围。

That is the address from the base of the library load, so you should compare it with the load address of .text as returned by (for example) eu-readelf : 那是库加载的基础地址,因此您应该将其与eu-readelf返回的.text的加载地址进行比较:

flame@saladin ~ % eu-readelf -S /usr/lib/libpython2.7.so
There are 25 section headers, starting at offset 0x1b1a80:

Section Headers:
[Nr] Name                 Type         Addr             Off      Size     ES Flags Lk Inf Al
[ 0]                      NULL         0000000000000000 00000000 00000000  0        0   0  0
[….]
[10] .text                PROGBITS     000000000003f220 0003f220 000e02a0  0 AX     0   0 16
[….]

What you should be able to do is to use the address you got with the addr2line tool: 您应该能够做的就是使用通过addr2line工具获得的地址:

addr2line -e /usr/lib/libpython2.7.so 0x6e408

In this case I can't get the data because my copy of the library differs from yours so the address makes no sense. 在这种情况下,我无法获取数据,因为我的库副本与您的库副本不同,因此地址没有意义。

Of course you still won't get a full backtrace unless you had a core file. 当然,除非拥有核心文件,否则您仍然不会获得完整的回溯。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM