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?
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:
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.