According to wikipedia:
A segmentation fault occurs when a program attempts to access a memory location that it is not allowed to access, or attempts to access a memory location in a way that is not allowed (for example, attempting to write to a read-only location, or to overwrite part of the operating system).
Usually signal #11 (SIGSEGV) set, which is defined in the header file signal.h file. The default action for a program upon receiving SIGSEGV is abnormal termination. This action will end the process, but may generate a core file (also known as core dump) to aid debugging, or perform some other platform-dependent action. A core dump is the recorded state of the working memory of a computer program at a specific time, generally when the program has terminated abnormally.
Segmentation fault can also occur under following circumstances:
a) A buggy program / command, which can be only fixed by applying patch.
b) It can also appear when you try to access an array beyond the end of an array under C programming.
c) Inside a chrooted jail this can occur when critical shared libs, config file or /dev/ entry missing.
d) Sometime hardware or faulty memory or driver can also create problem.
e) Maintain suggested environment for all computer equipment (overheating can also generate this problem).
Suggestions to debug Segmentation Fault errors
To debug this kind of error try one or all of the following techniques :
- Use gdb to track exact source of problem.
- Make sure correct hardware installed and configured.
- Always apply all patches and use updated system.
- Make sure all dependencies installed inside jail.
- Turn on core dumping for supported services such as Apache.
- Use strace which is a useful diagnostic, instructional, and debugging tool.
- Google and find out if there is a solution to problem.
- Fix your C program for logical errors such as pointer, null pointer, arrays and so on.
- Analyze core dump file generated by your system using gdb
Further readings:
- Read about the Segmentation fault in Wikipedia.
- Signal 11 while compiling the kernel.
- Example Debugging Session: Segmentation Fault Example
- Why does this not work!? How to find and fix faults in Linux applications.
- man pages gdb, core, signal
Please add your suggestions and debugging techniques in the comment below.



13 comment
Suddenly my software started giving a Segmentation Fault.
Language C, O/S: Linux.
Following is a (pseudo) code snippet:
1. x=strtok(y,”:”);
2. if(strlen(x)>0) { do_something; }
Line 2 would cause a Seg Fault. I would guess it should at least give me a false result.
Hence I changed the code to:
2. if(x != NULL) if(strlen(x) > 0) { do_something; }
Note: you cant do if(x != NULL && strlen(x) > 0) as the strlen woud cause a SegFault (GP fault in Windows, i guess).
Regards.
Hello All Forum members,
I am in dire need of help please. Can some one help me solve this segmentation problem ?
I have part of the code like this. I have tried to put displays around to track down the flow as follows:
LET GetInput = TRUE
WHILE GetInput
display ” Inside infield manno 1 ”
display “GetInput = “, GetInput
sleep 5
INPUT w_manno,
w_surname
WITHOUT DEFAULTS
FROM manno,
surname
AFTER FIELD manno
display ” Inside infield manno 2 ”
sleep 5
IF w_manno ” ”
AND w_manno IS NOT NULL
THEN
SELECT COUNT(*)
INTO w_cnt
The second display is not coming. I can’t put a display just after the INPUT command or as I am getting a syntax error.
I have also tried the following:
LET GetInput = TRUE
WHILE GetInput
display ” Inside infield manno 1 ”
display “GetInput = “, GetInput
sleep 5
INPUT BY NAME manno,
surname
WITHOUT DEFAULTS
But still I don’t seem to get what is going on. How do control the cursor to placed in the input field ?
Thanking you in advance.
Felix Mwango Mutale
Segmentation Fault may also occur if disk is running out of free space!
Invoking “ps gave me “segmentation fault”. Managed to got rid-off the problem by upgrading “procps”.
More info nixtaste
Good Luck !!
I’m having a strange behavior with an application, it segfaulted before every time while running it after the first error which happened after I closed it (after first use)
But then I by accident missed the – while trying to run it in debugging mode. So it kinda looks like this “./nameapp d” and that puzzles me, any insight or guess what is going on there? What difference does that make?
Cause after doing this it suddently worked again without error where as it segfaulted every single time before that. Could be random behaviour but others with the same problem seem to say it fixed it for them too.
hiii ……..my program works fine in turboc2 but it gives segmentation fualt in linux through putty………what should i do
9 out of 10:
You screwed up your printf like statement: the number of your print format parameters is greater than the number of arguments you pass. Like this
printf (” %d %s %s n”, string1, string2); Oops, you forgot to pass in your number which was supposed to be the first.
hi,
while make function i got following errors
./common/ptypes2tcl > gen/ptypes.cc
/bin/sh: line 1: 15769 Segmentation fault ./common/ptypes2tcl > gen/ptypes.cc
make: *** [gen/ptypes.cc] Error 139
[root@localhost ns-2.33]#
can you tell me how to solve this
thanks in advance
hello,
while doing make for ns-2.34
./common/ptypes2tcl > gen/ptypes.cc
/bin/sh: line 1: 15769 Segmentation fault ./common/ptypes2tcl > gen/ptypes.cc
make: *** [gen/ptypes.cc] Error 139
[root@localhost ns-2.33]#
can you tell me how to solve this…
thanks
hello,
while doing make for ns-2.34
./common/ptypes2tcl > gen/ptypes.cc
/bin/sh: line 1: 15769 Segmentation fault ./common/ptypes2tcl > gen/ptypes.cc
make: *** [gen/ptypes.cc] Error 139
[root@localhost ns-2.33]#
can you tell me how to solve this…
thanks
Hi All,
Today I have faced the segmentation fault in the Linux servers
I have tried to remove the mod_nss rpm from the server once it started to ask the dependency library from the server I have removed the dependency library from the server once the depency library removed I was unable to run any of the command and getting the error as “segmentation faultâ€
Once rebooted the server with the Linux iso I have upgraded the installation once it has been done the server comes to normal one
Regards,
Sathyaraj.S
Hey i am getting this error >> Segmentation fault (core dumped)
but this error comes at the time of runing the program not at the time of compilation.. all dependencies are installed so can you guide me how can fix it…?
when i run the command ” apt-get update” in kali linux 2.0 and it gives the error
“Segmentation fault
Reading package lists… Done ”
how can i solve this error
please tell me