Re: segmentation fault when allocating memory with new or malloc

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

 



On Jan 13, 2004, Tobias Kretz <kretz@xxxxxxxxxxxxxxxxxxxxx> 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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux