Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
11.1k views
in Technique[技术] by (71.8m points)

c - 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

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.

However, the core-file backtrace gives the below error message:

Program terminated with signal SIGSEGV, Segmentation fault.

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

32 ../sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S: No such file or directory.

(gdb) bt

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

#1 0x00000000004041f1 in main (argc=1, argv=0x7ffced1f8ae8) at main.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".

I should be getting some message related to NULL pointer de-reference but instead got this. What does that mean?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

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. In this case, strcmp is trying to access page 0 because you passed it a NULL ptr. Null Ptr is address zero, and page 0 is an invalid page.

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. Since you do not have that implementation file on your system, gdb is complaining that it can not access it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...