From mboxrd@z Thu Jan 1 00:00:00 1970 From: Josh Gagliardi To: help-gcc@gnu.org Subject: Re: Segmentation Fault: new char[12] Date: Wed, 08 Dec 1999 10:54:00 -0000 Message-id: <384EA7F1.4E7920CC@mediaone.net> References: <82jp3a$pal$1@nnrp1.deja.com> <82kesh$994$1@nnrp1.deja.com> <82ls9f$8il$1@nnrp1.deja.com> <82m7qn$pji$2@null.agames.com> X-SW-Source: 1999-12/msg00121.html > I don't think the "memory leak" is your biggest problem. The > visible result of a memory leak is that malloc() returns 0 after some > amount of time, but your code checks for that. Getting a _SEGFAULT_ > from malloc() (or free(), or whatever) is almost always caused by > your application corrupting the malloc "headers" that are often > stored adjacent to the allocated memory. You need to be looking for > array-bounds violations, not memory-leaks. Freeing something twice can also do bad things to the free list and cause a later malloc or free to SEGFAULT. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Josh Gagliardi To: help-gcc@gnu.org Subject: Re: Segmentation Fault: new char[12] Date: Fri, 31 Dec 1999 22:24:00 -0000 Message-ID: <384EA7F1.4E7920CC@mediaone.net> References: <82jp3a$pal$1@nnrp1.deja.com> <82kesh$994$1@nnrp1.deja.com> <82ls9f$8il$1@nnrp1.deja.com> <82m7qn$pji$2@null.agames.com> X-SW-Source: 1999-12n/msg00121.html Message-ID: <19991231222400.t21eprdU2W0Ig4hxhUrlERCgNvT5V-JvGd3jM6ojY4E@z> > I don't think the "memory leak" is your biggest problem. The > visible result of a memory leak is that malloc() returns 0 after some > amount of time, but your code checks for that. Getting a _SEGFAULT_ > from malloc() (or free(), or whatever) is almost always caused by > your application corrupting the malloc "headers" that are often > stored adjacent to the allocated memory. You need to be looking for > array-bounds violations, not memory-leaks. Freeing something twice can also do bad things to the free list and cause a later malloc or free to SEGFAULT.