Re: Segfault in free(), electric-fence for C++ ?
> 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 don't have this problem if compile the same code on IRIX.
> I suspect that since I make quite large allocations, it may be a bug
> in memory handling in either g++ library or linux kernel itself.
> Do I have grounds for that?
I'm having some kind of memory corruption error with a C++ program
myself, but it is hard to point a finger at anything, since this kind
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 :(.
> And another thing, can I link electric-fence library with C++ code?
Yes, just add `-u malloc -lefence' when finally linking the executable,
g++ -g -O2 -o myprog myprog.o -lm -u malloc -lefence
E.L. Meijer (email@example.com) | tel. office +31 40 2472189
Eindhoven Univ. of Technology | tel. lab. +31 40 2475032
Lab. for Catalysis and Inorg. Chem. (TAK) | tel. fax +31 40 2455054
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
Trouble? e-mail to firstname.lastname@example.org .