LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to handle Segmentation Fault (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-handle-segmentation-fault-713977/)

wkirubakaran 03-24-2009 01:27 AM

How to handle Segmentation Fault
 
Hello Friends. I am a newbie to Linux. The program that was
working perfectly ok in Unix is failing with segmentation fault.
The program aborts immediately. Is there way to make the program
continue further instead of aborting ?

trevelluk 03-24-2009 04:52 PM

Short answer, no.

A segmentation fault occurs when a program attempts to access a memory address which is not allocated to it. If the operating system detects a program doing this then the offending program will be immediately terminated by the OS to prevent potential interference with other programs.

Ultimately, the only way to get the program running on Linux is to identify and fix the problem. If you wrote the program yourself, its time to start debugging! You may find the "valgrind" program helps to identify the problem.

Obviously, I can't say exactly what causes the problem, but common causes include use of uninitialised or NULL pointers, and loops that iterate round an array going too far.

Assuming you have access to the code, and its not too big, then post it here and with any luck someone will be able to spot the problem.


All times are GMT -5. The time now is 01:02 AM.