Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Segmentation Fault: "...no such file or directory"

I'm getting weird seg fault that seems to be coming from somewhere not in my program...not explicitly anyway. I'm calling "strcmp" on two array's... Both arrays are stored in the same type of structs. I'm getting at one with dot notation and one through dereferencing with "->":

int name = strcmp(one.name, two->name);

It compiles fine but when I run it I get the seg fault. I've tried tracking it down with GDB but when I put breakpoints in just before where I think it should occur, it seg faults anyway. I'm getting:

Program received signal SIGSEGV, Segmentation fault.
__strcmp_ia32 () at ../sysdeps/i386/i686/multiarch/../strcmp.S:40
40  ../sysdeps/i386/i686/multiarch/../strcmp.S: No such file or directory.
    in ../sysdeps/i386/i686/multiarch/../strcmp.S

FML. Suggestions? Thanks!

like image 980
MCP Avatar asked May 17 '12 02:05

MCP


1 Answers

My suggestion: Compile it with -g and run it through valgrind.

like image 62
Christian Neverdal Avatar answered Oct 16 '22 00:10

Christian Neverdal