When running my c code I keep recieving the error message Segmentation Fault (core dumped)
That is all I receive. Is there a way I can see more from this error? I.E. through a c library at the top of the c code?
When running my c code I keep recieving the error message Segmentation Fault (core dumped)
That is all I receive. Is there a way I can see more from this error? I.E. through a c library at the top of the c code?
You can use a debugger to find the line that causes this error. That should be enough to solve your problem. Segmentation fault is often caused by accessing a memory location that is not available. For example, consider following code:
int array[5];
array[2] = 10; // OK
array[20] = 10; // Segmentation fault
This commonly occurs when you make a mistake in writing a loop.
See this question for an example how to debug your program with GDB:
First compile your program:
gcc program.c -g -o program
Then use gdb:
gdb ./program
(gdb) run
<segfault happens here>
(gdb) backtrace
<offending code is shown here>
The message core dumped
means that a core-file has been created. A core-file is a file which contains all content of the memory, related to the process which has just crashed (core dumps typically are created when an application crashes).
There are two things you can do: you can look for the cause, by looking into your program when this happened, or you can investigate the core dump, in order to understand which kind of error has led to this situation. In most cases, this can be done by reading the call stack from your core dump.
The core dump can be located anywhere, I have known situations where it was created in the runtime directory of the running process, I have known situations where core dumps where automatically moved to /var/core
. About applications for reading core dumps, I have worked with dbx
and gdb
, but I think that ladebug
might be useful too.
I know, I give plenty of new questions, but I hope that now you have an idea in which directions to look for further information.