Subject: Re: segmentation faults
To: None <bmilliga@NMSU.Edu>
From: Brett Lymn <blymn@awadi.com.AU>
List: netbsd-help
Date: 11/23/1994 12:14:32
According to bmilliga@NMSU.Edu:
>
>2. What are the conditions that lead to a segmentation fault? How
>might I proceed to debug it.
>
Basically, accessing memory you should not. Try using the
-fwritable-strings option on the compiler (assuming you are using
gcc!) to see if the problem goes away. Modifying a string constant
can cause a seg fault, depending on the OS. Also things like
dereferencing a null pointer will cause a seg fault.
The best way to find the problem is to use a debugger on the program
in conjunction with the core file, viz:
gdb prog prog.core
then use the "bt" command to trace the call stack which will show the
call sequence that lead up to the fault. If you find you are in a
system library then you passed a bad parameter, use the "frame"
command to get back to the code that called the system call and
examine the parameters for bad ones.
--
Brett Lymn, Computer Systems Administrator, AWA Defence Industries
===============================================================================
"Aha! Pronoun problems. It's not `shoot you, shoot you', it's `shoot me,
shoot me'. So, go ahead, shoot ME, shoot ME <BLAM>... You're Despicable"
-- Daffy Duck