This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: segmentation fault when allocating memory with new or malloc


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]