Segmentation fault inside a call to the 'new' operator
Joe Buck
jbuck@Synopsys.COM
Wed Jun 30 15:43:00 GMT 1999
Marilyn Davis wrote:
> >
> > When this has happened to me using gcc, it was because I was writing
> > outside the memory previously assigned to me by a previous call to
> > new.
Umberto writes:
> Thanks Marilyn, but I think that my post was not clear enough.
No, it was perfectly clear and Marilyn's explanation is the correct one.
If you ever see a crash inside new or malloc, the reason is always heap
corruption: the data structures used by malloc have been corrupted.
This can happen if you write to memory that you have not allocated
or have already freed, if you write beyond the end of memory you
have allocated, or if you free the same memory twice.
(I write "always" but of course it is possible that it is some other
bug, it's just that 9999 cases out of 10000 heap corruption is the
problem).
There are a variety of packages designed to catch just this sort of
problem. Electric Fence is one of the better free ones.
More information about the Gcc
mailing list