*** glibc detected *** ./input: realloc(): invalid next size:
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
*** glibc detected *** ./input: realloc(): invalid next size:
hi,
in the program below i tried to allocate memory for pointers, it reads chars and put in data than put data in person that it points data and person has many datas,it's an array of pointers to datas,then i put the persons in all array that contains pointers to persons.
the problem is i am not sure where to free my allocated memories. the error message from glibc is
*** glibc detected *** ./input: realloc(): invalid next size: 0x0804a018
i think its about memory leak.Am i right?
i am new in here if i posted somewhere wrong sorry,and i'll be happy if you tell me anymhere else to ask that question.
thanks
my program is:
#include<stdio.h>
#include<stdlib.h>
int main()
{
char *first,*data,**pfirst,**person,ch,***afirst,***all;
int ndata,nch,nper;
It's not a memory leak problem. Memory leaks are situations where you allocate memory that you do not free when you're finished with it. The only bothersome symptom of a memory leak is that you use more and more memory.
No, what you probably have is a more frustrating problem. You're probably stomping on memory you shouldn't be stomping on. The most common causes of this are wandering outside the proper bounds for an array, using memory you've already freed, and freeing a block of memory more than once (after allocating it just once).
For help with this frustrating problem, pick one of these:
welcome to LQ. when you post code you should wrap it in [code][/code] tags.. this preserves the formatting. you can edit the post you made and add the code tags
as for your problem, if you load your program into gdb, and step through it it should lead you to the offending line(s).
if you load your program into gdb, and step through it it should lead you to the offending line(s).
Not in this case, not without additional help, if it's a problem with stomping on memory you shouldn't be stomping on, because the stomping is done at some unknown point in the program, and the error is usually discovered way later.
The purpose of the packages I recommended is to provide that additional help, and to cause your program to fail at that earlier point. That's where gdb will help you.
Not in this case, not without additional help, if it's a problem with stomping on memory you shouldn't be stomping on, because the stomping is done at some unknown point in the program, and the error is usually discovered way later.
The purpose of the packages I recommended is to provide that additional help, and to cause your program to fail at that earlier point. That's where gdb will help you.
eh, maybe so. i didnt run it through a debugger and check.. that was just a 2 second evaluation based on the fact that there is no check on the pointer realloc returns, and that everything is running in a questionable looping structure with incrementing size for reallocs..
anyhow. valgrind is good. theres also another mem manager out there i used a lot, Fluid Studios Memory Manager.. aka 'MMGR'
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.