Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > free(): invalid pointer:

Reply
Thread Tools

free(): invalid pointer:

 
 
Cyron
Guest
Posts: n/a
 
      09-30-2007
Hello friends,

I'm getting a bizaare glibc error referencing free -- I malloc a
chunk of memory and then later when I try to free it is when the
program aborts. I've added some debug code to the source and find
that my pointer i get from malloc matches the one that I'm calling
free with -- and there is no possibility that have i have previously
freed the memory because there is only 1 free call in the entire
source (surrounded by debug printfs) so I don't know what is going on.
Any insight?

Thanks,
Mike

 
Reply With Quote
 
 
 
 
gw7rib@aol.com
Guest
Posts: n/a
 
      09-30-2007
On 30 Sep, 21:03, Cyron <mdigit...@yahoo.com> wrote:
> Hello friends,
>
> I'm getting a bizaare glibc error referencing free -- I malloc a
> chunk of memory and then later when I try to free it is when the
> program aborts. I've added some debug code to the source and find
> that my pointer i get from malloc matches the one that I'm calling
> free with -- and there is no possibility that have i have previously
> freed the memory because there is only 1 free call in the entire
> source (surrounded by debug printfs) so I don't know what is going on.
> Any insight?


Are you perhaps writing to memory just outside the memory you have
allocated?

 
Reply With Quote
 
 
 
 
Flash Gordon
Guest
Posts: n/a
 
      09-30-2007
Cyron wrote, On 30/09/07 21:03:
> I'm getting a bizaare glibc error referencing free -- I malloc a
> chunk of memory and then later when I try to free it is when the
> program aborts. I've added some debug code to the source and find


<snip>

You are probably writing beyond the end or before the start of the
allocated space. If you can get the program down to a reasonably small
chunk of code that shows the problem we can take a look at it.
--
Flash Gordon
 
Reply With Quote
 
Richard Tobin
Guest
Posts: n/a
 
      09-30-2007
In article < om>,
Cyron <> wrote:

> I'm getting a bizaare glibc error referencing free -- I malloc a
>chunk of memory and then later when I try to free it is when the
>program aborts. I've added some debug code to the source and find
>that my pointer i get from malloc matches the one that I'm calling
>free with -- and there is no possibility that have i have previously
>freed the memory because there is only 1 free call in the entire
>source (surrounded by debug printfs) so I don't know what is going on.


You almost certainly have some kind of out-of-bounds pointer error.
Your first choice for finding such things, if you have one available,
is a memory-reference-checking tool such as valgrind. From your
reference to glibc, I assume you're using Linux, so valgrind should be
available. I find that 90% of the time it directs me straight to the
bug.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
invalid character in base-64 string and invalid postback or callba kevin ASP .Net 0 01-16-2008 09:39 PM
How do fix: "Wrong number of arguments" / "invalid propert assignment"/ "Invalid argument" Java Guy Javascript 1 10-15-2006 08:41 PM
How do fix: "Wrong number of arguments" / "invalid propert assignment"/ "Invalid argument" Java Guy Java 1 10-15-2006 08:31 PM
Invalid URI: There is an invalid sequence in the string. Error!! Patrick.O.Ige ASP .Net 1 07-02-2006 11:21 AM
invalid@invalid.org Hank Sniadoch Computer Information 1 08-20-2004 11:24 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57