[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: Segmentation faults and Core Dump



Hello,

Almost all cases of segmentation faults are the result of access of
memory locations, which is often the case when pointers are used.  

You could be accessing an uninitialised pointer variable or a pointer set
to NULL.  Another place is while using scanf - make sure that the address
of the variable is passed and not the variable itself.

To debug this you could use printf statements at different checkpoints of
your program.  This would let you know the approximate point at which the
segmentation fault happens.

dbg or dbx is often used, but I am not familiar with using them.

Selvakumar



On Tue, 27 Mar 2001, Shridhar Daithankar wrote:

> Hi
> 
>  The only answer to core dump is pointer(barring divide by zero but I think 
> that's trapped)
> 
> Check *ALL* pointers in your code. I don't have much experinece with 
> programming but out of  hundreds of core dump I have traced so far, every 
> single of them was due to pointer.
> 
>  Either you try to use a function pointer that's invalid or access data by 
> reference of a pointer, that's invalid.
> 
> Just track down those buggers... :-)
> 
>  Shridhar
> 
> On Tuesday 27 March 2001 17:03, Senthil Devan wrote:
> > My program (comprising nearly 10 Source files) crashes with segmentation
> > fault. I am not able to back track (bt) in gdb as the stack is getting
> > corrupted. I also tried where in gdb (I haven't used where much), but it
> > was not of much help. I need some suggestions as how segmentation faults
> > can be tracked down. I also want to know about core dump file and how it
> > can be used to find the cause of segmentation fault.
> 
> ---------------------------------------------
> An alpha version of a web based tool to manage
> your subscription with this mailing list is at
> http://lists.linux-india.org/cgi-bin/mj_wwwusr
>