简体   繁体   English

核心文件的gdb backtrace打印错误“没有这样的文件或目录”

[英]gdb backtrace of a core file prints error “no such file or directory”

While testing a program I hit a segmentation fault which dumped the required core. 在测试程序时,我遇到了分段错误,该错误转储了所需的内核。

I'm using gdb to debug a core file as: gdb /path/to/exec path/to/core 我正在使用gdb调试核心文件,如下所示: gdb / path / to / exec path / to / core

I realized after looking at the core file (and the source code) that the issue is actually a NULL pointer dereference that happened while using the "strcmp" function. 在查看核心文件(和源代码)后,我意识到问题实际上是在使用“ strcmp”函数时发生的NULL指针取消引用。

However, the core-file backtrace gives the below error message: 但是,核心文件回溯提供以下错误消息:

Program terminated with signal SIGSEGV, Segmentation fault. 程序以信号SIGSEGV终止,分段错误。

#0 __strcmp_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S:32 #0 __strcmp_sse2_unaligned()位于../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S:32

32 ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S: No such file or directory. 32 ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S:没有此类文件或目录。

(gdb) bt (gdb)bt

#0 __strcmp_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S:32 #0 __strcmp_sse2_unaligned()位于../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S:32

#1 0x00000000004041f1 in main (argc=1, argv=0x7ffced1f8ae8) at main.c:1144 main.c上#1 0x00000000004041f1在main(argc = 1,argv = 0x7ffced1f8ae8)在c.1144

Now this is a weird message that I can't make any sense of. 现在,这是一条奇怪的消息,我无法理解。 I'm not sure why gdb is printing this message "../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S: No such file or directory" . 我不确定gdb为什么打印此消息“ ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S:没有这样的文件或目录”

I should be getting some message related to NULL pointer de-reference but instead got this. 我应该得到一些与NULL指针取消引用有关的消息,但是却得到了这一点。 What does that mean? 这意味着什么?

This error looks mystifying but it is correct. 该错误看起来令人迷惑,但它是正确的。 It shows that a NULL pointer de-reference was being made by strcmp , which was called from line 1144 of your code. 它显示了strcmp正在进行空指针取消引用,这是从代码的1144行调用的。

A segmentation fault refers to trying to access a page of memory that is invalid: its segment is mapped as Invalid for read or write in the MMU. 分段错误是指尝试访问无效的内存页面:其分段被映射为对于MMU中的读取或写入无效。 In this case, strcmp is trying to access page 0 because you passed it a NULL ptr. 在这种情况下, strcmp试图访问页面0,因为您将其传递给NULL ptr。 Null Ptr is address zero, and page 0 is an invalid page. 空Ptr是地址零,而页面0是无效页面。

The reference to file: 对文件的引用:

../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S

is referring the the assembler file (.S) that implements strcmp for x86 on 64-bit architectures. 指的是在64位体系结构上为x86实现strcmp的汇编文件(.S)。 Since you do not have that implementation file on your system, gdb is complaining that it can not access it. 由于您的系统上没有该实现文件,因此gdb抱怨它无法访问它。

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

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