malloc(): memory corruption error

Jan 21, 2011 at 10:53am
Hi all

Could anyone please tell me why do I get this error when I try to add another simple string type variable to the struct?

*** glibc detected *** ./run-64bit: malloc(): memory corruption: 0x00000000008d2500 ***

Thanks
Jan 21, 2011 at 11:14am
It's because you're corrupting some memory.

As a general rule of thumb, to see this you are doing something (reading/writing/freeing) memory that is not yours.

If you're running under Linux, run your code again, but with the command 'valgrind' on the front, to run it under the excellent valgrind memchecker, which will often identify where you're going wrong (you may have to install valgrind, but it's available in many common repositories).
Jan 31, 2011 at 10:06am
Hello Moschops

I am very for sorry a late reply.

I have installed the valgrind and ran the program with it but it shows many many lines which are all above my head. I have been searching for google about a tutorial and have found one. I will read it soon.

Many thanks :)
Jan 31, 2011 at 10:28am
If you build a debug version (i.e. with debug symbols, which under gcc is done with the '-g' switch) the valgrind messages will be a bit more helpful.
Jan 31, 2011 at 11:42am
Thank you once again Moschops :)
Topic archived. No new replies allowed.