LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   SIGSEGV- segmentation fault during execution (https://www.linuxquestions.org/questions/programming-9/sigsegv-segmentation-fault-during-execution-176261/)

ashwinipahuja 04-30-2004 04:41 AM

SIGSEGV- segmentation fault during execution
 
I am getting a SIGSEGV- segmentation fault
I have studied the code but cannot find out much.
wut are the most common problems for this error.:(

eshwar_ind 04-30-2004 05:34 AM

As far as i have known The reason for this error is Invalid memory access. The most common way of commiting this mistake is while you are doing string operations, closing the file pointer more than once, and wrting on readonly memory.

Use debuggers or printf to find out the error.

check the return values of each and every library function.
Thats all i know about it.
Bye,
Eshwar.

Mara 04-30-2004 03:31 PM

You can find the place (function) your program has a problem using
gdb progname
run
(the program will run, when it segfaults: )
bt
(shows an 'execution trace', function at the top was stared as the last one, there's a high probability there's a problem in it - or it uses data that's incorrect)

jinksys 05-02-2004 08:10 AM

Segmentation faults occur when a process tries to access memory outside its bounds.
In processes that arent trying to do something malicious, this usually happens when
a pointer is returned from a function and is not tested whether it is valid. Look at
your code and make sure your error checking uses == and not =. If you still cant
find it, post your code.

chris78 05-02-2004 08:14 AM

Quote:

Originally posted by jinksys

your code and make sure your error checking uses == and not =.

Hehe thats a quite common one.

if (t_ptr=NULL) FREE(t_ptr);

Or missing & or * in front of function arguments or assignements.

Chris

nodger 05-02-2004 10:02 PM

get a program called valgrind. It will tell you all the invalid reads/writes in your prog.


All times are GMT -5. The time now is 11:34 AM.