473,414 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

free(): invalid pointer

Hi All,

I have written a C++ program, it can be compiled (in UNIX) but when I
run it, I usually gives the following errors:

free(): invalid pointer 0x51d4a0!
free(): invalid pointer 0x51d460!
free(): invalid pointer 0x51d760!
free(): invalid pointer 0x51d7e0!
..
..
..

Can anyone help me to know what is the reason for this problem?

Thanks,

Jun 14 '06 #1
4 4307
c language wrote:
Hi All,

I have written a C++ program,
Then you should go down the hall to the C++ group.
it can be compiled (in UNIX) but when I
run it, I usually gives the following errors:

free(): invalid pointer 0x51d4a0!
free(): invalid pointer 0x51d460!
free(): invalid pointer 0x51d760!
free(): invalid pointer 0x51d7e0!
..
..
..

Can anyone help me to know what is the reason for this problem?

Passing an invalid pointer to free? When you post on the C++ group,
include the code.

--
Ian Collins.
Jun 14 '06 #2
c language wrote:
Hi All,

I have written a C++ program, it can be compiled (in UNIX) but when I
run it, I usually gives the following errors:

free(): invalid pointer 0x51d4a0!
free(): invalid pointer 0x51d460!
free(): invalid pointer 0x51d760!
free(): invalid pointer 0x51d7e0!

Can anyone help me to know what is the reason for this problem?


Why don't you try posting your question, along with a small, complete,
compilable example that demonstrates your issue, to comp.lang.c++. It
is very difficult to know exactly what the problem is without seeing
your code although, and I am going out on a limb here, you may be
trying to free an invalid pointer (i.e. a pointer that was not returned
to you by malloc and friends).

Robert Gamble

Jun 14 '06 #3

make sure the memory your pointer point to is allocated by fuction
"malloc"!

Jun 14 '06 #4
seni.yin schrieb:
make sure the memory your pointer point to is allocated by fuction
"malloc"!


What are you responding to? Please quote sufficient context.
The above may be right or wrong, depending on the context.

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Jun 14 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Ramprasad A Padmanabhan | last post by:
Hello all, If I assign one pointer to another , I had assumed I can call them interchangably. I can explain by the example below. I am doing a malloc to char* a which is the same as char* b....
17
by: kj | last post by:
How can one test if a pointer has been "freed" (i.e. with free())? My naive assumption was that such a pointer would equal NULL, but not so. Thanks, kj -- NOTE: In my address everything...
86
by: Walter Roberson | last post by:
If realloc() finds it necessary to move the memory block, then does it free() the previously allocated block? The C89 standard has some reference to undefined behaviour if one realloc()'s memory...
13
by: santosh | last post by:
Hi, If I call free() with a uninitialised pointer, will the program state become undefined, or will free() return harmlessly? Incidentally, is there a way in Standard C to determine weather a...
3
by: Ramki | last post by:
How does free() , delete() works? If we allocate memory using the following statement int *p = malloc(100*sizeof(int)); Inorder to release the memory we will call '"free(p) " How does...
171
by: Raman | last post by:
Hi All, Here is a small Code, int main(void) { char *p=(char *) malloc(100); strcpy(p,"Test1234567890"); p=p+10; free(p);
76
by: dbansal | last post by:
Hi group, I have a question to ask you all. I have allocated some chunk of memory using ptr=(int*)malloc(). now I am trying to free that memory using free((void*)ptr). My question is does free()...
17
by: anyone.anon | last post by:
Let p=malloc(N) for some N>0. As far as I understand it, free(p+k) for 0<k<N causes undefined behavior, since only a pointer returned by (m| re|c)alloc() can validly be passed to free(). This...
0
by: shrik | last post by:
I have following error : Total giant files in replay configuration file are : File name : /new_file/prob1.rec Given file /new_file/prob1.rec is successfully verified. Splitting for giant file...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.