Re: Seg Faults
- From: David Resnick <lndresnick@xxxxxxxxx>
- Date: Mon, 06 Aug 2007 05:37:56 -0700
On Aug 6, 6:17 am, Matt <matt...@xxxxxxxxxxx> wrote:
Hey guys. I've got a general question here regarding segmentation.....
faults.
So, as the programme is far too large to post up, I was hoping to draw
on the experience of you guys and come up with some possible sources
of this error. Any suggestions are welcome.
Without code, people can only offer generalities, like checking
pointers for NULL prior to dereferencing them, not using freed memory,
not using uninitialized pointers, not overwriting bounds of allocated
memory, etc. If you always crash at the same point in the program
(seen by logging/etc), it is usually straightforward to figure out
why. Add some print statements showing the objects in use (pointers,
etc), and figure out the problem that way. If you crash at random
points, that is trickier.
<OT>If you are on a system where a core file is available after a
segmentation fault, that can be helpful. Sometimes you need to enable
this (e.g. via ulimit on linux).
There are also lots of tools that can rescue you. If you always crash
in the same place, running under a debugger, putting a breakpoint
there, and looking at things can help. There are some tools, which
may be available on your system, some free, some not, like valgrind,
electric fence, purify, etc, that can be very nice for tracking down
this sort of problem. If you use glibc, the MALLOC_CHECK_ environment
variable set to 2 can occasionally help too, causes core dump on
bounds overwrites, though only when the memory is actually freed.
</OT>
-David
.
- References:
- Seg Faults
- From: Matt
- Seg Faults
- Prev by Date: Re: Exercise 5-9 K&R -- NOW OFF TOPIC
- Next by Date: [OT] Re: Exercise 5-9 K&R
- Previous by thread: Re: Seg Faults
- Next by thread: Re: Seg Faults
- Index(es):
Relevant Pages
|