Date: Sun, 21 Sep 2008 01:15:36 +0300 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: unga888@yahoo.com Cc: freebsd-questions@freebsd.org, Nash Nipples <trashy_bumper@yahoo.com> Subject: Re: Segmentation fault when free [SOLVED] Message-ID: <873ajuv4zb.fsf@kobe.laptop> In-Reply-To: <55974.31287.qm@web57001.mail.re3.yahoo.com> (Unga's message of "Sat, 20 Sep 2008 07:04:03 -0700 (PDT)") References: <55974.31287.qm@web57001.mail.re3.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 20 Sep 2008 07:04:03 -0700 (PDT), Unga <unga888@yahoo.com> wrote: >On Sat, 9/20/08, Giorgos Keramidas <keramida@ceid.upatras.gr> wrote: >>> : free(0xbfbfc9c9) >>> >>> 1. This clearly shows my program is trying to free a memory that >>> has not been allocated. How it could have happened? >> >> Aha. This looks remarkably like an address in the runtime stack. It >> usually happens when you have a function that returns the address of >> a 'local' variable, instead of a newly allocated heap area, i.e.: >> >> char * >> function(void) >> { >> char buffer[100]; >> >> return buf; >> } > > This was indeed the case, worst yet, I was trying to free a part of > the buffer (as per your example above) by mistake which was not > allocated by malloc. > > Thank you all who helped me. Great! You are welcome, of course :)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?873ajuv4zb.fsf>