This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: segmentation fault when allocating memory with new or malloc
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: Tobias Kretz <kretz at traf1 dot uni-duisburg dot de>
- Cc: gcc-help at gcc dot gnu dot org
- Date: 13 Jan 2004 12:04:10 -0200
- Subject: Re: segmentation fault when allocating memory with new or malloc
- Organization: GCC Team, Red Hat
- References: <4003C90D.8060203@traffic.uni-duisburg.de>
On Jan 13, 2004, Tobias Kretz <kretz@traf1.uni-duisburg.de> wrote:
> causes the program to be terminated by a segmentation fault.
Unless you're allocating too much memory (which could cause such odd
behavior with a broken kernel, but not in general) or running out of
stack space (quite unlikely, unless you have very slow stack ulimits),
the most likely reason you're running into this problem is that you're
corrupting the heap internal data structures. It may have happened
long before the point in which you call malloc. I strongly recommend
using some memory checker. GNU libc supports MALLOC_CHECK_ (look for
it in the libc manual), but it doesn't catch all kinds of errors.
There are several alternatives.
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Happy GNU Year! oliva@{lsd.ic.unicamp.br, gnu.org}
Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist Professional serial bug killer