[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Segfault in free(), electric-fence for C++ ?



On Wed, Sep 03, 1997 at 05:07:11PM +0200, E.L. Meijer (Eric) wrote:
> > I have some strange problem with my C++ code: I get a segmentation fault
> > in destructor's delete[] operator. GDB says it happend in free().
> > What could be the cause of that? The only place I touch the pointer
> > I pass to delete[] is in the constructor while allocating memory with new.
> 
> There can be lots of causes.  If you write beyond bounds anywhere in
> your program, this kind of errors can occur some place after the error,
> or not at all.

I suggest having a lunch break. Today I was working on a C++
problem with a team for some hours, and memory seemed to be getting
clobbered. We were using cvs, and we all committed changes
etc and went to lunch. When we came back, checked out fresh
source copies, and it worked. Two programs were having
the same bug in one of the base classes. We don't know
what changed, but it works now.

So, take a lunch break. :-)

> of error is extremely hard to pin down, especially in larger programs.
> The simple fact that your program runs OK on one platform using one
> compiler doesn't mean there are no errors which can turn out fatal with
> different compilers or on different platforms.  I have been able to
> crash ddd on this particular problem :(.

Try a different compiler, perhaps. I have not found g++ to be
the most helpful ever, eg it will not tell you which exception
occurred, just Abort. We are developing on Solaris so we have
Sun CC, which is nicer. The compiler finds more problems,
gives exception messages (and supports exceptions without
the -fhandle-exceptions kludge), and never gives interal compilre
errors, which g++ has been quite a bit. (2.7.2.2)


Hamish
-- 
Hamish Moffatt, StudIEAust              hamish@debian.org, hmoffatt@mail.com
Student, computer science & computer systems engineering.    3rd year, RMIT.
http://hamish.home.ml.org/ (PGP key here)             CPOM: [*****     ] 53%
The opposite of a profound truth may well be another profound truth.  --Bohr


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org . Trouble? 
e-mail to templin@bucknell.edu .


Reply to: